Ask Your Question
0

Quaternion.Slerp vs Quaternion.RotateTowards [Unity3D API vs ROS API]

asked 2016-12-05 11:26:18 -0600

alecive gravatar image

updated 2016-12-05 14:17:30 -0600

Hello everybody,

I am trying to compute a smooth trajectory between a 6D starting pose and a 6D desired pose. Everything is fine for what concerns the 3D positional component, but I am having issues with the orientation (and the quaternion that describes it).

Trying to look for help online, most of the references pointed to Unity 3D methods and specifically to Quaternion.RotateTowards, which has been deemed to be better than Quaternion.Slerp. Unfortunately, being Unity closed source, I could not find any source code to see what they actually do and why the former is better than the latter.

Unfortunately, the ROS API only provides a comparable method for quaternion.slerp, available here. So, my questions at this point are multiple:

  • Does anybody know what "rotateTowards" does and how it is better than the Spherical Linear Interpolation method?
  • Would it be possible to implement a similar method (if proven to be more advantageous than "slerp") ?
  • Is slerp sufficient for my needs? EDIT: my goal is to simply create a trajectory from one pose to another, i.e. to interpolate both 3D position and 3D orientation to gradually move from the starting pose to the final desired one. For what concerns the quaternion describing the orientation, it is not clear to me if "slerp" would be the method I need for my purposes. In particular, for the position I can easily implement a straight trajectory from one point to another by using the motion equation of a point over time (with a fixed velocity), but I don't understand how can I do it w.r.t. the orientation. Can I use some sort of angular velocity to feed "slerp" with?
edit retag flag offensive close merge delete

Comments

Is slerp sufficient for my needs?

I think this particular question will be hard to answer, as only you know what your needs are.

gvdhoorn gravatar imagegvdhoorn ( 2016-12-05 13:16:41 -0600 )edit

Agreed, I updated my question. Thank you!

alecive gravatar imagealecive ( 2016-12-05 14:17:44 -0600 )edit

I've never done it, but I seem to remember hearing people call this "tweening". 3D video games use it to move the camera point of view around smoothly while following a person, like in 3rd person point of view games for example. Maybe googleing tweening might lead to some example code.

Airuno2L gravatar imageAiruno2L ( 2016-12-06 14:00:20 -0600 )edit

Did you ever determine how these two methods are different, or did you get slerp to work for your application?

Stephen_Z gravatar imageStephen_Z ( 2017-07-28 09:25:20 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2016-12-08 06:20:57 -0600

sirop gravatar image

Try to see the difference from OpenRave source: for SLERP: http://openrave.org/docs/latest_stabl... for Rotate: http://openrave.org/docs/latest_stabl... .

The smoothness is definetely a function of your step both for the SLERP and ROTATE.

Hard to tell for me which would be faster if you use or do not use SIMD (SSE) instructions.

edit flag offensive delete link more
0

answered 2016-12-06 09:55:55 -0600

mpjansen gravatar image

Without getting into the mathematics of rotations here, you could borrow some math from control based approaches such as: https://www.math.ucsd.edu/~mleok/pdf/... Good luck!

edit flag offensive delete link more
0

answered 2016-12-06 05:10:47 -0600

Not sure which of the two methods you mention is better, but the rviz_animated_view_controller does something similar (smoothly moves a camera from one view to the other). With the source available on github, you could draw some inspiriation from that. There also is smooth camera motion capability in gazebo, but you'll have to find it in the source yourself :)

edit flag offensive delete link more

Comments

Thanks for the suggestion! Unfortunately, Gazebo's Camera class allows only for rotations along yaw, pitch and roll separately, whereas the rviz* is not documentated and is difficult to understand its internal functioning. I opened an issue on the GH repo, although the last commit was from 2014.

alecive gravatar imagealecive ( 2016-12-06 08:46:49 -0600 )edit

I dug into rviz_animated_view_controller and I believe that the transitions are done within this function. Documentation says: "Applies a body-fixed-axes sequence of rotations; only accurate for small angles."

alecive gravatar imagealecive ( 2016-12-06 08:55:46 -0600 )edit

So from my understanding what rviz_animate_view_controller is doing is exactly what gazebo does (i.e. independent yaw-pitch-roll rotations), which may be okay if you have a continuous control that gives you small increments, but is not general enough for my purposes.

alecive gravatar imagealecive ( 2016-12-06 08:57:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-12-05 11:26:18 -0600

Seen: 1,757 times

Last updated: Dec 06 '16