osrf / rmf_demos

Demos to showcase the capabilities of RMF
Apache License 2.0
69 stars 38 forks source link

package that spawns tinyrobot #169

Closed txlei closed 3 years ago

txlei commented 3 years ago

In office.launch demo, how does the simulated tinyrobot actually get spawned in gazebo? Its different from my understanding referencing the turtlebot3_gazebo launches that use the gazebo_ros package. In rqt_graph, I could not find common robot topics like /cmd_vel and /scan for each robot.

On another note, could you point to me the configuration where gazebo learns to spawn 2 tinyrobot in particular to the office demo context?

Specifically, I am actually trying to spawn multiple turtlebots with its individual free fleet client node, and sending request_msg commands from rmf_demo_tasks.

Yadunund commented 3 years ago

The TinyRobot model is "spawned" in gazebo by including its model SDF file in the generated office.world file via its URI. (check install/rmf_demo_maps/share/rmf_demo_maps/maps/office/office.world) In the generated office.world file you should find the sub-element below. More information on the syntax can be found here

    <include>
      <name>tinyRobot1</name>
      <uri>model://TinyRobot</uri>
      <pose>11.553368836072618 -11.315970962255989 0.0 0 0 -1.5772312340829895</pose>
    </include>

When annotating waypoints in traffic-editor, you can choose to spawn a robot at a waypoint by setting the spawn_robot_type and spawn_robot_name to the asset name and a unique model name respectively. See screenshot below for annotation for spawning tinyRobot1 in office world. image

During build time, the building_map_generator script is invoked to generate the office.world file from the office.building.yaml file. Here is the entry point for generating the <include> sub-element in the .world file.

I would like to highlight that the robots spawned in the rmf_demos simulations do not rely on a nav stack to navigate around the world. Instead they are controlled by the slotcar plugin. Hence, the missing cmd_vel/ and scan/ topics.

The free_fleet README has instructions to run simulations with multiple Turtlebots.

txlei commented 3 years ago

These functionalities, for a "full control" robot type, are achieved through the slotcar plugin.

written in the multi robot book under simulation section. Does this mean that a simulated turtlebot that is spawn by gazebo_ros as a free fleet client on machine1 cannot be visualised in the gazebo office world (machine2) that is specific to traffic editor params like spawn_robot_type and spawn_robot_name? I understand that free fleet server also subscribes to /robot_path_requests and /robot_mode_requests topics, similar to slotcar plugin

Marcusttk commented 3 years ago

The TinyRobot model is "spawned" in gazebo by including its model SDF file in the generated office.world file via its URI. (check install/rmf_demo_maps/share/rmf_demo_maps/maps/office/office.world) In the generated office.world file you should find the sub-element below. More information on the syntax can be found here

    <include>
      <name>tinyRobot1</name>
      <uri>model://TinyRobot</uri>
      <pose>11.553368836072618 -11.315970962255989 0.0 0 0 -1.5772312340829895</pose>
    </include>

When annotating waypoints in traffic-editor, you can choose to spawn a robot at a waypoint by setting the spawn_robot_type and spawn_robot_name to the asset name and a unique model name respectively. See screenshot below for annotation for spawning tinyRobot1 in office world. image

During build time, the building_map_generator script is invoked to generate the office.world file from the office.building.yaml file. Here is the entry point for generating the <include> sub-element in the .world file.

I would like to highlight that the robots spawned in the rmf_demos simulations do not rely on a nav stack to navigate around the world. Instead they are controlled by the slotcar plugin. Hence, the missing cmd_vel/ and scan/ topics.

The free_fleet README has instructions to run simulations with multiple Turtlebots.

I have done this, and my robot is in my custom .world file.

image

However, when I try to launch it, the robot model does not appear in my gazebo environment, and I get the following error msg:

[tinyRobot_fleet_adapter]: Robot named [tinyRobot2] belonging to fleet [tinyRobot] is lost because we cannot figure out what floor it is on. Please publish the robot's current floor name in the level_name field of its RobotState.

Please advise on what I need to do to display my robot in the gazebo environment. Thank you.

For reference: My launch file regarding the TinyRobot slotcar_plugin: image

Marcusttk commented 3 years ago

@Yadunund Any feedback? Thanks

Yadunund commented 3 years ago

@txlei

Does this mean that a simulated turtlebot that is spawn by gazebo_ros as a free fleet client on machine1 cannot be visualised in the gazebo office world (machine2) that is specific to traffic editor params like spawn_robot_type and spawn_robot_name?

This is not true. You should be able to spawn a tb into the same gazebo instance. Let us know if you're still having troubles with that.

Yadunund commented 3 years ago

@Marcusttk Is the waypoint that you are spawning the robot on, connected to a graph? ie, are there traffic lanes going to/from the waypoint? Also, to check, have you created a new Level in traffic_editor with a valid name? Could you share a screenshot of the levels tab in traffic_editor (located in the right-side toolbox). Lastly could you also ensure you have added flooring to your map?

txlei commented 3 years ago

what i did in a single machine

  1. [rmf on foxy] ros2 launch demos office.launch.xml with the turtlebot model in rmf_demo_assets package. using the same fleet adapter and robot state aggregator as tinyrobot office demo.
  2. [free fleet server on foxy] ros2 launch ff_examples_ros2 turtlebot3_world_ff.launch.xml
  3. [free fleet client on noetic] export TURTLEBOT3_MODEL=burger; roslaunch ff_examples_ros1 turtlebot3_world_ff.launch edited the launch file to point to office world map in the rmf_demo_maps package in install folder

