klampt.control.motion_generation module
Classes:
|
A motion generator that limits the element-wise velocities for continuously generated position targets. |
|
A motion generator similar to the Reflexxes library, which provides acceleration- and velocity-bounded smooth trajectories for arbitrary targets. |
- class klampt.control.motion_generation.VelocityBoundedMotionGeneration(x0, vmax)[source]
Bases:
object
A motion generator that limits the element-wise velocities for continuously generated position targets. Note that the target is reached simultaneously on each dimension.
Usage:
from klampt.control.utils import TimedLooper x0 = robot.getPosition() generator = VelocityBoundedMotionGeneration(x0,vmax) dt = 1.0/rate #some control rate looper = TimedLooper(dt) while looper: #TODO: send commands, e.g., generator.setTarget(xtgt) (x,v) = generator.update(dt) robot.setPosition(x)
- Parameters:
x0 (list of floats) – the start position
vmax (list of floats, optional) – the velocity limits
Methods:
Returns the remaining time to finish the path, in s.
reset
(x0)Resets the motion generator to the start position x0.
update
(dt[, xtarget])Updates the motion generator.
setTarget
(xtarget[, append])Sets a new target.
setVelocity
(vtarget[, duration, append])Sets a velocity command to vtarget.
brake
()Stops as quickly as possible.
duration
()Returns the time remaining in the trajectory
target
()Returns the final position on the trajectory
predict
(t)Predicts the state that the system will be in at time t>=0 in the future, assuming no changes to the target.
Returns the future trajectory as a Trajectory.
- remainingTime()[source]
Returns the remaining time to finish the path, in s. Returns 0 if the path is done executing.
- update(dt, xtarget=None)[source]
Updates the motion generator. Optionally sets the new target.
- Returns:
(x,v) giving the new state
- Return type:
tuple
- setTarget(xtarget, append=False)[source]
Sets a new target. If append=True, appends the target to the motion queue.
- setVelocity(vtarget, duration=1, append=False)[source]
Sets a velocity command to vtarget. Moves along this speed for duration seconds and then stops.
- brake()[source]
Stops as quickly as possible. Since acceleration is unbounded, this just stops immediately.
- class klampt.control.motion_generation.AccelerationBoundedMotionGeneration(x0, xmin=None, xmax=None, vmax=None, amax=None)[source]
Bases:
object
A motion generator similar to the Reflexxes library, which provides acceleration- and velocity-bounded smooth trajectories for arbitrary targets.
Usage:
from klampt.control.utils import TimedLooper x0 = robot.getPosition() generator = AccelerationBoundedMotionGeneration(x0,vmax) dt = 1.0/rate #some control rate looper = TimedLooper(dt) while looper: #TODO: send commands, e.g., generator.setTarget(xtgt) (x,v) = generator.update(dt) robot.setPosition(x)
- Parameters:
x0 (list of floats) – the start position
xmin (list of floats, optional) – the lower position joint limits
xmax (list of floats, optional) – the upper position joint limits
vmax (list of floats, optional) – the velocity limits
amax (list of floats) – the acceleration limits. Non-optional (for now.)
Methods:
Returns the remaining time to finish the path, in s.
reset
(x0)Resets the motion generator to the start position x0.
update
(dt[, xtarget, vtarget])Updates the motion generator.
setTarget
(xtarget[, vtarget, append])Sets a new target position xtarget and optional velocity vtarget.
setVelocity
(vtarget[, duration, append])Sets a velocity command to vtarget.
brake
()Stops as quickly as possible under the acceleration bounds.
duration
()Returns the time remaining in the trajectory
target
()Returns the final position on the trajectory
predict
(t)Predicts the state that the system will be in at time t>=0 in the future, assuming no changes to the target.
Returns the future trajectory as a HermiteTrajectory.
- remainingTime()[source]
Returns the remaining time to finish the path, in s. Returns 0 if the path is done executing.
- update(dt, xtarget=None, vtarget=None)[source]
Updates the motion generator. Optionally sets the new target and velocity. If velocity is None, ends in 0 velocity.
- Returns:
(x,v) giving the new state
- Return type:
tuple
- setTarget(xtarget, vtarget=None, append=False)[source]
Sets a new target position xtarget and optional velocity vtarget.
If append=True, appends the target to the motion queue.
- setVelocity(vtarget, duration=1, append=False)[source]
Sets a velocity command to vtarget. Moves along this speed for duration seconds and then stops.