Skip to content

Commit 3edb53a

Browse files
committed
more work..
1 parent 5d5f72d commit 3edb53a

File tree

10 files changed

+168
-64
lines changed

10 files changed

+168
-64
lines changed

src/simulation/launch/bridge.launch.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,38 @@
22
from launch_ros.actions import Node
33

44
def generate_launch_description():
5+
# All bridge nodes use simulation time since they only run in simulation
56
return LaunchDescription([
7+
Node(
8+
package='ros_gz_bridge',
9+
executable='parameter_bridge',
10+
name='imu_bridge',
11+
output='screen',
12+
parameters=[{'use_sim_time': True}],
13+
arguments=[
14+
'/imu@sensor_msgs/msg/Imu[gz.msgs.IMU',
15+
],
16+
),
17+
18+
Node(
19+
package='ros_gz_bridge',
20+
executable='parameter_bridge',
21+
name='gps_bridge',
22+
output='screen',
23+
parameters=[{'use_sim_time': True}],
24+
arguments=[
25+
'/gps/fix@sensor_msgs/msg/NavSatFix@gz.msgs.NavSat',
26+
],
27+
),
28+
629
Node(
730
package='ros_gz_bridge',
831
executable='parameter_bridge',
932
name='depth_camera_bridge',
1033
output='screen',
34+
parameters=[{'use_sim_time': True}],
1135
arguments=[
36+
'/depth_camera@sensor_msgs/msg/Image@gz.msgs.Image',
1237
'/depth_camera/points@sensor_msgs/msg/PointCloud2@gz.msgs.PointCloudPacked',
1338
],
1439
),
@@ -18,6 +43,7 @@ def generate_launch_description():
1843
executable='parameter_bridge',
1944
name='clock_bridge',
2045
output='screen',
46+
parameters=[{'use_sim_time': True}],
2147
arguments=[
2248
'/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock',
2349
]
@@ -28,6 +54,7 @@ def generate_launch_description():
2854
executable='parameter_bridge',
2955
name='ground_truth_odom_bridge',
3056
output='screen',
57+
parameters=[{'use_sim_time': True}],
3158
arguments=[
3259
'/odom/ground_truth@nav_msgs/msg/Odometry@gz.msgs.Odometry',
3360
]

src/simulation/launch/ground_truth_tf.launch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def generate_launch_description():
2323
output='screen',
2424
parameters=[{
2525
'child_frame_id': LaunchConfiguration('child_frame_id'),
26-
'use_sim_time': True
26+
'use_sim_time': True # Always true since this only runs in simulation
2727
}]
2828
),
2929
])

src/simulation/launch/sim_bringup.launch.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from ament_index_python.packages import get_package_share_directory
22
from launch import LaunchDescription
33
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
4+
from launch.conditions import IfCondition
45
from launch.launch_description_sources import PythonLaunchDescriptionSource
56
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
67

@@ -11,10 +12,10 @@
1112
description='Gazebo world file to load'
1213
),
1314
DeclareLaunchArgument(
14-
'use_sim_time',
15+
'publish_ground_truth_tf',
1516
default_value='true',
1617
choices=['true', 'false'],
17-
description='Use simulation time from Gazebo'
18+
description='Publish ground truth odom -> base_footprint transform'
1819
),
1920
]
2021

@@ -26,7 +27,6 @@ def generate_launch_description():
2627
gazebo = IncludeLaunchDescription(
2728
PythonLaunchDescriptionSource([gazebo_launch]),
2829
launch_arguments=[
29-
('use_sim_time', LaunchConfiguration('use_sim_time')),
3030
('world', LaunchConfiguration('world'))
3131
]
3232
)
@@ -36,7 +36,14 @@ def generate_launch_description():
3636
PythonLaunchDescriptionSource([bridge_launch])
3737
)
3838

39+
ground_truth_tf_launch = PathJoinSubstitution([pkg_sim, 'launch', 'ground_truth_tf.launch.py'])
40+
ground_truth_tf = IncludeLaunchDescription(
41+
PythonLaunchDescriptionSource([ground_truth_tf_launch]),
42+
condition=IfCondition(LaunchConfiguration('publish_ground_truth_tf'))
43+
)
44+
3945
ld = LaunchDescription(ARGUMENTS)
4046
ld.add_action(gazebo)
4147
ld.add_action(bridge)
48+
ld.add_action(ground_truth_tf)
4249
return ld

src/subsystems/drive/drive_bringup/launch/athena_drive.launch.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,32 @@ def generate_launch_description():
6767
description="Gazebo world file to load (only used when use_sim:=true)",
6868
)
6969