unable to launch [3] with following error

[ WARN] [1609751812.397049501]: Request for map failed; trying again...
[gazebo-2] process has died [pid 27779, exit code 255, cmd /opt/ros/noetic/lib/gazebo_ros/gzserver -e ode /home/USER/client_freefleet_ws/install/turtlebot3_gazebo/share/turtlebot3_gazebo/worlds/turtlebot3_world.world __name:=gazebo __log:=/home/leia/.ros/log/944a9b1e-4e6d-11eb-bcbe-e1bbf47d4129/gazebo-2.log].
log file: /home/USER/.ros/log/944a9b1e-4e6d-11eb-bcbe-e1bbf47d4129/gazebo-2*.log

however, the issue that I have not figured out, since office world map with its robots is generated when building the demos package, how do I include the turtlebot model at that step?

Marcusttk commented 3 years ago

@Yadunund

You may refer to my traffic editor screenshot below

image

The robot is on the traffic lane, and I have added flooring.

I suspect the issue might be related to the fleet adapter. I am using the tinyRobot fleet adapter. Which file do I have to change to use this fleet adapter for my own map?

Thanks.

Yadunund commented 3 years ago

@Marcusttk Just noticed the problem in the previous screenshot. The 'nav_graph_file' argument in your launch file is still pointing at the one from the office map in rmf_demo_maps. Please pass in the appropriate navigation graph file.

Marcusttk commented 3 years ago

@Yadunund that fixes the problem. Thanks for your help!

aaronchongth commented 3 years ago

Hello @txlei!

As the demo is launched in ROS 2, the gazebo plugins that handle model spawning will be service calls in ROS 2, while all the model spawning functionalities in free fleet is currently ROS 1. It becomes rather tricky if you'd like to run both ROS 1 and ROS 2 in the same simulation and we have not explored that.

My suggestion for now would be to work on Turtlebot3 in simulation using the nav2 stack and implement a fleet adapter for it.

txlei commented 3 years ago

@aaronchongth

for your suggestion, with a Turtlebot3 simulation running on foxy with its free fleet client node. How do I get the gazebo server or rviz launch in demos to get its model and frames from the Turtlebot3 simulation?

And without gazebo, in real-life set up with physical robots, is it possible to visualise the rmf traffic's proposed path in rviz for each robot? using robot_state_publisher node to publish robot's frames. Has it been done in the demos project? The goal is to avoid having to create an UI or fleet manager to visualise the rmf traffic capability on screen. Hopefully using the demos project to minimise the effort. Any other suggestions?

aaronchongth commented 3 years ago

Hey @txlei!

for your suggestion, with a Turtlebot3 simulation running on foxy with its free fleet client node.

The current implementation of the free fleet client interacts directly with the ROS 1 navigation stack (robot state publisher, transforms, move_base, etc), therefore there is currently no way to work with the ROS 2 navigation stack (nav2) in Foxy.

A re-work of free fleet is currently underway which has multiple levels of abstractions that would allow working with different navigation stacks. As of now, your best bet would be to write a fleet adapter specifically for robots ROS 2 navigation stacks.

How do I get the gazebo server or rviz launch in demos to get its model and frames from the Turtlebot3 simulation?

To spawn the model into the demo is not difficult, you would only need the model in either rmf_demo_assets alongside TinyRobot and DeliveryRobot, however to properly set up the robot frames, you would need to run a robot state publisher node, providing it with the URDF instead of the SDF model.

And without gazebo, in real-life set up with physical robots, is it possible to visualise the rmf traffic's proposed path in rviz for each robot? using robot_state_publisher node to publish robot's frames. Has it been done in the demos project?

The current existing implementation of free fleet is working with physical ROS 1 robots as well as a Full Control fleet adapter, with their traffic paths visualized, hence it has not been fully deprecated yet.

The goal is to avoid having to create an UI or fleet manager to visualise the rmf traffic capability on screen. Hopefully using the demos project to minimise the effort. Any other suggestions?

Sorry I am a bit confused by this goal. Do you mean to run RMF without any user interfaces or visualization, while allowing traffic negotiations to happen automatically?

txlei commented 3 years ago

Hello @aaronchongth

implementation of free fleet is working with physical ROS 1 robots as well as a Full Control fleet adapter, with their traffic paths visualized

actually this is what I want to implement as well. But I previously thought that their traffic paths cannot be visualized. Would like to understand how is this done. Visualised in the vendor's own fleet managers or in rviz? Is fleet_state topic subscribed by the visualiser, could you point to me the key files to look into?

aaronchongth commented 3 years ago

Hello @txlei!

Tthe traffic visualizations you see in rviz from the demos are the schedules and space-time occupancy of the robots, check out the visualizer repository. The schedules are obtained from the schedule database, which the fleet adapters update, when they receive a fleet state.

The fleet states are published by free fleet in ROS 2, and subscribed to by the Full Control fleet adapter. This is where the subscription is initialized, https://github.com/osrf/rmf_core/blob/master/rmf_fleet_adapter/src/full_control/main.cpp#L492-L523

This is a short description of what is happening with the physical ROS 1 robots, https://osrf.github.io/ros2multirobotbook/integration_free-fleet.html