Skip to content

Commit 76690b6

Browse files
authored
Merge pull request #698 from osrf/jessica/move_tf_to_ros
move tf to ros
2 parents bfc5c65 + 0aed330 commit 76690b6

File tree

11 files changed

+832
-7
lines changed

11 files changed

+832
-7
lines changed

vrx_gz/src/vrx_gz/bridges.py

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ def pose_static(model_name):
3838
ros_type='tf2_msgs/msg/TFMessage',
3939
direction=BridgeDirection.GZ_TO_ROS)
4040

41+
def joint_states(world_name, model_name):
42+
return Bridge(
43+
gz_topic=f'/world/{world_name}/model/{model_name}/joint_state',
44+
ros_topic='joint_states',
45+
gz_type='ignition.msgs.Model',
46+
ros_type='sensor_msgs/msg/JointState',
47+
direction=BridgeDirection.GZ_TO_ROS)
48+
4149
def cmd_vel(model_name):
4250
return Bridge(
4351
gz_topic=f'/model/{model_name}/cmd_vel',

vrx_gz/src/vrx_gz/launch.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
from launch.actions import RegisterEventHandler
2020
from launch.event_handlers import OnProcessExit
2121
from launch.launch_description_sources import PythonLaunchDescriptionSource
22-
22+
from launch import LaunchDescription
23+
from launch.actions import DeclareLaunchArgument
24+
from launch.substitutions import LaunchConfiguration
2325
from launch.actions import ExecuteProcess, EmitEvent
2426
from launch.events import Shutdown
2527

@@ -202,6 +204,11 @@ def competition_bridges(world_name):
202204
def spawn(sim_mode, world_name, models, robot=None):
203205
if type(models) != list:
204206
models = [models]
207+
use_sim_time = LaunchConfiguration('use_sim_time', default='true')
208+
DeclareLaunchArgument(
209+
'use_sim_time',
210+
default_value='true',
211+
description='Use simulation (Gazebo) clock if true'),
205212

206213
launch_processes = []
207214
for model in models:
@@ -237,13 +244,25 @@ def spawn(sim_mode, world_name, models, robot=None):
237244
remappings=[bridge.remapping() for bridge in bridges],
238245
))
239246

240-
# tf broadcaster
247+
# tf broadcaster (sensors)
241248
nodes.append(Node(
242249
package='vrx_ros',
243250
executable='pose_tf_broadcaster',
244251
output='screen',
245252
))
246253

254+
# robot_state_publisher (tf for wamv)
255+
model_dir = os.path.join(get_package_share_directory('vrx_gazebo'), 'models/wamv/tmp')
256+
urdf_file = os.path.join(model_dir, 'model.urdf')
257+
with open(urdf_file, 'r') as infp:
258+
robot_desc = infp.read()
259+
params = {'use_sim_time': use_sim_time, 'frame_prefix': 'wamv/', 'robot_description': robot_desc}
260+
nodes.append(Node(package='robot_state_publisher',
261+
executable='robot_state_publisher',
262+
output='both',
263+
parameters=[params],
264+
remappings=[('/joint_states', '/wamv/joint_states')]))
265+
247266
group_action = GroupAction([
248267
PushRosNamespace(model.model_name),
249268
*nodes

vrx_gz/src/vrx_gz/model.py

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def bridges(self, world_name):
7070
vrx_gz.bridges.pose(self.model_name),
7171
# pose static
7272
vrx_gz.bridges.pose_static(self.model_name),
73+
# joint states
74+
vrx_gz.bridges.joint_states(world_name, self.model_name),
7375
# comms tx
7476
# vrx_gz.bridges.comms_tx(self.model_name),
7577
# comms rx

vrx_urdf/vrx_gazebo/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ install(DIRECTORY config/
2323
install(PROGRAMS scripts/generate_wamv.py
2424
DESTINATION lib/${PROJECT_NAME})
2525

26-
2726
ament_python_install_package(
2827
vrx_gazebo
2928
PACKAGE_DIR src/vrx_gazebo

0 commit comments

Comments
 (0)