ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to use slotcar plugin for my own robot?

asked 2021-12-02 20:53:29 -0600

Kevin1719 gravatar image

Hi, I have read about the RMF in ROS2, but I want to use slotcar plugin for my own robot in ROS1 to integrate it into the RMF. Beside adding this plugin to my urdf robot file and change the parameters, should I do anything else for this to work?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-12-05 08:19:12 -0600

osilva gravatar image

Hi @Kevin1719

To use the plugin you will need to compile it as a library then added to your model urdf/sdf: Refer to this tutorial that shows you how to.

To add it to library path:

export GAZEBO_PLUGIN_PATH=$HOME/gazebo_plugin_tutorial/build:$GAZEBO_PLUGIN_PATH

The source code for the slotcar plugin can be found in this repo

  : public System,
  public ISystemConfigure,
  public ISystemPreUpdate

As per the tutorial in your link to use:

<plugin name="slotcar" filename="">

To use with ROS, then refer to this tutorial how to add Gazebo Plugins.

edit flag offensive delete link more


Thanks @osilva for a comprehensive answer, I will follow your instructions and reply the outcome as soon as possible. By the way, I'm wondering how slotcar simulates robot models in Gazebo, when I launch the clinic demo from this, I can see it publishes messages to /robot_state topic after running rqt_graph command, but Gazebo doesn't subscribe to that topic, and the robots still move normally in Gazebo simulation. Can you explain the mechanism under the hood, please?

Kevin1719 gravatar image Kevin1719  ( 2021-12-05 10:39:59 -0600 )edit

I think the best way is to study the source code for the plugin link

void SlotcarPlugin::send_control_signals(EntityComponentManager& ecm,
  const std::pair<double, double>& velocities,
  const std::unordered_set<Entity> payloads,
  const double dt)
  auto lin_vel_cmd =
  auto ang_vel_cmd =

  double v_robot = lin_vel_cmd->Data()[0];
  double w_robot = ang_vel_cmd->Data()[2];
  std::array<double, 2> target_vels;
  target_vels = dataPtr->calculate_model_control_signals({v_robot, w_robot},
      velocities, dt);

For example the function above sends control signals of linear and angular velocities.

osilva gravatar image osilva  ( 2021-12-05 11:13:44 -0600 )edit

The plugin is another gazebo objects that interacts with Gazebo's physics engine, so if the robot moves for example, the engine knows that the robot is in motion, those physical properties can be read by the plugin in simulation. Hope that makes a little more clear.

osilva gravatar image osilva  ( 2021-12-05 11:16:03 -0600 )edit

@osilva Yes, that makes sense, I will dig into the code to see if there is anything related. Thanks a lot.

Kevin1719 gravatar image Kevin1719  ( 2021-12-06 19:18:00 -0600 )edit

Question Tools



Asked: 2021-12-02 20:53:29 -0600

Seen: 236 times

Last updated: Dec 05 '21