Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add minjerk interpolation method #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

k-okada
Copy link
Member

@k-okada k-okada commented Jul 16, 2016

currently baxter's joint trajectory action uses Bezier interpolation function and that would jerky motion for some inputs, for example, if we inputs https://gist.github.com/k-okada/b17850cde70f426aa84e0b8be98ed893 files, we'll get
screenshot from 2016-07-16 16 08 39

The problem is second peak, where time=5, the input is

angle  time_from_start
1.0      2.0
0.0      3.0
1.0      4.0
1.1      4.1
0.0      5.0

when when the program generate interpolated trajectory from (angle, time) = (1.0, 4.0) to (1.1, 4.1)` it will generate too peaky outputs, We at JSK, have been using "Minimum Jerk" trajectory generation a.k.a "Hoff Arbib" for many years, which is basically to generate trajectory which minimize derivative of acceleration and ensure the continuousness of position, velocity and acceleration. See http://www.shadmehrlab.org/book/minimumjerk.pdf for background.

Wen we use min-jerk, we can get figure below for same input
screenshot from 2016-07-16 16 05 44

I know this is huge change and need more intensive testing, but hope this PR would be good starting point for discussions

Cc: @pazeshun

@k-okada
Copy link
Member Author

k-okada commented Jul 16, 2016

Another concern about output of Bezier function is it overshoot, for example , the example code outputs Trapezoid trajectory, but upper part is straight in minjerk and overshoot in the bezier function. For example
if we consider 1 joint arm and start with angle 0 and you can reach to some position at the angle 90, we'll send command 0, and 90, after we control gripper, then we'll send backward motion from 90 to 0, in that case, current interpolation function outputs angle > 90, if the target is object on the table of button on the wall, it means the robot gripper is trying to penetrate to the obstacles, and it is not what we expected.

@IanTheEngineer
Copy link
Contributor

@k-okada Wow! Really interesting work that you've done and contributed. I want to find a way to incorporate these changes, but agree they will require substantial testing. Have you run this modified action server on your Baxter? As always, your contributions are incredibly appreciated.

@k-okada k-okada force-pushed the minjerk branch 2 times, most recently from 39a9cf0 to e83d119 Compare July 19, 2016 09:52
@k-okada
Copy link
Member Author

k-okada commented Jul 19, 2016

Yes, I have just tested on our Baxter robot and here is the results; (I have also used #73 as well)
I have added -i switch
https://github.com/RethinkRobotics/baxter_interface/pull/72/files#diff-d1acf285ad84d35b2efa98b2c88a19bbR109
, so new interpolation method is not activated unless you run rosrun baxter_interface joint_trajectory_action_server.py -i minjerk

Bezier function;
screenshot from 2016-07-19 18 55 41

MinJerk function
screenshot from 2016-07-19 18 13 37

I have noticed that current Bezier interpolation moves the arm if we send same goal positions for several times, see the first three goal message.

JTA message for this example;
https://gist.github.com/k-okada/f04885bc9403897621dd39e95b01228f

roseus program to genrate JTA message

(load "package://baxtereus/baxter-interface.l")
(baxter-init)

(defun straight-motion2 ()
  (let ((pos0 #f(900 -500 350))
        (pos1 #f(900    0 350))
        (i 0) avs)
    (while (<= i pi)
      (print (list (sin i) (make-coords :pos (midpoint (sin i) pos0 pos1))))
      (send *baxter* :rarm :inverse-kinematics (make-coords :pos (midpoint (sin\
 i) pos0 pos1)))
      (push (send *baxter* :angle-vector) avs)
      (incf i 0.1))
    (setq avs (nreverse avs))
    (dotimes (i 3)
      (send *ri* :angle-vector (car avs) 3000)
      (send *ri* :wait-interpolation)
      (unix:sleep 1))
    (send *ri* :angle-vector-sequence avs 300)
    (send *ri* :wait-interpolation)

    (send *ri* :angle-vector (send *baxter* :rarm :inverse-kinematics (make-coords :pos pos0)) 5000)
    (send *ri* :wait-interpolation)
    (send *ri* :angle-vector (send *baxter* :rarm :inverse-kinematics (make-coords :pos pos1)) 5000)
    (send *ri* :wait-interpolation)
    (send *ri* :angle-vector (send *baxter* :rarm :inverse-kinematics (make-coords :pos pos0)) 5000)
    (send *ri* :wait-interpolation)
    (unix:sleep 3)

    (send *ri* :angle-vector-sequence
          (list (send *baxter* :rarm :inverse-kinematics (make-coords :pos pos0))
                (send *baxter* :rarm :inverse-kinematics (make-coords :pos pos1))
                (send *baxter* :rarm :inverse-kinematics (make-coords :pos pos0)))
          (list 5000 5000 5000))
    (send *ri* :wait-interpolation)
    ))

@k-okada
Copy link
Member Author

k-okada commented Jul 19, 2016

another examples -> jsk-ros-pkg/jsk_robot#635

else:
b_matrix = self._compute_bezier_coeff(joint_names,
trajectory_points,
dimensions_dict)
except Exception as ex:
rospy.logerr(("{0}: Failed to compute a Bezier trajectory for {1}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either remove the Bezier adjective or substitute the current interpolation method in there.

@k-okada k-okada force-pushed the minjerk branch 2 times, most recently from f05f433 to 6abbebd Compare July 22, 2016 16:06
@k-okada
Copy link
Member Author

k-okada commented Jul 22, 2016

thanks for comment, fixed and updated the PR.

@IanTheEngineer
Copy link
Contributor

@k-okada, your work here is fantastic. Based on your plots and description of the issues experienced by using the bezier trajectories, minjerk might be the better default interpolation in the future. For now, it's fine to leave bezier default. Can you target this PR at the development branch as well?

@k-okada
Copy link
Member Author

k-okada commented Jul 23, 2016

ok, rebased against development branch. Just for note, comparison between
bezier and minjerk is not fair, I have been using minjerk for many years,
so I know how to configure that (for example
https://github.com/RethinkRobotics/baxter_interface/pull/72/files#diff-fc2fc667f0344438888d1adafa3170e6R125),
and I just use bezier for default settings, so it may have chance to work
well if you propery configure control point of the bezier curve, it may
work well. But I myself has no knowledge on that.

◉ Kei Okada

On Sat, Jul 23, 2016 at 1:20 AM, Ian McMahon [email protected]
wrote:

@k-okada https://github.com/k-okada, your work here is fantastic. Based
on your plots and description of the issues experienced by using the
bezier trajectories, minjerk might be the better default interpolation in
the future. For now, it's fine to leave bezier default. Can you target
this PR at the development branch as well?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#72 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAeG3GOtGvvethurmwaYC4tJ--bFtfBRks5qYO2wgaJpZM4JN8pP
.

@wkentaro
Copy link
Member

wkentaro commented Sep 23, 2016

What is the status of this PR?

IanTheEngineer added a commit to RethinkRobotics/intera_sdk that referenced this pull request Sep 28, 2016
From RethinkRobotics/baxter_interface#72
@k-okada

currently baxter's joint trajectory action uses Bezier interpolation function and that would jerky motion f
![screenshot from 2016-07-16 16 08 39](https://cloud.githubusercontent.com/assets/493276/16893337/a2ad667e-

The problem is second peak, where time=5, the input is
```
angle  time_from_start
1.0      2.0
0.0      3.0
1.0      4.0
1.1      4.1
0.0      5.0
```
when when the program generate interpolated trajectory from `(angle, time) = (1.0, 4.0)` to (1.1, 4.1)` it

Wen we use min-jerk, we can get figure below for same input
![screenshot from 2016-07-16 16 05 44](https://cloud.githubusercontent.com/assets/493276/16893336/a02ae520-

I know this is huge change and need more intensive testing, but  hope this PR would be good starting point

Cc: @pazeshun
@pazeshun
Copy link

pazeshun commented Dec 6, 2016

@k-okada Please target development branch

@k-okada
Copy link
Member Author

k-okada commented Dec 6, 2016

I think this is already targeting development branch

screenshot from 2016-12-06 16 29 34

@pazeshun
Copy link

pazeshun commented Dec 6, 2016

I mean base branch of this PR is master

@k-okada
Copy link
Member Author

k-okada commented Dec 6, 2016

I see. See #78,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants