open-rmf / rmf_simulation

Support plugins for simulating RMF scenarios
Apache License 2.0
10 stars 18 forks source link

[Bug]: plugin/slotcar/joint_cmd] is not valid #119

Closed alperen-keser closed 6 months ago

alperen-keser commented 6 months ago

Before proceeding, is there an existing issue or discussion for this?

OS and version

Ubuntu 22.04

Open-RMF installation type

Binaries

Other Open-RMF installation methods

No response

Open-RMF version or commit hash

2.3.0

ROS distribution

Humble

ROS installation type

Source build

Other ROS installation methods

No response

Package or library, if applicable

rmf_robot_sim_gz_plugins

Description of the bug

I have been trying to create my own demo on Open-RMF. Followed this tutorial to do so. I managed to create the traffic lanes and can open the world I created on Gazebo-11, while displaying it on RViz also. But, right after I added a robot, I got an error regarding the slotcar plugin.

[gzclient-18] Topic [/data://world/world/model/deliveryRobot_0/plugin/slotcar/joint_cmd] is not valid.
[gzclient-18] [Err] [JointControlWidget.cc:393] Error advertising topic [/data://world/world/model/deliveryRobot_0/plugin/slotcar/joint_cmd]

How could I fix this error?

Steps to reproduce the bug

  1. Launched Gazebo and RViz with the .launch.xml file I created inside my pkg, with the given configs (map_name, map_package, plugin_path, nav_graph_file ...)
  2. Clicked the slotcar under PLUGINS on Gazebo's World display. image
  3. Error msg on the terminal shows up. image

Expected behavior

Being able to control the robot like a turtlebot3

Actual behavior

slotcar plugins does not work properly

Additional information or screenshots

No response

luca-della-vedova commented 6 months ago

Hello!

Can you clarify exactly how you would want to control the robot when you say "like a turtlebot3"? I'm assuming through utilities such as teleop / cmd_vel messages? Slotcar doesn't really support that as of now, and it can just be commanded through Open-RMF messages (specifically by receiving trajectory requests that it will follow). Also with Gazebo classic going EoL in 2025 and we will be focusing on gz instead. (I'm not actually sure whether it will be released in Ubuntu 24.04 but it seems it is not there).

For a "gz way" of doing the same, I would suggest looking at the VelocityControl system, which subscribes to cmd_vel messages and commands the robot accordingly. You should be able to add this system to your robot (as shown in the example world), run your teleop node and remap cmd_vel to the robot's cmd_vel topic.

If you are doing this together with Open-RMF I would suggest using the teleop action so Open-RMF will not try to control the robot, and it will steer other robots clear of its way instead.

alperen-keser commented 6 months ago

Thanks for your respond.

Can you clarify exactly how you would want to control the robot when you say "like a turtlebot3"? I'm assuming through utilities such as teleop / cmd_vel messages?

Exactly. But now that I realize I have to do those within Open-RMF, through teleop actions, without using Nav2; thanks for that. The error is still there though:

[gzclient-18] Topic [/data://world/world/model/deliveryRobot_0/plugin/slotcar/joint_cmd] is not valid.
[gzclient-18] [Err] [JointControlWidget.cc:393] Error advertising topic [/data://world/world/model/deliveryRobot_0/plugin/slotcar/joint_cmd]

I am not sure if anything malfunctions because of that error, but I realised I can't use navigation stack with DeliveryRobot s (MiR100s) on my simulation, like they do not navigate to the goal position I gave them via 2D Goal Pose .

Is this an expected behaviour with Open-RMF's default settings, meaning I should implement Nav2/navstack into my simulation or is it because of that slotcar error I mentioned above? Would appreciate the help.

luca-della-vedova commented 6 months ago

From your log I believe you are still trying to use Gazebo Classic which we don't really support anymore, at least for new features (which this would be).

Have you tried the way I recommended with the velocity control system and remapping cmd_vel?

alperen-keser commented 6 months ago

I've been trying to switch to gz-sim for a time, from Gazebo Classic, which I believe only requires rearranging the parameters in .launch.xml related with Gazebo and creating a .sdf instead of .world, but I could not.

I am desperately looking for examples using gz-sim instead of Gazebo Classic but I think there is none. Every single demo is done with the classic. May I suggest making a tutorial for Open-RMF using gz-sim. I think it would be very helpful for newcomers such as I.

luca-della-vedova commented 6 months ago

The world definitions tend to be fairly different between Gazebo and gz-sim. From the Open-RMF side, we support both quite transparently (at least until Humble and Iron and Ubuntu 22.04), you can check the rmf_demos repository, from the demo side all you need to do to switch between one and the other is append _classic or not to the launch command, i.e.:

source ~/rmf_ws/install/setup.bash
# Gazebo classic
ros2 launch rmf_demos_gz_classic hotel.launch.xml

# gz-sim
ros2 launch rmf_demos_gz hotel.launch.xml

I think the current Open-RMF map generation and demo pipeline can be a good input on what the differences are between the two simulators and how to approach the transition.

What kind of tutorial do you think would help? I think we should avoid adding documentation that is out of scope. For example, navstack integration is in the roadmap but it's not quite there yet so we haven't started looking at support from the simulation side.

alperen-keser commented 6 months ago

I think the current Open-RMF map generation and demo pipeline can be a good input on what the differences are between the two simulators and how to approach the transition.

Yes, it is good for seeing the differences but my problem is generating the world in Ignition/gz-sim and configuring my workspace with respect to that world.

I followed CMakeLists.txt of rmf_demos_maps for that but errors occur if I enable commands for generating Ignition version of my .world too, as in:

# Generate Ignition simulation world
  set(ign_output_dir ${CMAKE_CURRENT_BINARY_DIR}/maps/${output_world_name}_ign)
  set(ign_output_world_path ${ign_output_dir}/${output_world_name}.world)
  set(ign_output_model_dir ${ign_output_dir}/models)

  message(NOTICE "BUILDING WORLD FILE WITH COMMAND: ros2 run rmf_building_map_tools building_map_generator ignition ${map_path}")
  message(NOTICE "....Downloading Models and Building to ${ign_output_model_dir}")

  add_custom_command(
    OUTPUT ${ign_output_world_path}
    COMMAND ros2 run rmf_building_map_tools building_map_generator ignition ${map_path} ${ign_output_world_path} ${ign_output_model_dir}
    DEPENDS ${map_path}

What kind of tutorial do you think would help?

Every single tutorial I came across (regarding building a demo on simulation) are done with gz-classic. I haven't seen anyone using Ignition/gz-sim. It would be nice if there would be any.

These problems might be little out of scope from this issue topic - thanks for your help again.

luca-della-vedova commented 6 months ago

I followed CMakeLists.txt of rmf_demos_maps for that but errors occur if I enable commands for generating Ignition version of my .world too

For this I would recommend opening an issue in either rmf_demos or rmf_traffic_editor with more details on the issue (i.e. what's the exact error message and what you are exactly trying to do). Feel free to tag me!

I agree sadly on the fact that most tutorials out there target Gazebo Classic and not as many target gz. It's inevitable since Gazebo Classic has been around much longer, only time (and wider community effort!) can help in that domain.

I'll close this issue for now, it's not really a bug but more of a feature request. I haven't tried personally but it should be possible with the way I proposed (the VelocityControl system, topic remapping), feel free to reopen if you try it out and run into any issues!