nobleo / tracking_pid

PID controller following a moving carrot
Apache License 2.0
238 stars 50 forks source link

Using flip_for_axis parameter to follow a path by driving backwards #18

Open vanem opened 2 years ago

vanem commented 2 years ago

Is it possible to use this parameter:

flip_for_axis (float, default: None) When enabled, the desired following distance between robot and control point (published on /trajectory) is inverted when the control point moves backwards along the given axis. Depending on the robot, this makes the robot drive backwards when moving in the indicated axis.

To follow a path wit a non-holonomic (dual differential drive robot) by driving backwards? If I do:

    <node name="interpolator" pkg="tracking_pid" type="path_interpolator">
        <param name="target_x_vel" value="0.7"/>
        <param name="target_x_acc" value="100.0"/>
        <param name="flip_for_axis" value="x"/>
    </node>

and then: roslaunch tracking_pid test_tracking_pid.test rviz:=true

I get no movement and:

[ INFO] - /fake_odometry: [1655821967.503094200] Started mobile robot simulator update loop, listening on cmd_vel topic
[ INFO] - /controller: [1655821967.717553000] Transform between map and base_link found
[ERROR] - /interpolator: [1655821968.183834] SimpleActionServer.internal_goal_callback - exception

Does the path need to be specified differently? Could you give me an example? Thank you!

vanem commented 2 years ago

I made a mistake in the first post: "flip_for_axis" parameter values must be upper case. But even with this correction the results of the simulation are not ok. In path_interpolator.py:494, unless I'm missing something the effect of setting the parameter for any axis for a tracked section (between 2 poses) is to switch the tracked distance l to its negative value if traveling in the the negative direction of that axis (exactly as in the readme). But the effect is not what is described, the robot does not track the path backwards. I would appreciate some feedback, this would be a useful feature (if working). Below is the effect. It can be seen that the only "diagonal" is track backwards (but the orientation is very wobbly) msrdc_tKzedSYTSk

Timple commented 2 years ago

Regarding your first question, it should be an uppercase direction. While the documentation states it's a float. We should fix that.

From the screenshot it's not quite clear what is going wrong. Would it be possible to publish a minimal reproducing example?

I think with some minimal rewrites this file: https://github.com/nobleo/tracking_pid/blob/master/test/tracking_pid/test_tracking_pid.test should be a good starting point.

vanem commented 2 years ago

For an example: use the test_tracking_pid.test, the only change is adding: <param name="flip_for_axis" `value="X"/> and observe the results. This is what I described in the questions, and the trajectory is seen in the screenshot. You can see that in the first segment of the zig-zag the robot still drives with the front, same on the last segment, while on the diagonal is drives with the back (good!) but the orientation of the robot oscillates wildly (bad!) What I would like to be able to do, is follow a trajectory, but driving with the back of the robot (my use case: un-dock a robot). Is that possible?

rokusottervanger commented 1 year ago

The angular feedback loop only worked under the assumption that the path was being tracked forward. Since #21 , you can now track a path backwards by setting the parameter l to a negative value. It introduces a fix for the angular error calculation when the carrot distance l is negative. Curious to see if this works for you.