org.robokind.api.motion.utils
Class PositionTargetFrameSource

java.lang.Object
  extended by org.robokind.api.motion.utils.PositionTargetFrameSource
All Implemented Interfaces:
FrameSource<Robot.RobotPositionMap>, RobotFrameSource

public class PositionTargetFrameSource
extends Object
implements RobotFrameSource

A FrameSource which moves the Joints of a Robot towards a set of target positions with a limited velocity.

Author:
Matthew Stevenson

Constructor Summary
PositionTargetFrameSource(double velocity, Robot.RobotPositionMap targetPositions)
          Creates a new MotionTargetFrameSource
 
Method Summary
 void clearPositions()
          Clears all target positions and disables this MotionTargetFrameSource.
protected  void disableAtGoal()
           
 boolean getEnabled()
          Returns true if enabled
 MotionFrame getMovements(long time, long interval)
          Creates a MotionFrame starting at the Robot's goal positions, and moving towards the target positions as much as the velocity will allow in the given time interval.
 Robot getRobot()
           
 boolean getStopOnGoalFlag()
          Returns the StopOnGoalFlag.
 double getVelocity()
          Returns the velocity, measured as (change in NormalizedDouble)/millisecond
protected  boolean isAtGoal()
           
 void putPosition(Robot.JointId id, org.robokind.api.common.position.NormalizedDouble position)
          Set the target position for the given JointId and enables this MotionTargetFrameSource.
 void putPositions(Robot.RobotPositionMap targetPositions)
          Puts the given positions in the target position map and enables this MotionTargetFrameSource.
 void setEnabled(boolean enabled)
          If false, this MotionTargetFrameSource will return null when queried for Movements.
 void setRobot(Robot robot)
          Sets the Robot to
 void setStopOnGoal(boolean val)
          When StopOnGoal is set true, the MotionTargetFrameSource will disable itself after reaching the target positions.
 void setVelocity(double velocity)
          Set the max velocity, measured as (change in NormalizedDouble)/millisecond.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PositionTargetFrameSource

public PositionTargetFrameSource(double velocity,
                                 Robot.RobotPositionMap targetPositions)
Creates a new MotionTargetFrameSource

Parameters:
context - BundleContext used to retrieve the Robot
robotId - Id of the Robot to move
velocity - maximum allowed velocity. The velocity is measured in terms of (change in NormalizedDouble)/millisecond
targetPositions - initial target positions to move towards. Positions for Joints not belonging to the Robot with the given robotId are ignored
Method Detail

setRobot

public void setRobot(Robot robot)
Description copied from interface: RobotFrameSource
Sets the Robot to

Specified by:
setRobot in interface RobotFrameSource

getRobot

public Robot getRobot()
Specified by:
getRobot in interface RobotFrameSource

setEnabled

public void setEnabled(boolean enabled)
If false, this MotionTargetFrameSource will return null when queried for Movements. A MotionTargetFrameSource is automatically enabled when target positions are changed, and disabled if they are cleared.

Parameters:
enabled -

getEnabled

public boolean getEnabled()
Returns true if enabled

Returns:
true if enabled

setVelocity

public void setVelocity(double velocity)
Set the max velocity, measured as (change in NormalizedDouble)/millisecond. A velocity of 0.0005 moves a joint across its full range in 2 seconds.

Parameters:
velocity - max velocity, measured as (change in NormalizedDouble)/millisecond

getVelocity

public double getVelocity()
Returns the velocity, measured as (change in NormalizedDouble)/millisecond

Returns:
the velocity, measured as (change in NormalizedDouble)/millisecond

setStopOnGoal

public void setStopOnGoal(boolean val)
When StopOnGoal is set true, the MotionTargetFrameSource will disable itself after reaching the target positions. Target positions are assumed to be reached when getMovements is called and all current positions are equal to the target positions. When this happens Enabled is set to false. The MotionTargetFrameSource can be re-enabled by setting Enabled to true.

Parameters:
val - value for StopOnGoal

getStopOnGoalFlag

public boolean getStopOnGoalFlag()
Returns the StopOnGoalFlag.

Returns:
the StopOnGoalFlag

putPositions

public void putPositions(Robot.RobotPositionMap targetPositions)
Puts the given positions in the target position map and enables this MotionTargetFrameSource.

Parameters:
targetPositions - positions to add

putPosition

public void putPosition(Robot.JointId id,
                        org.robokind.api.common.position.NormalizedDouble position)
Set the target position for the given JointId and enables this MotionTargetFrameSource.

Parameters:
id - JointId to set
position - new position to set

clearPositions

public void clearPositions()
Clears all target positions and disables this MotionTargetFrameSource.


getMovements

public MotionFrame getMovements(long time,
                                long interval)
Creates a MotionFrame starting at the Robot's goal positions, and moving towards the target positions as much as the velocity will allow in the given time interval.

Specified by:
getMovements in interface FrameSource<Robot.RobotPositionMap>
Parameters:
time - the time of this movement, often the current time
interval - time length of the movement in milliseconds
Returns:
MotionFrame starting at the Robot's goal positions, and moving towards the target positions as much as the velocity will allow in the given time interval

disableAtGoal

protected void disableAtGoal()

isAtGoal

protected boolean isAtGoal()


Copyright © 2011-2013. All Rights Reserved.