Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update record_bag action #112

Merged
merged 35 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f392244
publish by snapshot by default, update clients
fred-labs Jul 15, 2024
fd8bd86
format
fred-labs Jul 15, 2024
f96ced2
fix colors for other schemes
fred-labs Jul 15, 2024
dec9f68
linter
fred-labs Jul 15, 2024
529d3a8
cleanup
fred-labs Jul 15, 2024
5802e50
Update record_bag, add to multi-robot example
fred-labs Jul 15, 2024
6e65fdf
update doc
fred-labs Jul 15, 2024
bc59d60
format
fred-labs Jul 15, 2024
c89956a
test ci
fred-labs Jul 15, 2024
a9ad2c8
update upload
fred-labs Jul 15, 2024
130e0d1
revert timeout
fred-labs Jul 15, 2024
20b822f
limit recording
fred-labs Jul 16, 2024
e04dcba
change prios
fred-labs Jul 16, 2024
f70eff0
change prios
fred-labs Jul 16, 2024
6e94524
cleanup
fred-labs Jul 16, 2024
835798b
use sim time
fred-labs Jul 16, 2024
af18690
Merge branch 'main' into ci_rosbag
fred-labs Jul 16, 2024
b8e84b1
test different rmw
fred-labs Jul 16, 2024
63d9a49
extend timeout
fred-labs Jul 16, 2024
28ffb2c
cleanup
fred-labs Jul 16, 2024
1ecff80
cleanup
fred-labs Jul 16, 2024
9369fc4
test
fred-labs Jul 16, 2024
01b68d4
example_multi_robot: replace second robot
fred-labs Jul 16, 2024
7653b8f
test
fred-labs Jul 16, 2024
a8dc885
add static camera for ci
fred-labs Jul 16, 2024
de006e0
fix orientation
fred-labs Jul 16, 2024
23f89d2
fix orientation
fred-labs Jul 16, 2024
f87a27a
test with delay
fred-labs Jul 16, 2024
64e218b
test with delay
fred-labs Jul 16, 2024
0061d4a
test with delay
fred-labs Jul 16, 2024
a5c2171
analyze orientation issue
fred-labs Jul 17, 2024
f44b35b
cleanup
fred-labs Jul 17, 2024
dce2465
cleanup
fred-labs Jul 17, 2024
503d74c
cleanup
fred-labs Jul 17, 2024
67cda2f
cleanup
fred-labs Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ jobs:
with:
name: test-example-multirobot-result
path: test_example_multirobot/test.xml
- name: Upload ros bag
uses: actions/upload-artifact@ef09cdac3e2d3e60d8ccadda691f4f1cec5035cb
if: always()
with:
name: test-example-multirobot-ros-bag
path: test_example_multirobot/**/rosbag*
test-example-external-method:
needs: [build]
runs-on: intellabs-01
Expand Down
6 changes: 5 additions & 1 deletion docs/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,12 @@ A common topic to record is ``/scenario_execution/snapshots`` which publishes ch
- Whether to record hidden topics
* - ``storage``
- ``string``
-
- ``''``
- Storage type to use (empty string: use ROS bag record default)
* - ``use_sim_time``
- ``bool``
- ``false``
- Use simulation time for message timestamps by subscribing to the /clock topic