70+
world_name_arg = DeclareLaunchArgument(
71+
"world_name",
72+
default_value="",
73+
description="Name of the world inside Gazebo (optional)",
74+
)
75+
76+
rqt_arg = DeclareLaunchArgument(
77+
"rqt",
78+
default_value="false",
79+
choices=["true", "false"],
80+
description="Start rqt_image_view for camera topics",
81+
)
82+
83+
image_topic_arg = DeclareLaunchArgument(
84+
"image_topic",
85+
default_value="/depth_camera",
86+
description="Image topic to view in rqt_image_view",
87+
)
88+
89+
publish_ground_truth_tf_arg = DeclareLaunchArgument(
90+
"publish_ground_truth_tf",
91+
default_value="true",
92+
choices=["true", "false"],
93+
description="Publish ground truth TF in simulation",
94+
)
95+
7096
use_sim = LaunchConfiguration("use_sim")
7197
runtime_config_package = LaunchConfiguration("runtime_config_package")
7298
description_package = LaunchConfiguration("description_package")
@@ -76,6 +102,10 @@ def generate_launch_description():
76102
start_rviz = LaunchConfiguration("start_rviz")
77103
rviz_file = LaunchConfiguration("rviz_file")
78104
world = LaunchConfiguration("world")
105+
world_name = LaunchConfiguration("world_name")
106+
rqt = LaunchConfiguration("rqt")
107+
image_topic = LaunchConfiguration("image_topic")
108+
publish_ground_truth_tf = LaunchConfiguration("publish_ground_truth_tf")
79109

80110
robot_controllers_path = PathJoinSubstitution(
81111
[FindPackageShare(runtime_config_package), "config", "athena_drive_controllers.yaml"]
@@ -91,7 +121,7 @@ def generate_launch_description():
91121
]),
92122
launch_arguments={
93123
"world": world,
94-
"use_sim_time": "true",
124+
"publish_ground_truth_tf": publish_ground_truth_tf,
95125
}.items(),
96126
condition=IfCondition(use_sim),
97127
)
@@ -129,17 +159,18 @@ def generate_launch_description():
129159
}.items(),
130160
)
131161

132-
hardware = IncludeLaunchDescription(
162+
spawn_robot = IncludeLaunchDescription(
133163
PythonLaunchDescriptionSource([
134164
PathJoinSubstitution([
135165
FindPackageShare(runtime_config_package),
136166
"launch",
137-
"hardware.launch.py"
167+
"spawn.launch.py"
138168
])
139169
]),
140170
launch_arguments={
141171
"use_sim": use_sim,
142172
"robot_name": "rover",
173+
"world_name": world_name,
143174
"spawn_x": "0.0",
144175
"spawn_y": "0.0",
145176
"spawn_z": "3.0",
@@ -174,6 +205,8 @@ def generate_launch_description():
174205
"description_package": description_package,
175206
"rviz_file": rviz_file,
176207
"use_sim": use_sim,
208+
"rqt": rqt,
209+
"image_topic": image_topic,
177210
}.items(),
178211
condition=IfCondition(start_rviz),
179212
)
@@ -189,11 +222,15 @@ def generate_launch_description():
189222
robot_controller_arg,
190223
start_rviz_arg,
191224
world_arg,
225+
world_name_arg,
226+
rqt_arg,
227+
image_topic_arg,
228+
publish_ground_truth_tf_arg,
192229
# Launch files and nodes
193230
sim_bringup,
194231
robot_description,
195232
teleop,
196-
hardware,
233+
spawn_robot,
197234
controllers,
198235
visualization,
199236
])

src/subsystems/drive/drive_bringup/launch/controllers.launch.py

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,44 @@ def controller_spawning_logic(context, *args, **kwargs):
3434
remappings=[
3535
("~/robot_description", "/robot_description"),
3636
],
37-
condition=UnlessCondition(use_sim),
38-
)
39-
40-
cmd_vel_relay = Node(
41-
package="topic_tools",
42-
executable="relay",
43-
name="cmd_vel_to_ackermann_relay",
44-
arguments=[
45-
"/cmd_vel",
46-
"/ackermann_steering_controller/reference",
47-
"--ros-args",
48-
"--log-level",
49-
"fatal",
50-
],
51-
parameters=[{"use_sim_time": use_sim}],
52-
output="log",
37+
#condition=UnlessCondition(use_sim),
5338
)
5439

