Package org.robwork.sdurw_trajectory
Class InterpolatorTrajectoryQuaternion_f
- java.lang.Object
-
- org.robwork.sdurw_trajectory.TrajectoryQuaternion_f
-
- org.robwork.sdurw_trajectory.InterpolatorTrajectoryQuaternion_f
-
public class InterpolatorTrajectoryQuaternion_f extends TrajectoryQuaternion_f
Sequence of interpolators and blends giving a trajectory
A trajectory is defined as a sequence of interpolators and blends.
Multiple interpolators can follow each other, whereas a Blend must be
preceded and followed by interpolators.
The length of a Trajectory is defined as the time it takes to go from
start to finish.
When performing random queries the trajectory needs to do a binary search
through all interpolators and blend, giving the random access an O(lg n)
complexity.
For accessing multiple consecutive values use TrajectoryInterpolator.
Example of usage:
Transform3D<> T1(Vector3D<>(0,0,0), EAA<>(0,0,0)); Transform3D<> T2(Vector3D<>(1,1,0), EAA<>(1,1,0)); Transform3D<> T3(Vector3D<>(2,0,0), EAA<>(2,2,0)); LinearInterpolator<Transform3D<> >::Ptr cartInt1 = ownedPtr(new LinearInterpolator<Transform3D<> >(T1, T2, 1)); LinearInterpolator<Transform3D<> >::Ptr cartInt2 = ownedPtr(new LinearInterpolator<Transform3D<> >(T2, T3, 1)); ParabolicBlend<Transform3D<> >::Ptr blend1 = ownedPtr(new ParabolicBlend<Transform3D<> >(cartInt1, cartInt2, 0.25)); InterpolatorTrajectory<Transform3D<> > trajectory; trajectory.add(cartInt1); trajectory.add(blend1, cartInt2); std::ofstream out("test.dat"); for (double t = 0; t<=trajectory.duration(); t += dt) { Transform3D<> x = trajectory.x(t); out<<t<<" "<<x.P()(0)<<" "<<x.P()(1)<<" "<<x.P()(2)<<std::endl; } out.close();
-
-
Constructor Summary
Constructors Constructor Description InterpolatorTrajectoryQuaternion_f()
Construct an empty trajectoryInterpolatorTrajectoryQuaternion_f(double startTime)
Construct an empty trajectoryInterpolatorTrajectoryQuaternion_f(long cPtr, boolean cMemoryOwn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(InterpolatorTrajectoryQuaternion_f trajectory)
Append trajectory to the end
When adding a Trajectory all interpolators and blends of
trajectory is added in sequence.
Ownership of the interpolator and blends are shared using
std::shared_ptr
void
add(SWIGTYPE_p_rw__core__PtrT_rw__trajectory__BlendT_rw__math__QuaternionT_float_t_t_t blend, SWIGTYPE_p_rw__core__PtrT_rw__trajectory__InterpolatorT_rw__math__QuaternionT_float_t_t_t interpolator)
Adds a blend and an interpolator to the trajectory.
The Blend added is used to blend between what was previously the last
Interpolator of the trajectory onto interpolator, which become the
new last interpolator of the trajectory.void
add(SWIGTYPE_p_rw__core__PtrT_rw__trajectory__InterpolatorT_rw__math__QuaternionT_float_t_t_t interpolator)
Adds an interpolator to the end of the trajectory.
When adding the interpolator the Trajectory takes ownership.
Quaternion_f
ddx(double t)
Acceleration of trajectory at time t
Returns the acceleration of the trajectory at time t \in[startTime(), endTime()].
void
delete()
double
duration()
Total duration of the trajectory.
The duration of the Trajectory corresponds to the time it takes to
run through it.
If the trajectory is empty, then -1 is returned.Quaternion_f
dx(double t)
Velocity of trajectory at time t
Returns the velocity of the trajectory at time t \in[startTime(), endTime()].
static long
getCPtr(InterpolatorTrajectoryQuaternion_f obj)
SWIGTYPE_p_rw__trajectory__TrajectoryIteratorT_rw__math__QuaternionT_float_t_t__Ptr
getIterator()
Returns a bi-directional interator for running through the trajectory.
For some trajectory types it may be significantly more efficient to run through
using an iterator, rather than using random access.
Pointer to the iterator.SWIGTYPE_p_rw__trajectory__TrajectoryIteratorT_rw__math__QuaternionT_float_t_t__Ptr
getIterator(double dt)
Returns a bi-directional interator for running through the trajectory.
For some trajectory types it may be significantly more efficient to run through
using an iterator, rather than using random access.
SegmentQuaternion_f
getSegment(long index)
long
getSegmentsCount()
Returns the number of segments
A segment contains a description interpolator and the blend used to blend from the
previous interpolatordouble
startTime()
Returns the startTime of the trajectory
Quaternion_f
x(double t)
Position of trajectory at time t
Returns the position of the trajectory at time t \in[startTime(), endTime()].
-
Methods inherited from class org.robwork.sdurw_trajectory.TrajectoryQuaternion_f
endTime, getCPtr, getPath, getPath
-
-
-
-
Constructor Detail
-
InterpolatorTrajectoryQuaternion_f
public InterpolatorTrajectoryQuaternion_f(long cPtr, boolean cMemoryOwn)
-
InterpolatorTrajectoryQuaternion_f
public InterpolatorTrajectoryQuaternion_f(double startTime)
Construct an empty trajectory
-
InterpolatorTrajectoryQuaternion_f
public InterpolatorTrajectoryQuaternion_f()
Construct an empty trajectory
-
-
Method Detail
-
getCPtr
public static long getCPtr(InterpolatorTrajectoryQuaternion_f obj)
-
delete
public void delete()
- Overrides:
delete
in classTrajectoryQuaternion_f
-
x
public Quaternion_f x(double t)
Description copied from class:TrajectoryQuaternion_f
Position of trajectory at time t
Returns the position of the trajectory at time t \in[startTime(), endTime()].
- Overrides:
x
in classTrajectoryQuaternion_f
- Parameters:
t
- [in] time between startTime() and endTime()- Returns:
- Position
-
dx
public Quaternion_f dx(double t)
Description copied from class:TrajectoryQuaternion_f
Velocity of trajectory at time t
Returns the velocity of the trajectory at time t \in[startTime(), endTime()].
- Overrides:
dx
in classTrajectoryQuaternion_f
- Parameters:
t
- [in] time between startTime() and endTime()- Returns:
- Velocity
-
ddx
public Quaternion_f ddx(double t)
Description copied from class:TrajectoryQuaternion_f
Acceleration of trajectory at time t
Returns the acceleration of the trajectory at time t \in[startTime(), endTime()].
- Overrides:
ddx
in classTrajectoryQuaternion_f
- Parameters:
t
- [in] time between startTime() and endTime()- Returns:
- Acceleration
-
duration
public double duration()
Description copied from class:TrajectoryQuaternion_f
Total duration of the trajectory.
The duration of the Trajectory corresponds to the time it takes to
run through it.
If the trajectory is empty, then -1 is returned.- Overrides:
duration
in classTrajectoryQuaternion_f
-
startTime
public double startTime()
Description copied from class:TrajectoryQuaternion_f
Returns the startTime of the trajectory
- Overrides:
startTime
in classTrajectoryQuaternion_f
- Returns:
- Start time
-
getIterator
public SWIGTYPE_p_rw__trajectory__TrajectoryIteratorT_rw__math__QuaternionT_float_t_t__Ptr getIterator(double dt)
Description copied from class:TrajectoryQuaternion_f
Returns a bi-directional interator for running through the trajectory.
For some trajectory types it may be significantly more efficient to run through
using an iterator, rather than using random access.
- Overrides:
getIterator
in classTrajectoryQuaternion_f
- Parameters:
dt
- [in] The default time step used when using the ++ or -- operators in the
iterator
Pointer to the iterator. The pointer has ownership.
-
getIterator
public SWIGTYPE_p_rw__trajectory__TrajectoryIteratorT_rw__math__QuaternionT_float_t_t__Ptr getIterator()
Description copied from class:TrajectoryQuaternion_f
Returns a bi-directional interator for running through the trajectory.
For some trajectory types it may be significantly more efficient to run through
using an iterator, rather than using random access.
Pointer to the iterator. The pointer has ownership.- Overrides:
getIterator
in classTrajectoryQuaternion_f
-
add
public void add(SWIGTYPE_p_rw__core__PtrT_rw__trajectory__InterpolatorT_rw__math__QuaternionT_float_t_t_t interpolator)
Adds an interpolator to the end of the trajectory.
When adding the interpolator the Trajectory takes ownership.
- Parameters:
interpolator
- [in] The interpolator to add
-
add
public void add(SWIGTYPE_p_rw__core__PtrT_rw__trajectory__BlendT_rw__math__QuaternionT_float_t_t_t blend, SWIGTYPE_p_rw__core__PtrT_rw__trajectory__InterpolatorT_rw__math__QuaternionT_float_t_t_t interpolator)
Adds a blend and an interpolator to the trajectory.
The Blend added is used to blend between what was previously the last
Interpolator of the trajectory onto interpolator, which become the
new last interpolator of the trajectory.- Parameters:
blend
- [in] the blend to addinterpolator
- [in] the interpolator to add
-
add
public void add(InterpolatorTrajectoryQuaternion_f trajectory)
Append trajectory to the end
When adding a Trajectory all interpolators and blends of
trajectory is added in sequence.
Ownership of the interpolator and blends are shared using
std::shared_ptr
- Parameters:
trajectory
- [in] Trajectory to append
-
getSegmentsCount
public long getSegmentsCount()
Returns the number of segments
A segment contains a description interpolator and the blend used to blend from the
previous interpolator
-
getSegment
public SegmentQuaternion_f getSegment(long index)
-
-