Skip to content

Commit e84c0a8

Browse files
committed
Testing pick and place manager
1 parent 75868bb commit e84c0a8

5 files changed

Lines changed: 58 additions & 75 deletions

File tree

robotics_application_manager/manager/docker_thread/docker_thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run(self):
2020
self.process = subprocess.Popen(
2121
self.cmd,
2222
shell=self.shell,
23-
stdout=subprocess.PIPE,
23+
stdout=sys.stdout,
2424
stderr=subprocess.PIPE,
2525
start_new_session=True,
2626
bufsize=1024,

robotics_application_manager/manager/launcher/launcher_gzsim.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
from typing import List, Any
1414
from robotics_application_manager import LogManager
1515

16+
from gz.msgs10.world_control_pb2 import WorldControl
17+
from gz.msgs10.boolean_pb2 import Boolean
18+
from gz.transport13 import Node
19+
1620

1721
def call_gzservice(service, reqtype, reptype, timeout, req):
1822
command = f"gz service -s {service} --reqtype {reqtype} --reptype {reptype} --timeout {timeout} --req '{req}'"
@@ -162,8 +166,17 @@ def reset(self):
162166
"gz.msgs.WorldControl",
163167
"gz.msgs.Boolean",
164168
"3000",
165-
"reset: {all: true}",
169+
"reset: {model_only: true}",
166170
)
171+
172+
# node = Node()
173+
# simControl_service = "/world/default/control"
174+
# simControl_msg = WorldControl()
175+
# simControl_msg.reset = "model_only"
176+
# response = node.request(
177+
# simControl_service, simControl_msg, WorldControl, Boolean, 3000
178+
# )
179+
167180
if is_ros_service_available("/drone0/controller/_reset"):
168181
call_service("/drone0/controller/_reset", "std_srvs/srv/Trigger", "{}")
169182

robotics_application_manager/manager/launcher/launcher_robot.py

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,26 @@
1313

