Skip to content

Commit f0eeedb

Browse files
Feat/add gps launch (#14)
* include gps launch Signed-off-by: stevedan <[email protected]> * working version Signed-off-by: stevedan <[email protected]> * lintering Signed-off-by: stevedan <[email protected]> * Update nav2_minimal_tb3_sim/configs/turtlebot3_waffle_gps_bridge.yaml Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Stevedan Ogochukwu Omodolor <[email protected]> * Change naming Signed-off-by: stevedan <[email protected]> * change artifat from v1 to v4 Signed-off-by: stevedan <[email protected]> --------- Signed-off-by: stevedan <[email protected]> Signed-off-by: Stevedan Ogochukwu Omodolor <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
1 parent f4eefd0 commit f0eeedb

File tree

6 files changed

+1114
-1
lines changed

6 files changed

+1114
-1
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
import-token: ${{ secrets.GITHUB_TOKEN }}
2929
target-ros2-distro: ${{ matrix.ros_distro }}
30-
- uses: actions/upload-artifact@v1
30+
- uses: actions/upload-artifact@v4
3131
with:
3232
name: colcon-logs
3333
path: ros_ws/log
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# replace clock_bridge
2+
- topic_name: "/clock"
3+
ros_type_name: "rosgraph_msgs/msg/Clock"
4+
gz_type_name: "gz.msgs.Clock"
5+
direction: GZ_TO_ROS
6+
7+
# no equivalent in TB3 - add
8+
- topic_name: "joint_states"
9+
ros_type_name: "sensor_msgs/msg/JointState"
10+
gz_type_name: "gz.msgs.Model"
11+
direction: GZ_TO_ROS
12+
13+
# replace odom_bridge - check gz topic name
14+
# gz topic published by DiffDrive plugin
15+
- topic_name: "odom"
16+
ros_type_name: "nav_msgs/msg/Odometry"
17+
gz_type_name: "gz.msgs.Odometry"
18+
direction: GZ_TO_ROS
19+
20+
# replace odom_tf_bridge - check gz and ros topic names
21+
# gz topic published by DiffDrive plugin
22+
# prefix ros2 topic with gz
23+
- topic_name: "tf"
24+
ros_type_name: "tf2_msgs/msg/TFMessage"
25+
gz_type_name: "gz.msgs.Pose_V"
26+
direction: GZ_TO_ROS
27+
28+
# replace imu_bridge - check gz topic name
29+
- topic_name: "imu/data"
30+
ros_type_name: "sensor_msgs/msg/Imu"
31+
gz_type_name: "gz.msgs.IMU"
32+
direction: GZ_TO_ROS
33+
34+
# replace lidar_bridge
35+
- topic_name: "scan"
36+
ros_type_name: "sensor_msgs/msg/LaserScan"
37+
gz_type_name: "gz.msgs.LaserScan"
38+
direction: GZ_TO_ROS
39+
40+
# replace cmd_vel_bridge
41+
- topic_name: "cmd_vel"
42+
ros_type_name: "geometry_msgs/msg/Twist"
43+
gz_type_name: "gz.msgs.Twist"
44+
direction: ROS_TO_GZ
45+
46+
# replace navsat_bridge - check gz topic name
47+
- topic_name: "gps/fix"
48+
ros_type_name: "sensor_msgs/msg/NavSatFix"
49+
gz_type_name: "gz.msgs.NavSat"
50+
direction: GZ_TO_ROS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Copyright (C) 2023 Open Source Robotics Foundation
2+
# Copyright (C) 2024 Open Navigation LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
import os
17+
from pathlib import Path
18+
19+
20+
from ament_index_python.packages import get_package_share_directory
21+
22+
from launch import LaunchDescription
23+
from launch.actions import AppendEnvironmentVariable
24+
from launch.actions import DeclareLaunchArgument
25+
from launch.substitutions import LaunchConfiguration
26+
from launch.substitutions.command import Command
27+
from launch.substitutions.find_executable import FindExecutable
28+
29+
from launch_ros.actions import Node
30+
31+
32+
def generate_launch_description():
33+
bringup_dir = get_package_share_directory('nav2_minimal_tb3_sim')
34+
35+
namespace = LaunchConfiguration('namespace')
36+
robot_name = LaunchConfiguration('robot_name')
37+
robot_sdf = LaunchConfiguration('robot_sdf')
38+
pose = {
39+
'x': LaunchConfiguration('x_pose', default='-2.00'),
40+
'y': LaunchConfiguration('y_pose', default='-0.50'),
41+
'z': LaunchConfiguration('z_pose', default='0.01'),
42+
'R': LaunchConfiguration('roll', default='0.00'),
43+
'P': LaunchConfiguration('pitch', default='0.00'),
44+
'Y': LaunchConfiguration('yaw', default='0.00'),
45+
}
46+
47+
# Declare the launch arguments
48+
declare_namespace_cmd = DeclareLaunchArgument(
49+
'namespace', default_value='', description='Top-level namespace'
50+
)
51+
52+
declare_robot_name_cmd = DeclareLaunchArgument(
53+
'robot_name',
54+
default_value='turtlebot3_waffle_gps',
55+
description='name of the robot',
56+
)
57+
58+
declare_robot_sdf_cmd = DeclareLaunchArgument(
59+
'robot_sdf',
60+
default_value=os.path.join(bringup_dir, 'urdf', 'gz_waffle_gps.sdf.xacro'),
61+
description='Full path to robot sdf file to spawn the robot in gazebo',
62+
)
63+
64+
bridge = Node(
65+
package='ros_gz_bridge',
66+
executable='parameter_bridge',
67+
namespace=namespace,
68+
parameters=[
69+
{
70+
'config_file': os.path.join(
71+
bringup_dir, 'configs', 'turtlebot3_waffle_gps_bridge.yaml'
72+
),
73+
'expand_gz_topic_names': True,
74+
'use_sim_time': True,
75+
}
76+
],
77+
output='screen',
78+
)
79+
80+
spawn_model = Node(
81+
package='ros_gz_sim',
82+
executable='create',
83+
output='screen',
84+
namespace=namespace,
85+
arguments=[
86+
'-name',
87+
robot_name,
88+
'-string',
89+
Command(
90+
[
91+
FindExecutable(name='xacro'),
92+
' ',
93+
'namespace:=',
94+
LaunchConfiguration('namespace'),
95+
' ',
96+
robot_sdf,
97+
]
98+
),
99+
'-x',
100+
pose['x'],
101+
'-y',
102+
pose['y'],
103+
'-z',
104+
pose['z'],
105+
'-R',
106+
pose['R'],
107+
'-P',
108+
pose['P'],
109+
'-Y',
110+
pose['Y'],
111+
],
112+
)
113+
114+
set_env_vars_resources = AppendEnvironmentVariable(
115+
'GZ_SIM_RESOURCE_PATH', os.path.join(bringup_dir, 'models')
116+
)
117+
set_env_vars_resources2 = AppendEnvironmentVariable(
118+
'GZ_SIM_RESOURCE_PATH', str(Path(os.path.join(bringup_dir)).parent.resolve())
119+
)
120+
121+
# Create the launch description and populate
122+
ld = LaunchDescription()
123+
ld.add_action(declare_namespace_cmd)
124+
ld.add_action(declare_robot_name_cmd)
125+
ld.add_action(declare_robot_sdf_cmd)
126+
127+
ld.add_action(set_env_vars_resources)
128+
ld.add_action(set_env_vars_resources2)
129+
130+
ld.add_action(bridge)
131+
ld.add_action(spawn_model)
132+
return ld

0 commit comments

Comments
 (0)