Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "robotics_application_manager"
version = "5.6.11"
version = "5.6.12"
authors = [
{ name="JdeRobot", email="jderobot@gmail.com" },
]
Expand Down
125 changes: 0 additions & 125 deletions robotics_application_manager/manager/launcher/launcher_gazebo.py

This file was deleted.

12 changes: 10 additions & 2 deletions robotics_application_manager/manager/launcher/launcher_gzsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,29 @@ def reset(self, robot_entity=None):
)
node = Node()

node.request(
f"/world/default/control",
WorldControl(pause=True),
WorldControl,
Boolean,
10000,
)

if robot_entity is not None:
node.request(
f"/world/default/remove",
Entity(name=robot_entity, type=Entity.MODEL),
Entity,
Boolean,
1000,
5000,
)

node.request(
f"/world/default/control",
WorldControl(pause=True, reset=WorldReset(all=True)),
WorldControl,
Boolean,
1000,
10000,
)

if is_ros_service_available("/drone0/controller/_reset"):
Expand Down
17 changes: 5 additions & 12 deletions robotics_application_manager/manager/launcher/launcher_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
from .launcher_interface import ILauncher

worlds = {
"gazebo": {
"2": [
{
"type": "gazebo",
"module": "robot_ros2_api",
"parameters": [],
"launch_file": [],
}
],
},
"gz": {
"2": [
{
Expand All @@ -44,10 +34,13 @@ class LauncherRobot(BaseModel):
module: str = ".".join(__name__.split(".")[:-1])
ros_version: int = get_ros_version()
launchers: Optional[ILauncher] = []
entity: str = ""
start_pose: Optional[list] = []

def run(self, start_pose=None, extra_config=None):
def run(self, entity="", start_pose=None, extra_config=None):
"""Run the robot launcher with an optional start pose."""
self.entity = entity

if start_pose is not None:
self.start_pose = start_pose

Expand Down Expand Up @@ -86,7 +79,7 @@ def process_terminated(name, exit_code):
launcher_class = get_class(launcher_module)
launcher = launcher_class.from_config(launcher_class, configuration)

launcher.run(self.start_pose, extra_config, process_terminated)
launcher.run(self.entity, self.start_pose, extra_config, process_terminated)
return launcher

def launch_command(self, configuration):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,10 @@

import logging
from robotics_application_manager import LogManager
from gz.transport13 import Node


def call_service(service, service_type, request_data="{}"):
command = f"ros2 service call {service} {service_type} '{request_data}'"
try:
p = subprocess.Popen(
[
f"{command}",
],
shell=True,
stdout=sys.stdout,
stderr=subprocess.STDOUT,
bufsize=1024,
universal_newlines=True,
)
p.wait(10)
except:
p.kill()

LogManager.logger.exception(f"Unable to complete call: {service}")
raise Exception(f"Unable to complete call: {service}")
from gz.msgs10.empty_pb2 import Empty
from gz.msgs10.scene_pb2 import Scene


class LauncherRobotRos2Api(ILauncher):
Expand All @@ -42,7 +25,7 @@ class LauncherRobotRos2Api(ILauncher):
launch_file: str
threads: List[Any] = []

def run(self, robot_pose, extra_config, callback):
def run(self, entity, robot_pose, extra_config, callback):
DRI_PATH = self.get_dri_path()
ACCELERATION_ENABLED = self.check_device(DRI_PATH)

Expand All @@ -66,6 +49,23 @@ def run(self, robot_pose, extra_config, callback):
exercise_launch_thread = DockerThread(exercise_launch_cmd)
exercise_launch_thread.start()

# Wait until robot entity has spawned
node = Node()
spawned = False
while not spawned:
a = node.request(
f"/world/default/scene/info",
Empty(),
Empty,
Scene,
1000,
)
if a[0]:
for model in a[1].model:
if model.name == entity:
spawned = True
LogManager.logger.info("Robot spawned OK")

def terminate(self):
if self.threads is not None:
for thread in self.threads:
Expand Down
10 changes: 0 additions & 10 deletions robotics_application_manager/manager/launcher/launcher_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
"external_port": 6082,
"internal_port": 5901,
},
"gazebo": {
"type": "module",
"width": 1024,
"height": 768,
"module": "gazebo",
"display": ":2",
"external_port": 6080,
"internal_port": 5900,
},
"gzsim": {
"type": "module",
"width": 1024,
Expand Down Expand Up @@ -68,7 +59,6 @@
}

simulator = {
"gazebo": {"tool": "gazebo"},
"gz": {"tool": "gzsim"},
"o3de": {"tool": "o3de"},
}
Expand Down
10 changes: 0 additions & 10 deletions robotics_application_manager/manager/launcher/launcher_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
from .launcher_interface import ILauncher

worlds = {
"gazebo": {
"2": [
{
"type": "gazebo",
"module": "ros2_api",
"parameters": [],
"launch_file": [],
}
],
},
"gz": {
"2": [
{
Expand Down
8 changes: 6 additions & 2 deletions robotics_application_manager/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ def on_launch_world(self, event):

self.world_launcher.run()
if self.robot_launcher is not None:
self.robot_launcher.run(robot_cfg["start_pose"], robot_cfg["extra_config"])
self.robot_launcher.run(
robot_cfg["entity"], robot_cfg["start_pose"], robot_cfg["extra_config"]
)
LogManager.logger.info("Launch transition finished")

def prepare_custom_universe(self, cfg_dict):
Expand Down Expand Up @@ -1008,7 +1010,9 @@ def reset_sim(self):
if self.robot_launcher:
try:
self.robot_launcher.run(
self.robot_config["start_pose"], self.robot_config["extra_config"]
self.robot_config["entity"],
self.robot_config["start_pose"],
self.robot_config["extra_config"],
)
except Exception as e:
LogManager.logger.exception("Exception terminating world launcher")
Expand Down
4 changes: 2 additions & 2 deletions test/dummyclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class LaunchWorldCmd(ManagerConsumerMessage):
command: str = "launch_world"
data: dict = {
"world": {
"type": "gazebo",
"launch_file_path": "/opt/jderobot/Launchers/simple_circuit_followingcam.launch.py",
"type": "gz",
"launch_file_path": "/opt/jderobot/Launchers/simple_circuit.launch.py",
},
"robot": {
"type": None,
Expand Down
Loading
Loading