Closed fjp closed 3 years ago
The problem might be that the encoder values are not zero after launching the bringup package. And also the read velocity in the hardware interface is something quite high at the start:
[ INFO] [1616228464.459879850]: Initializing DiffBot Hardware Interface ...
[ INFO] [1616228464.460056253]: Number of joints: 2
[ INFO] [1616228464.460419242]: pid namespace: pid/left_motor
[ INFO] [1616228464.460576090]: Initialize PID
[ INFO] [1616228464.460676420]: Initializing dynamic reconfigure in namespace /diffbot/pid/left_motor
[ INFO] [1616228464.557533459]: Update PID Gains: F=0.8, P=0.35, I=0.5, D=0.01, out_min=-6.15385, out_max=6.15385
[ INFO] [1616228464.586639267]: Initialized dynamic reconfigure
[ INFO] [1616228464.586828372]: Initialized PID: F=0.8, P=0.35, I=0.5, D=0.01, out_min=-6.15385, out_max=6.15385
[ INFO] [1616228464.586925684]: Update PID output limits: lower=6.15385, upper=-6.15385
[ INFO] [1616228464.587086976]: pid namespace: pid/right_motor
[ INFO] [1616228464.587175251]: Initialize PID
[ INFO] [1616228464.587251823]: Initializing dynamic reconfigure in namespace /diffbot/pid/right_motor
[ INFO] [1616228464.680847326]: Update PID Gains: F=0.8, P=0.35, I=0.5, D=0.01, out_min=-6.15385, out_max=6.15385
[ INFO] [1616228464.706535566]: Initialized dynamic reconfigure
[ INFO] [1616228464.706727079]: Initialized PID: F=0.8, P=0.35, I=0.5, D=0.01, out_min=-6.15385, out_max=6.15385
[ INFO] [1616228464.706817392]: Update PID output limits: lower=6.15385, upper=-6.15385
[ INFO] [1616228464.707294470]: ... Done Initializing DiffBot Hardware Interface
[ INFO] [1616228464.934849034]:
Read ticks angle dangle velocity
j0: -707135280-8.19753e+06-8.19753e+06-1.32926e+12
j1: 65535 759.721 759.721 1.23191e+08
[ INFO] [1616228464.935248097]:
Write velocity p_error i_error d_error pid out percent
j0: 0 1.32926e+128.19753e+062.15544e+172.1559e+153.50334e+16
j1: 0 -1.23191e+08-759.721 -1.99759e+13-1.99802e+11-3.24678e+12
[ INFO] [1616228465.034950868]:
Read ticks angle dangle velocity
j0: -707135280-8.19753e+060 0
j1: 65535 759.721 0 0
[ INFO] [1616228465.035816139]:
Write velocity p_error i_error d_error pid out percent
j0: 0 0 0 0 0 0
j1: 0 0 0 0 0 0
[ INFO] [1616228465.134998480]:
Read ticks angle dangle velocity
j0: -707135280-8.19753e+060 0
j1: 65535 759.721 0 0
[ INFO] [1616228465.135785402]:
Write velocity p_error i_error d_error pid out percent
j0: 0 0 0 0 0 0
j1: 0 0 0 0 0 0
At the start the set_velocity from the controller should be zero. But as you can see in the log at the first read cycle:
[ INFO] [1616228464.934849034]:
Read ticks angle dangle velocity
j0: -707135280-8.19753e+06-8.19753e+06-1.32926e+12
j1: 65535 759.721 759.721 1.23191e+08
[ INFO] [1616228464.935248097]:
Write velocity p_error i_error d_error pid out percent
j0: 0 1.32926e+128.19753e+062.15544e+172.1559e+153.50334e+16
j1: 0 -1.23191e+08-759.721 -1.99759e+13-1.99802e+11-3.24678e+12
this velocity difference (set_vel = 0, measured_vel = "something high") leads to a pid out
that is much too high.
I think I found the problem and work on it in the hw_init branch. After it is fixed completely I will do a PR to the main noetic-devel branch.
There are/were mainly three errors causing the problem:
For the last unsolved error I think the best way to solve it, is to let the hw intf control loop wait for the encoder messages being published. Another way in solving this, could be to send the /reset
message from the hardware interface just before the first loop cycle starts. This will lead to zero ticks and therefore no jump.
Sounds like you're fixing it, Franz! I'll have to check through my Teensy code when you finish, as mine is controlling the motors, too. (No Grove device.)
This is a bug, I encounter the same problem on my robot. I suspect missing zero initializations in the
diffbot_hw_interface.cpp
but couldn't find the exact problem so far and didn't investiage further yet. I do set the joint states and commands to zero here in the code at the beginning but it doesn't seem to help.Another source of this problem might be the motor driver code.
What I do to "solve" this, is to send an empty message on the
/diffbot/reset
topic to the encoders that might not be zero while the wheels spin. And then in my case I can stop the wheels by just blocking the wheels of the robot during this resetting, or I also make use of the motor driver reset button.Originally posted by @fjp in https://github.com/fjp/diffbot/issues/24#issuecomment-794489216