webots_ros2 icon indicating copy to clipboard operation
webots_ros2 copied to clipboard

Publishing Twist results in discontinuous movement

Open mwlock opened this issue 2 years ago • 5 comments

Describe the Bug

I am publishing a twist message (just 1 message) and it results in the robot only moving for a fraction of a second.

Steps to Reproduce

  1. Launch the robot
ros2 launch webots_ros2_epuck robot_launch.py
  1. Send one message
ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear:{x: 2.0}}"

Expected behavior I expect the robot to move continuously in the specified direction.

System

  • Webots Version: R2022a
  • ROS Version: hubmle
  • Operating System: Ubuntu 22.04

mwlock avatar Sep 19 '22 20:09 mwlock

Any ideas on what might be causing this? :eyes:

mwlock avatar Sep 20 '22 20:09 mwlock

I found that the defined diffdrive_controller does not set a cmd_vel_timeout.

Seems that there is obviously some predefined default which is sending a zero speed command to the wheels.

mwlock avatar Sep 21 '22 13:09 mwlock

If you send the command only once then after the timeout kicks indeed a 0 command is automatically sent to the motors. By default this timeout is set to 0.5s, hence the behavior you observed. For the e-puck example to be consistent with the behavior we'd have using a non-ros controllers, I agree we should change it. Rather than setting an arbitrary timeout, it might be better to set cmd_vel_timeout : 0.0 so as to disable the behavior entirely. May I ask you to open a pull request with the proposed change?

ad-daniel avatar Sep 26 '22 10:09 ad-daniel

@omichel @ad-daniel Just bringing this discussion here.

I have attempted a zero-valued timeout as @ad-daniel suggested but it does not seem to address the issue. In fact, The robot moves and will almost immediately stop. Looking at the controller documentation, I don't see any obvious way to disable the timeout

mwlock avatar Sep 26 '22 13:09 mwlock

mmh you're right, I tested it locally and it seemed to work, perhaps I forgot to re-build between tries. I've checked in the ros2_control repo and I did't find any way to disable it either other than setting a large value as you mentioned. Perhaps it's best to ask there if there's a more proper solution

ad-daniel avatar Sep 26 '22 13:09 ad-daniel

I am closing this issue for now, as the change should be implemented in https://github.com/ros-controls/ros2_controllers/issues/440. If, in the end, something should be change in webots_ros2 as well, please feel free to reopen.

ygoumaz avatar Mar 30 '23 11:03 ygoumaz