RoverRobotics-archive / roverrobotics_ros2

Packages for running an OpenRover robot on ROS2
30 stars 11 forks source link

Vehicle velocity oscillates badly during teleop #4

Open pjreed opened 4 years ago

pjreed commented 4 years ago

I've got a 4wd rover, and I'm trying to set it up so that I can teleop it with a joystick using ROS 2. I'm using an Intel NUC that has Ubuntu 18.04 and ROS Dashing installed.

First, when I start the openrover_demo hardware.launch.py and teleop.launch.py, I can send use the keyboard to send it commands, but the velocity oscillates badly, so it seems like the vehicle is constantly jerking forward. The values in the /cmd_vel topic look reasonable, but the /motor_efforts bounce around quiet a bit, and I suspect it may be due to a badly PID controller somewhere in the driver.

Also, when I lower the velocity back near zero, it tends to suddenly rocket away at top speed. The nickp/prevent_near_zero_runaway branch in this repository seems to fix that, so it would be nice to have that merged in.

Next, I've also tried using the standard teleop_twist_joy_node to use a joystick to publish Twist messages to /cmd_vel. I've observed similar behaviors, except that the angular velocity is very slow even when the joystick is turned all the way, so that's probably just an issue of scaling the magnitude somewhere; another issue, though, is that the teleop_twist_joy_node stops publishing Twist messages if the joystick axes are within their dead zones, and a side effect is that it seems like the openrover driver stops changing the motor efforts when it stops receiving Twists. A behavior I very frequently observe is that if the motor efforts are almost reduced to neutral, but not quite, the rover will stop moving but its internal fans will keep running, and so I have to very lightly tap the joystick until it drops all the way to neutral and the fans turn off.

rotu commented 4 years ago

Thanks, @pjreed, for the in-depth writeup!

  1. Yes, the motor efforts are based on a PI controller which was tuned for the rover in 2 wheel drive mode. This differs significantly from 4 wheel drive mode, as you can see.
  2. Thanks and you're totally right! I've merged @padiln's fix!
  3. The thing to do here seems to be to tune the PI controller. Ihttps://github.com/RoverRobotics/openrover-ros2/blob/5f127a26e82c5dcc20f6346abc613d2568d68b0d/openrover_demo/config/hardware.yaml#L5-L13 I would drop motor_controller_gain_i to 0 and raise motor_control_gain_p until it starts to behave sanely, and maybe decrease the windup.
  4. Thanks for the report about joystick timeout. Yes, I should and will add a control timeout!