ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange

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

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 close merge delete

Is slerp sufficient for my needs?

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

( 2016-12-05 13:16:41 -0500 )edit

Agreed, I updated my question. Thank you!

( 2016-12-05 14:17:44 -0500 )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.

( 2016-12-06 14:00:20 -0500 )edit

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

( 2017-07-28 09:25:20 -0500 )edit

Sort by ยป oldest newest most voted

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.

more

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 :)

more

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.

( 2016-12-06 08:46:49 -0500 )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."

( 2016-12-06 08:55:46 -0500 )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.

( 2016-12-06 08:57:43 -0500 )edit

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!

more