``ros_launch()``
""""""""""""""""
Expand Down
18 changes: 2 additions & 16 deletions examples/example_multi_robot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,10 @@ source install/setup.bash
```
The Following example spawns 2 robots. The first robot is initialised with nav2 and moves in a straight line. Once it reaches a specific point a velocity command is sent to the second robot which will position itsel in front of the first one. The first robot then replans its path and moves around the second robot.

To actually run the scenario, run the following commands.
Note: due to an [issue](https://github.com/turtlebot/turtlebot4_simulator/issues/60) with the turtlebot simulation when running multiple robots, some launch commands need to run in separate terminals.
Launch the simulation and spawn the first robot by running the following command:
To actually run the scenario, run the following command.

```bash
ros2 launch tb4_sim_scenario sim_nav_scenario_launch.py scenario_execution:=False scenario:=foo yaw:=3.14
```

To spawn the second robot, run the following command in a new terminal:

```bash
ros2 launch tb4_sim_scenario ignition_robot_launch.py namespace:=turtlebot2 x:=-3.0 y:=1.5 yaw:=-1.57
```

To run the actual scenario, run the following command in a third terminal:

```bash
ros2 launch scenario_execution scenario_launch.py scenario:=examples/example_multi_robot/example_multi_robot.osc
ros2 launch tb4_sim_scenario sim_nav_scenario_launch.py scenario:=examples/example_multi_robot/example_multi_robot.osc
```

For a more detailed understanding of the code structure and scenario implementation please refer to the [tutorial documentation](https://intellabs.github.io/scenario_execution/tutorials.html).
174 changes: 13 additions & 161 deletions examples/example_multi_robot/example_multi_robot.osc
Original file line number Diff line number Diff line change
@@ -1,179 +1,31 @@
import osc.ros
import osc.gazebo

scenario nav2_simulation_nav_to_pose:
scenario multi_robot:
robot: differential_drive_robot
robot2: osc_actor
do parallel:
serial:
parallel:
robot2.spawn(pose_3d(position_3d(x: -3.0, y: 1.5, z: 0.3), orientation_3d(yaw: -1.57)), model: 'example_multi_robot://models/robot.sdf')
ros_launch("example_multi_robot", "robot2_launch.py", wait_for_shutdown: false)
ros_launch("gazebo_static_camera", "spawn_static_camera_launch.py", [ key_value('x', '-3'), key_value('z', '10'), key_value('pitch', '1.57')], wait_for_shutdown: false)
record_bag(['/tf', '/tf_static', '/scenario_execution/snapshots', '/map', '/static_camera/image_raw', '/local_costmap/costmap', '/initialpose'], use_sim_time: true)
parallel:
test_drive: serial:
robot.init_nav2(initial_pose: pose_3d(position: position_3d(), orientation: orientation_3d(yaw: 3.14rad)))
robot.init_nav2(initial_pose: pose_3d(orientation: orientation_3d(yaw: 3.14rad)))
robot.nav_to_pose(goal_pose: pose_3d(position: position_3d(x: -4.0m), orientation: orientation_3d(yaw: 3.14rad)))
emit end
serial:
robot.tf_close_to() with:
keep(it.reference_point.x == -1.5m)
keep(it.reference_point.y == 0.0m)
keep(it.threshold == 0.35m)
keep(it.robot_frame_id == 'turtlebot4_base_link_gt')
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_name == '/robot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.3, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(0.2s)
topic_publish() with:
keep(it.topic_name == '/turtlebot2/cmd_vel')
keep(it.topic_type == 'geometry_msgs.msg.Twist')
keep(it.value == '{\"linear\": {\"x\": 0.30, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
emit end
keep(it.value == '{\"linear\": {\"x\": 0.6, \"y\": 0.0, \"z\": 0.0}, \"angular\": {\"x\": 0.0, \"y\": 0.0, \"z\": 0.0}}')
wait elapsed(10s)
time_out: serial:
wait elapsed(240s)
emit fail
58 changes: 58 additions & 0 deletions examples/example_multi_robot/launch/robot2_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (C) 2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration

from launch_ros.actions import Node


ARGUMENTS = [
DeclareLaunchArgument('robot_name', default_value='robot2',
description='name of robot'),
]


def generate_launch_description():

# Launch configurations
robot_name = LaunchConfiguration('robot_name')

cmd_vel_bridge = Node(
package='ros_gz_bridge',
executable='parameter_bridge',
name='cmd_vel_bridge',
output='screen',
parameters=[{
'use_sim_time': True
}],
arguments=[
[robot_name,
'/cmd_vel' + '@geometry_msgs/msg/Twist' + '[ignition.msgs.Twist'],
['/model/', robot_name, '/cmd_vel' +
'@geometry_msgs/msg/Twist' +
']ignition.msgs.Twist']
],
remappings=[
(['/model/', robot_name, '/cmd_vel'], [robot_name, '/cmd_vel'])
]
)

# Define LaunchDescription variable
ld = LaunchDescription(ARGUMENTS)
ld.add_action(cmd_vel_bridge)
return ld
Loading
Loading