Robotics StackExchange | Archived questions

[Project template] keyboard control not working

I would like to control the diff drive from the templates' bringup example, by keyboard.

The recipe I have followed:

https://gazebosim.org/docs/garden/moving_robot#moving-the-robot-using-the-keyboard

I can see the keystroke data in a terminal using gz topic -e -t /keyboard/keypress, when I press keys from within the active simulation, with KeyPublisher plugin activated. I have placed the TriggeredPublisher plugins under the world tag in diff_drive.sdf. For example

<!-- Moving Forward-->
<plugin filename="gz-sim-triggered-publisher-system"
  name="gz::sim::systems::TriggeredPublisher">
  <input type="gz.msgs.Int32" topic="/keyboard/keypress">
    <match field="data">16777235</match>
  </input>
  <output type="gz.msgs.Twist" topic="/cmd_vel">
    linear: {x: 0.5}, angular: {z: 0.0}
  </output>
</plugin>

I'm pretty sure I got the key mapping right in the plugins. I also make sure to colcon build and . install/setup.sh after any changes in the .sdf file.

Anyhow the robot does not move at all in the simulation. Am I using the wrong topics, since they come from a unrelated tutorial?

EDIT: I can see the cmd_vel messages from the keystrokes using gz topic -e -t /cmd_vel in a fresh shell. Example:

linear {
  x: 0.5
}
angular {
}

Still, the robot does not move.

Asked by Simple Simpson on 2023-07-05 12:40:01 UTC

Comments

Answers

The correct topic for the template diff drive is

/model/diff_drive/cmd_vel

as it stands in the comments of the diff_drive.sdf file.

Asked by Simple Simpson on 2023-07-05 14:35:35 UTC

Comments