1414
worlds = {
1515
"gazebo": {
16-
"1": [
17-
{
18-
"type": "module",
19-
"module": "ros_api",
20-
"parameters": [],
21-
"launch_file": [],
22-
}
23-
],
2416
"2": [
2517
{
26-
"type": "module",
18+
"type": "gazebo",
2719
"module": "robot_ros2_api",
2820
"parameters": [],
2921
"launch_file": [],
3022
}
3123
],
3224
},
33-
"drones": {
34-
"1": [
35-
{
36-
"type": "module",
37-
"module": "drones",
38-
"resource_folders": [],
39-
"model_folders": [],
40-
"plugin_folders": [],
41-
"parameters": [],
42-
"launch_file": [],
43-
}
44-
],
45-
"2": [
46-
{
47-
"type": "module",
48-
"module": "drones_ros2",
49-
"resource_folders": [],
50-
"model_folders": [],
51-
"plugin_folders": [],
52-
"parameters": [],
53-
"launch_file": [],
54-
}
55-
],
56-
},
57-
"gzsimdrones": {
25+
"gz": {
5826
"2": [
5927
{
60-
"type": "module",
61-
"module": "drones_gzsim",
62-
"resource_folders": [],
63-
"model_folders": [],
64-
"plugin_folders": [],
28+
"type": "gz",
29+
"module": "robot_ros2_api",
6530
"parameters": [],
6631
"launch_file": [],
6732
}
6833
],
6934
},
35+
"o3de": {},
7036
"physical": {},
7137
}
7238

robotics_application_manager/manager/launcher/launcher_robot_ros2_api.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,30 @@ def terminate(self):
4848
thread.join()
4949
self.threads.remove(thread)
5050

51-
kill_cmd = "pkill -9 -f "
52-
cmd = kill_cmd + "spawn_robot.launch.py"
53-
subprocess.call(
54-
cmd,
55-
shell=True,
56-
stdout=subprocess.PIPE,
57-
bufsize=1024,
58-
universal_newlines=True,
59-
)
51+
# kill_cmd = "pkill -9 -f "
52+
# cmd = kill_cmd + "spawn_robot_warehouse.launch.py"
53+
# subprocess.call(
54+
# cmd,
55+
# shell=True,
56+
# stdout=subprocess.PIPE,
57+
# bufsize=1024,
58+
# universal_newlines=True,
59+
# )
6060

61-
kill_cmd = "pkill -9 "
62-
cmd = kill_cmd + "bridg"
63-
subprocess.call(
64-
cmd,
65-
shell=True,
66-
stdout=subprocess.PIPE,
67-
bufsize=1024,
68-
universal_newlines=True,
69-
)
61+
# cmd = kill_cmd + "/opt/ros/humble"
62+
# subprocess.call(
63+
# cmd,
64+
# shell=True,
65+
# stdout=subprocess.PIPE,
66+
# bufsize=1024,
67+
# universal_newlines=True,
68+
# )
7069

71-
cmd = kill_cmd + "robot_state_publisher"
72-
subprocess.call(
73-
cmd,
74-
shell=True,
75-
stdout=subprocess.PIPE,
76-
bufsize=1024,
77-
universal_newlines=True,
78-
)
70+
# cmd = kill_cmd + "robot_state_publisher"
71+
# subprocess.call(
72+
# cmd,
73+
# shell=True,
74+
# stdout=subprocess.PIPE,
75+
# bufsize=1024,
76+
# universal_newlines=True,
77+
# )

robotics_application_manager/manager/manager.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def __init__(self, host: str, port: int):
211211
self.world_launcher = None
212212
self.world_type = None
213213
self.robot_launcher = None
214+
self.robot_pose = None
214215
self.tools_launcher = None
215216
self.application_process = None
216217
self.running = True
@@ -349,7 +350,8 @@ def on_launch_world(self, event):
349350

350351
self.robot_launcher = LauncherRobot(**cfg.model_dump())
351352
LogManager.logger.info(str(self.robot_launcher))
352-
self.robot_launcher.run(robot_cfg["start_pose"])
353+
self.robot_pose = robot_cfg["start_pose"]
354+
self.robot_launcher.run(self.robot_pose)
353355
LogManager.logger.info("Launch transition finished")
354356

355357
def prepare_custom_universe(self, cfg_dict):
@@ -767,6 +769,7 @@ def on_terminate_universe(self, event):
767769
if self.robot_launcher is not None:
768770
self.robot_launcher.terminate()
769771
self.robot_launcher = None
772+
self.robot_pose = None
770773

771774
def on_disconnect(self, event):
772775
"""
@@ -790,6 +793,7 @@ def on_disconnect(self, event):
790793
LogManager.logger.exception("Exception terminating tools launcher")
791794

792795
if self.robot_launcher:
796+
self.robot_pose = None
793797
try:
794798
self.robot_launcher.terminate()
795799
except Exception as e:
@@ -873,20 +877,21 @@ def reset_sim(self):
873877
the appropriate ROS or Gazebo services based on the visualization type,
874878
and relaunches the robot if a launcher is available.
875879
"""
876-
if self.robot_launcher:
877-
self.robot_launcher.terminate()
880+
# if self.robot_launcher:
881+
# self.robot_launcher.terminate()
878882

879883
try:
880884
self.tools_launcher.reset()
881885
except subprocess.TimeoutExpired as e:
882886
self.write_to_tool_terminal(f"{e}\n\n")
883887
raise Exception("Failed to reset simulator")
884888

885-
if self.robot_launcher:
886-
try:
887-
self.robot_launcher.run()
888-
except Exception as e:
889-
LogManager.logger.exception("Exception terminating world launcher")
889+
# if self.robot_launcher:
890+
# try:
891+
# LogManager.logger.exception("Relaunching robot launcher")
892+
# self.robot_launcher.run(self.robot_pose)
893+
# except Exception as e:
894+
# LogManager.logger.exception("Exception terminating world launcher")
890895

891896
def start(self):
892897
"""

0 commit comments

Comments
 (0)