Skip to content

Commit 1377ed7

Browse files
authored
Merge pull request #22 from mleegwt/sensors
Sensors
2 parents 67a57d9 + e66241e commit 1377ed7

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

ros_ws/src/navigation/config/karaburan_boat.sdf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<pose>0 0 0.1 0 0 0</pose>
1616
</visual>
1717

18-
<!-- Massa/inertie van de romp; COM iets lager dan midden (0.07) -->
18+
<!-- Massa/inertie van de romp; COM iets lager dan midden -->
1919
<inertial>
2020
<pose>0 0 -0.02 0 0 0</pose>
2121
<mass>4.0</mass>
@@ -30,6 +30,20 @@
3030
<linear>0.02</linear>
3131
<angular>0.15</angular>
3232
</velocity_decay>
33+
34+
<sensor name="imu_sensor" type="imu">
35+
<gz_frame_id>imu_link</gz_frame_id>
36+
<always_on>1</always_on>
37+
<update_rate>30</update_rate>
38+
<visualize>false</visualize>
39+
<topic>/imu</topic>
40+
</sensor>
41+
<sensor name="gps_sensor" type="navsat">
42+
<gz_frame_id>gps_link</gz_frame_id>
43+
<always_on>1</always_on>
44+
<update_rate>5</update_rate>
45+
<topic>/gps</topic>
46+
</sensor>
3347
</link>
3448

3549
<!-- LEFT PROPELLER (link + joint) -->

ros_ws/src/navigation/config/world.sdf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
name="gz::sim::systems::Imu">
3131
</plugin>
3232

33+
<!-- Vereist door Gazebo's NavSat-systeem -->
34+
<spherical_coordinates>
35+
<surface_model>EARTH_WGS84</surface_model>
36+
<world_frame_orientation>ENU</world_frame_orientation>
37+
<latitude_deg>52.3728</latitude_deg> <!-- bv. Amsterdam -->
38+
<longitude_deg>4.8936</longitude_deg>
39+
<elevation>0</elevation>
40+
<heading_deg>0</heading_deg>
41+
</spherical_coordinates>
42+
43+
<plugin filename="gz-sim-navsat-system" name="gz::sim::systems::NavSat"/>
44+
3345
<model name="water_surface">
3446
<static>true</static>
3547
<pose>0 0 0 0 0 0</pose>

ros_ws/src/navigation/launch/sim.launch.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from launch import LaunchDescription
1212
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, TimerAction
1313
from launch.launch_description_sources import PythonLaunchDescriptionSource
14-
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
14+
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution, PythonExpression
1515
from launch_ros.actions import Node
1616
from launch_ros.substitutions import FindPackageShare
1717

@@ -31,6 +31,15 @@ def generate_launch_description():
3131
with_gazebo = LaunchConfiguration("with_gazebo")
3232
xacro_args = LaunchConfiguration("xacro_args")
3333

34+
# Build parameter_bridge arguments (GZ -> ROS for sensors)
35+
ns = LaunchConfiguration('ns')
36+
imu_topic = LaunchConfiguration('imu_topic')
37+
gps_topic = LaunchConfiguration('gps_topic')
38+
publish_static_tf = LaunchConfiguration('publish_static_tf')
39+
base_frame = LaunchConfiguration('base_frame')
40+
imu_frame = LaunchConfiguration('imu_frame')
41+
gps_frame = LaunchConfiguration('gps_frame')
42+
3443
return LaunchDescription([
3544
# Paths / args
3645
DeclareLaunchArgument(
@@ -59,6 +68,13 @@ def generate_launch_description():
5968
DeclareLaunchArgument(
6069
"xacro_args", default_value="",
6170
),
71+
# Launch args for the GZ - ROS2 bridge
72+
DeclareLaunchArgument('ns', default_value='', description='ROS namespace for the bridge'),
73+
DeclareLaunchArgument('imu_topic', default_value='/imu', description='GZ/ROS topic for IMU'),
74+
DeclareLaunchArgument('gps_topic', default_value='/gps', description='GZ/ROS topic for GPS/NavSat'),
75+
DeclareLaunchArgument('base_frame', default_value='base_link', description='Base frame id'),
76+
DeclareLaunchArgument('imu_frame', default_value='imu_link', description='IMU frame id (must match gz_frame_id in SDF)'),
77+
DeclareLaunchArgument('gps_frame', default_value='gps_link', description='GPS frame id (must match gz_frame_id in SDF)'),
6278

6379
IncludeLaunchDescription(
6480
PythonLaunchDescriptionSource(PathJoinSubstitution([
@@ -98,6 +114,18 @@ def generate_launch_description():
98114
"x": x, "y": y, "z": z,
99115
"R": R, "P": P, "Y": Y
100116
}.items()
117+
),
118+
Node(
119+
package='ros_gz_bridge',
120+
executable='parameter_bridge',
121+
name='ros_gz_parameter_bridge',
122+
namespace=ns,
123+
output='screen',
124+
arguments=[
125+
PythonExpression(['"', imu_topic, '" + \'@sensor_msgs/msg/Imu[gz.msgs.IMU\'']),
126+
PythonExpression(['"', gps_topic, '" + \'@sensor_msgs/msg/NavSatFix[gz.msgs.NavSat\'']),
127+
'/clock@rosgraph_msgs/msg/Clock[gz.msgs.Clock'
128+
],
101129
)
102130
]
103131
),

0 commit comments

Comments
 (0)