55-
joy_relay = Node(
56-
package="topic_tools",
57-
executable="relay",
58-
name="joy_to_single_ackermann_relay",
59-
arguments=[
60-
"/joy",
61-
"/single_ackermann_controller/reference",
62-
"--ros-args",
63-
"--log-level",
64-
"fatal",
65-
],
66-
parameters=[{"use_sim_time": use_sim}],
67-
output="log",
68-
)
40+
# Relay nodes: route cmd_vel to the correct controller's reference topic
41+
relay_nodes = []
42+
43+
if robot_controller == "ackermann_steering_controller":
44+
# For ackermann_steering_controller: relay cmd_vel to its reference topic
45+
relay_nodes.append(Node(
46+
package="topic_tools",
47+
executable="relay",
48+
name="cmd_vel_relay",
49+
arguments=[
50+
"/cmd_vel",
51+
"/ackermann_steering_controller/reference",
52+
"--ros-args",
53+
"--log-level",
54+
"fatal",
55+
],
56+
parameters=[{"use_sim_time": use_sim}],
57+
output="log",
58+
))
59+
elif robot_controller == "single_ackermann_controller":
60+
# For single_ackermann_controller: relay cmd_vel to its reference topic
61+
relay_nodes.append(Node(
62+
package="topic_tools",
63+
executable="relay",
64+
name="cmd_vel_relay",
65+
arguments=[
66+
"/cmd_vel",
67+
"/single_ackermann_controller/reference",
68+
"--ros-args",
69+
"--log-level",
70+
"fatal",
71+
],
72+
parameters=[{"use_sim_time": use_sim}],
73+
output="log",
74+
))
6975

7076
joint_state_broadcaster_spawner = Node(
7177
package="controller_manager",
@@ -155,8 +161,7 @@ def controller_spawning_logic(context, *args, **kwargs):
155161

156162
return [
157163
control_node,
158-
cmd_vel_relay,
159-
joy_relay,
164+
*relay_nodes,
160165
delayed_controllers_real,
161166
delayed_controllers_sim,
162167
]

src/subsystems/drive/drive_bringup/launch/rviz.launch.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from launch import LaunchDescription
22
from launch.actions import DeclareLaunchArgument, TimerAction
3+
from launch.conditions import IfCondition
34
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
45
from launch_ros.actions import Node
56
from launch_ros.substitutions import FindPackageShare
@@ -28,12 +29,25 @@ def generate_launch_description():
2829
default_value="2.0",
2930
description="Delay in seconds before starting RViz.",
3031
),
32+
DeclareLaunchArgument(
33+
"rqt",
34+
default_value="false",
35+
choices=["true", "false"],
36+
description="Start rqt_image_view for camera topics.",
37+
),
38+
DeclareLaunchArgument(
39+
"image_topic",
40+
default_value="/depth_camera",
41+
description="Image topic to view in rqt_image_view.",
42+
),
3143
]
3244

3345
description_package = LaunchConfiguration("description_package")
3446
rviz_file = LaunchConfiguration("rviz_file")
3547
use_sim = LaunchConfiguration("use_sim")
3648
startup_delay = LaunchConfiguration("startup_delay")
49+
rqt = LaunchConfiguration("rqt")
50+
image_topic = LaunchConfiguration("image_topic")
3751

3852
rviz_config_file = PathJoinSubstitution(
3953
[FindPackageShare(description_package), "rviz", rviz_file]
@@ -54,4 +68,13 @@ def generate_launch_description():
5468
actions=[rviz_node],
5569
)
5670

57-
return LaunchDescription(declared_arguments + [delayed_rviz_launch])
71+
rqt_image_view_node = Node(
72+
package="rqt_image_view",
73+
executable="rqt_image_view",
74+
name="rqt_image_view",
75+
arguments=[image_topic],
76+
parameters=[{"use_sim_time": use_sim}],
77+
condition=IfCondition(rqt),
78+
)
79+
80+
return LaunchDescription(declared_arguments + [delayed_rviz_launch, rqt_image_view_node])

src/subsystems/drive/drive_bringup/launch/hardware.launch.py renamed to src/subsystems/drive/drive_bringup/launch/spawn.launch.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ def generate_launch_description():
1919
description="Name of the robot in Gazebo.",
2020
)
2121

22+
world_name_arg = DeclareLaunchArgument(
23+
"world_name",
24+
default_value="",
25+
description="Name of the world inside Gazebo (optional).",
26+
)
27+
2228
spawn_args = [
2329
DeclareLaunchArgument("spawn_x", default_value="0.0", description="Spawn X"),
2430
DeclareLaunchArgument("spawn_y", default_value="0.0", description="Spawn Y"),
@@ -28,6 +34,7 @@ def generate_launch_description():
2834

2935
use_sim = LaunchConfiguration("use_sim")
3036
robot_name = LaunchConfiguration("robot_name")
37+
world_name = LaunchConfiguration("world_name")
3138
spawn_x = LaunchConfiguration("spawn_x")
3239
spawn_y = LaunchConfiguration("spawn_y")
3340
spawn_z = LaunchConfiguration("spawn_z")
@@ -39,6 +46,7 @@ def generate_launch_description():
3946
executable="create",
4047
arguments=[
4148
"-name", robot_name,
49+
"-world", world_name,
4250
"-x", spawn_x,
4351
"-y", spawn_y,
4452
"-z", spawn_z,
@@ -53,6 +61,7 @@ def generate_launch_description():
5361
[
5462
use_sim_arg,
5563
robot_name_arg,
64+
world_name_arg,
5665
*spawn_args,
5766
spawn_robot,
5867
]

0 commit comments

Comments
 (0)