Package edu.tufts.hrilab.pr2
Class MockPR2Component
java.lang.Object
edu.tufts.hrilab.diarc.DiarcComponent
edu.tufts.hrilab.pr2.MockPR2Component
- All Implemented Interfaces:
ArmInterface,LearningInterface,MoveItInterface,PR2Interface
-
Field Summary
Fields inherited from class edu.tufts.hrilab.diarc.DiarcComponent
executionLoopCycleTime, log, shouldRunExecutionLoop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloseGripper(String groupName) voidTurn off carrying orientation constraints.voidTurn on carrying orientation constraints.executeTrajectory(String trajectory_name) Execute a previously recorded trajectory.org.apache.commons.lang3.tuple.Pair<javax.vecmath.Point3d,javax.vecmath.Quat4d> Convenience method of getPose that finds the end-effector link based on the passed in groupName.floatgetGripperPosition(String groupName) org.apache.commons.lang3.tuple.Pair<javax.vecmath.Point3d,javax.vecmath.Quat4d> Get the point and orientation of a link on the robot.Move robot to previously recorded robot state/pose.Move robot to previously recorded robot state/pose, using only the specified group name (e.g., right_arm).booleangoToPoseNoPlanning(String pose_name) graspObject(String groupName, Symbol refId, float position) Close gripper(s) to specified amount and attach MemoryObject as a collision object.Use the passed in term to learn a new descriptor.voidloadEEPosesFromFile(String filename) Load poses previously saved to file and make them accessible via goToPose.voidloadPosesFromFile(String filename) Load poses previously saved to file and make them accessible via goToPose.voidloadTrajectoriesFromFile(String filename) Load trajectories from a file that was generated via saveTrajectoriesToFile().moveGripper(String groupName, float position) Move arms(s) to location of chosen grasp specified in MemoryObject.[ Move arms(s) to pose defined by the refId and constrained by a set of constraints.Move the groupName to a pose.moveTo(String group_name, javax.vecmath.Point3d point_l, javax.vecmath.Quat4d orientation_l, javax.vecmath.Point3d point_r, javax.vecmath.Quat4d orientation_r) Move the groupName to specified poses(s).moveToCartesian(String group_name, javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation) booleanmoveToJointPosition(String joint, double position) Set the position of a single joint.booleanmoveToJointPositions(String[] jointNames, double[] positions) booleanmoveToJointPositions(String[] joint_names, double[] positions, double[] velocities, double[] efforts) moveToRelative(String group_name, javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation) Move a certain amount from the current location, without any squeezing or releasing.openGripper(String groupName) booleanpointHeadTo(Symbol objectRef) Point head in direction of target object in base_link coordinate frame.booleanpointHeadTo(javax.vecmath.Point3d target_point) Point head in direction of target point in base_link coordinate frame.Point a groupName to an object.pressObject(String group_name, Symbol refID) Presses an object based off a given symbolpressObject(String group_name, javax.vecmath.Point3d object_location, javax.vecmath.Quat4d object_orientation) Presses an object based off a given posebooleanpublishPointCloudToRos(byte[] data) Publish the compressed depth data to ROS after being decompressed and converted to proper point cloud form.recordPose(Symbol pose_name) Record current robot state (i.e., joint positions), and name it.releaseObject(String groupName, Symbol refId, float position) Move arm(s) and open gripper(s) to specified amount and detach MemoryObject as collision object.saveEEPosesToFile(String filename) Write the poses recorded via recordPose to file.savePosesToFile(String filename) Write the poses recorded via recordPose to file.saveTrajectoriesToFile(String filename) Take all trajectories saved via startRecordingTrajectory and save them to a file for later.booleansetTorsoPosition(double position) Move the torso to desired joint position.voidstartRecordingTrajectory(String trajectory_name) Start recording a trajectory.voidStop recording the currently running trajectory recording.Un-learns things that have been learned by the learn method.Methods inherited from class edu.tufts.hrilab.diarc.DiarcComponent
additionalUsageInfo, createInstance, createInstance, createInstance, createInstance, executionLoop, getMyGroupConstraints, getMyGroups, getMyService, getMyServices, init, main, parseArgs, shutdown, shutdownComponent
-
Constructor Details
-
MockPR2Component
public MockPR2Component()
-
-
Method Details
-
moveTo
public Justification moveTo(String group_name, javax.vecmath.Point3d point_l, javax.vecmath.Quat4d orientation_l, javax.vecmath.Point3d point_r, javax.vecmath.Quat4d orientation_r) Description copied from interface:ArmInterfaceMove the groupName to specified poses(s). If group name only contains a single arm, use a different moveTo().Note that there's a baked-in assumption that the only two-arned nmachines will use a group name that is checked against in the 'isOneArm()' method (currently just "arms"). Update this function if this does not describe your use case. It also assumes that groupName "arms" can be described as independent movement of groupName "left_arm" and groupName "right_arm". At this point in time this is a safe assumption because of the state of the PR2's JSON config. point_l, orientation_l refer to the left arm, point_r and orientation_r refer to the right.
- Specified by:
moveToin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks.
-
moveTo
public Justification moveTo(String group_name, javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation) Description copied from interface:ArmInterfaceMove the groupName to a pose. Uses the default coordinate frame as set by JSON (defaulting to base_link).- Specified by:
moveToin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks.
-
moveTo
Description copied from interface:ArmInterfaceMove arms(s) to location of chosen grasp specified in MemoryObject. Uses the default "grasp_point(X)" constraint to select grasp points. Assumes default coordinate frame as set by JSON, defaulting to base_link. Note: gripper should already be open/closed before calling this method. This is an alternative method to moveTo that takes in POWER ref instead of MemoryObject.- Specified by:
moveToin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks.
-
moveToJointPositions
- Specified by:
moveToJointPositionsin interfaceMoveItInterface
-
moveToJointPositions
public boolean moveToJointPositions(String[] joint_names, double[] positions, double[] velocities, double[] efforts) - Specified by:
moveToJointPositionsin interfaceMoveItInterface
-
moveTo
public Justification moveTo(String group_name, Symbol objectRef, List<? extends Term> grasp_constraints) Description copied from interface:ArmInterface[ Move arms(s) to pose defined by the refId and constrained by a set of constraints. Assumes base_link coordinate frame. Note: gripper should already be open/closed before calling this method.- Specified by:
moveToin interfaceArmInterfacegrasp_constraints- a list of predicate constraints- Returns:
- true on success, false on failure. This function blocks.
-
moveToRelative
public Justification moveToRelative(String group_name, javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation) Description copied from interface:ArmInterfaceMove a certain amount from the current location, without any squeezing or releasing.- Specified by:
moveToRelativein interfaceArmInterface- Parameters:
group_name- the name of the arm or arms to movepoint- the amount of change in base frame the object is movedorientation- the amount to rotate the object in goal state from its current rotation in base frame- Returns:
- success or failure to move. This function blocks.
-
graspObject
Description copied from interface:ArmInterfaceClose gripper(s) to specified amount and attach MemoryObject as a collision object. Alternative method to graspObject that takes in POWER ref instead of MemoryObject.- Specified by:
graspObjectin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks.
-
releaseObject
Description copied from interface:ArmInterfaceMove arm(s) and open gripper(s) to specified amount and detach MemoryObject as collision object. Alternative method to releaseObject that takes in POWER ref instead of MemoryObject.- Specified by:
releaseObjectin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks.
-
getEEPose
public org.apache.commons.lang3.tuple.Pair<javax.vecmath.Point3d,javax.vecmath.Quat4d> getEEPose(String group_name) Description copied from interface:ArmInterfaceConvenience method of getPose that finds the end-effector link based on the passed in groupName.- Specified by:
getEEPosein interfaceArmInterface- Returns:
-
getPose
public org.apache.commons.lang3.tuple.Pair<javax.vecmath.Point3d,javax.vecmath.Quat4d> getPose(String link_name) Description copied from interface:ArmInterfaceGet the point and orientation of a link on the robot.- Specified by:
getPosein interfaceArmInterface
-
moveToCartesian
public Justification moveToCartesian(String group_name, javax.vecmath.Point3d point, javax.vecmath.Quat4d orientation) - Specified by:
moveToCartesianin interfaceMoveItInterface
-
pointHeadTo
Description copied from interface:PR2InterfacePoint head in direction of target object in base_link coordinate frame. Alternative method to pointHeadTo that takes in POWER ref instead of MemoryObject.- Specified by:
pointHeadToin interfacePR2Interface- Returns:
-
pointHeadTo
public boolean pointHeadTo(javax.vecmath.Point3d target_point) Description copied from interface:PR2InterfacePoint head in direction of target point in base_link coordinate frame.- Specified by:
pointHeadToin interfacePR2Interface- Returns:
-
pointTo
Description copied from interface:ArmInterfacePoint a groupName to an object.- Specified by:
pointToin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks
-
pointTo
- Specified by:
pointToin interfaceMoveItInterface
-
setTorsoPosition
public boolean setTorsoPosition(double position) Description copied from interface:PR2InterfaceMove the torso to desired joint position. TODO: replace this with the more general setJointPosition(String joint, double position) method in MoveItComponent- Specified by:
setTorsoPositionin interfacePR2Interface- Parameters:
position- all the way down is 0.0, and all the way up is approximately 0.3- Returns:
-
recordPose
Description copied from interface:ArmInterfaceRecord current robot state (i.e., joint positions), and name it.- Specified by:
recordPosein interfaceArmInterface- Parameters:
pose_name- The name of the pose to be saved.- Returns:
- true on success, false on failure. This function blocks.
-
saveEEPosesToFile
Description copied from interface:ArmInterfaceWrite the poses recorded via recordPose to file.- Specified by:
saveEEPosesToFilein interfaceArmInterface- Returns:
- true on success
-
loadEEPosesFromFile
Description copied from interface:ArmInterfaceLoad poses previously saved to file and make them accessible via goToPose.- Specified by:
loadEEPosesFromFilein interfaceArmInterface
-
goToPose
Description copied from interface:ArmInterfaceMove robot to previously recorded robot state/pose. Currently set to ignore gripper joints so it will leave grippers in current state of open/closed.- Specified by:
goToPosein interfaceArmInterface- Parameters:
pose_name- name of pose to move into- Returns:
- true on success, false on failure. This function blocks.
-
goToPose
Description copied from interface:ArmInterfaceMove robot to previously recorded robot state/pose, using only the specified group name (e.g., right_arm). Currently set to ignore gripper joints so it will leave grippers in current state of open/closed.- Specified by:
goToPosein interfaceArmInterface- Parameters:
pose_name- which arm(s) should move (rightArm, leftArm, arms, etc)group_name- name of pose to move into- Returns:
- true on success, false on failure. This function blocks.
-
goToPoseNoPlanning
- Specified by:
goToPoseNoPlanningin interfacePR2Interface
-
startRecordingTrajectory
Description copied from interface:ArmInterfaceStart recording a trajectory. Trajectory recording can be started here, the robot can be physically manipulated, and then stopRecordingTrajectory can be called to stop the current recording.- Specified by:
startRecordingTrajectoryin interfaceArmInterface- Parameters:
trajectory_name- The name of the trajectory to be saved.
-
stopRecordingTrajectory
public void stopRecordingTrajectory()Description copied from interface:ArmInterfaceStop recording the currently running trajectory recording.- Specified by:
stopRecordingTrajectoryin interfaceArmInterface
-
executeTrajectory
Description copied from interface:ArmInterfaceExecute a previously recorded trajectory.- Specified by:
executeTrajectoryin interfaceArmInterface- Returns:
- true on success, false on failure. This function blocks.
-
savePosesToFile
Description copied from interface:ArmInterfaceWrite the poses recorded via recordPose to file.- Specified by:
savePosesToFilein interfaceArmInterface- Returns:
- true on success
-
loadPosesFromFile
Description copied from interface:ArmInterfaceLoad poses previously saved to file and make them accessible via goToPose.- Specified by:
loadPosesFromFilein interfaceArmInterface
-
saveTrajectoriesToFile
Description copied from interface:ArmInterfaceTake all trajectories saved via startRecordingTrajectory and save them to a file for later.- Specified by:
saveTrajectoriesToFilein interfaceArmInterface- Parameters:
filename- Path to file- Returns:
- true on success, false on failure.
-
loadTrajectoriesFromFile
Description copied from interface:ArmInterfaceLoad trajectories from a file that was generated via saveTrajectoriesToFile(). The loaded trajectories will then be executable via executeTrajectory().- Specified by:
loadTrajectoriesFromFilein interfaceArmInterface
-
closeGripper
- Specified by:
closeGripperin interfaceArmInterface
-
openGripper
- Specified by:
openGripperin interfaceArmInterface
-
moveGripper
- Specified by:
moveGripperin interfaceArmInterface
-
getGripperPosition
- Specified by:
getGripperPositionin interfaceArmInterface
-
pressObject
public Justification pressObject(String group_name, javax.vecmath.Point3d object_location, javax.vecmath.Quat4d object_orientation) Description copied from interface:ArmInterfacePresses an object based off a given pose- Specified by:
pressObjectin interfaceArmInterface- Parameters:
group_name- The arm group to do the pressing (i.e. "arm")object_location- The location of the object relative to the base linkobject_orientation- The orientation of the object relative to the base link with the normal vector coming out of the object- Returns:
- Condition Justification stating if the action is successful or not
-
pressObject
Description copied from interface:ArmInterfacePresses an object based off a given symbol- Specified by:
pressObjectin interfaceArmInterface- Parameters:
group_name- The arm group to do the pressing (i.e. "arm")refID- Symbol representing the object to be pressed- Returns:
- Condition Justification stating if the action is successful or not
-
moveToJointPosition
Description copied from interface:MoveItInterfaceSet the position of a single joint. All remaining joints will remain in the same position.- Specified by:
moveToJointPositionin interfaceMoveItInterface- Parameters:
joint- The name of the joint to manipulate, as found in `names` of /joint_statesposition- The goal position, as viewed in /joint_states- Returns:
- true on success, false on failure. This function blocks.
-
enableCarryingConstraints
public void enableCarryingConstraints()Description copied from interface:MoveItInterfaceTurn on carrying orientation constraints. This will apply to all moveTo and goToPose methods.- Specified by:
enableCarryingConstraintsin interfaceMoveItInterface
-
disableCarryingConstraints
public void disableCarryingConstraints()Description copied from interface:MoveItInterfaceTurn off carrying orientation constraints.- Specified by:
disableCarryingConstraintsin interfaceMoveItInterface
-
publishPointCloudToRos
public boolean publishPointCloudToRos(byte[] data) Description copied from interface:MoveItInterfacePublish the compressed depth data to ROS after being decompressed and converted to proper point cloud form.- Specified by:
publishPointCloudToRosin interfaceMoveItInterface- Parameters:
data- A byte array containing the point cloud data.- Returns:
- true on success.
-
learn
Description copied from interface:LearningInterfaceUse the passed in term to learn a new descriptor. The term must have two arguments, the first arg 'describing' the new thing-to-learn, and the second arg 'naming' the new thing-to-learn. The description must be composed entirely of things vision already knows about.- Specified by:
learnin interfaceLearningInterface- Parameters:
learningTerm- term specifying the thing to learn (e.g., instanceOf(X,Y))- Returns:
- if thing-to-learn was successfully learned
-
unlearn
Description copied from interface:LearningInterfaceUn-learns things that have been learned by the learn method.- Specified by:
unlearnin interfaceLearningInterface- Returns:
-