Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature rdx-generalization-other-robots #409

Merged
merged 17 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title" : "Atlas footstep planner parameters",
"Use GPU" : true,
"AStar heuristics weight" : 1.5,
"Max branch factor" : 175,
"Enable expansion mask" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public ROS2SyncedRobotModel(DRCRobotModel robotModel, ROS2Node ros2Node)
{
this(robotModel, ros2Node, robotModel.createFullRobotModel());
}

public ROS2SyncedRobotModel(DRCRobotModel robotModel, ROS2Node ros2Node, boolean enforceUniqueReferenceFrames)
{
this(robotModel, ros2Node, robotModel.createFullRobotModel(enforceUniqueReferenceFrames));
}

public ROS2SyncedRobotModel(DRCRobotModel robotModel, ROS2Node ros2Node, FullHumanoidRobotModel fullRobotModel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

public interface RobotVersion
{
default boolean hasHead()
{
return true;
}

default boolean hasArm(RobotSide robotSide)
{
return false;
Expand All @@ -14,11 +19,6 @@ default boolean hasBothArms()
return hasArm(RobotSide.LEFT) && hasArm(RobotSide.RIGHT);
}

default boolean hasHead()
{
return true;
}

default boolean hasSakeGripperJoints(RobotSide side)
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,12 @@ public MovingReferenceFrame getChestFrame()
{
return null;
}

@Override
public MovingReferenceFrame getHeadFrame()
{
return null;
}
}

public static class ForcePointController implements RobotController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ public class FootstepPlanningModule implements CloseableAndDisposable
private final DefaultFootstepPlannerParametersBasics footstepPlannerParameters;

private final WaypointDefinedBodyPathPlanHolder bodyPathPlanHolder = new WaypointDefinedBodyPathPlanHolder();
private final AStarBodyPathPlannerInterface bodyPathPlannerInterface;
private AStarBodyPathPlannerInterface bodyPathPlannerInterface;

// TODO plan then snap planner needs to work for height maps.
private final PlanThenSnapPlanner planThenSnapPlanner;
private final AStarFootstepPlanner aStarFootstepPlanner;
private final List<VariableDescriptor> footstepPlanVariableDescriptors;
private final SideDependentList<ConvexPolygon2D> footPolygons;

private final AtomicBoolean isPlanning = new AtomicBoolean();
private final FootstepPlannerRequest request = new FootstepPlannerRequest();
Expand All @@ -81,7 +82,7 @@ public class FootstepPlanningModule implements CloseableAndDisposable
private final List<Consumer<SwingPlannerType>> swingReplanRequestCallbacks = new ArrayList<>();
private final List<Consumer<FootstepPlan>> swingReplanStatusCallbacks = new ArrayList<>();

private final boolean useGPU;
private boolean useGPU;

public FootstepPlanningModule()
{
Expand All @@ -99,6 +100,11 @@ public FootstepPlanningModule(String name)
null);
}

public FootstepPlanningModule(boolean useGPU)
{
this(FootstepPlanningModule.class.getSimpleName(), useGPU);
}

public FootstepPlanningModule(String name, boolean useGPU)
{
this(name,
Expand Down Expand Up @@ -141,8 +147,10 @@ public FootstepPlanningModule(String name,
this.name = name;
this.aStarBodyPathPlannerParameters = aStarBodyPathPlannerParameters;
this.footstepPlannerParameters = footstepPlannerParameters;
this.footPolygons = footPolygons;

this.useGPU = useGPU;

if (useGPU)
{
this.bodyPathPlannerInterface = new GPUAStarBodyPathPlanner(footstepPlannerParameters, aStarBodyPathPlannerParameters, footPolygons, stopwatch);
Expand Down Expand Up @@ -210,6 +218,20 @@ public void destroy()
((GPUAStarBodyPathPlanner) bodyPathPlannerInterface).destroyOpenCLStuff();
}

public void enableGPUBodyPathPlanner(boolean useGPU)
{
if (this.useGPU && !useGPU)
{
destroy();
bodyPathPlannerInterface = new AStarBodyPathPlanner(footstepPlannerParameters, aStarBodyPathPlannerParameters, footPolygons, stopwatch);
}
else if (!this.useGPU && useGPU)
{
bodyPathPlannerInterface = new GPUAStarBodyPathPlanner(footstepPlannerParameters, aStarBodyPathPlannerParameters, footPolygons, stopwatch);
}
this.useGPU = useGPU;
}

private void handleRequestInternal(FootstepPlannerRequest request) throws Exception
{
this.request.set(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class DefaultFootstepPlannerParameters extends StoredPropertySet implemen
{
public static final StoredPropertyKeyList keys = new StoredPropertyKeyList();

public static final BooleanStoredPropertyKey useGPU = keys.addBooleanKey("Use GPU");
public static final DoubleStoredPropertyKey astarHeuristicsWeight = keys.addDoubleKey("AStar heuristics weight");
public static final IntegerStoredPropertyKey maxBranchFactor = keys.addIntegerKey("Max branch factor");
public static final BooleanStoredPropertyKey enableExpansionMask = keys.addBooleanKey("Enable expansion mask");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ default void set(DefaultFootstepPlannerParametersReadOnly footstepPlannerParamet
setAll(footstepPlannerParameters.getAll());
}

default void setUseGPU(boolean useGPU)
{
set(DefaultFootstepPlannerParameters.useGPU, useGPU);
}

default void setAStarHeuristicsWeight(double aStarHeuristicsWeight)
{
set(DefaultFootstepPlannerParameters.astarHeuristicsWeight, aStarHeuristicsWeight);
Expand Down Expand Up @@ -343,6 +348,7 @@ default void setCliffHeightThreshold(double cliffHeightThreshold)
default void set(FootstepPlannerParametersPacket parametersPacket)
{
double noValue = FootstepPlannerParametersPacket.DEFAULT_NO_VALUE;
setUseGPU(parametersPacket.getUseGpu());
setCheckForBodyBoxCollisions(parametersPacket.getCheckForBodyBoxCollisions());
setCheckForPathCollisions(parametersPacket.getCheckForPathCollisions());
setIntermediateBodyBoxChecks((int) parametersPacket.getIntermediateBodyBoxChecks());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ public interface DefaultFootstepPlannerParametersReadOnly extends StoredProperty
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// Algorithm parameters //////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Whether we use the GPU for body path planning
*/
default boolean getUseGPU()
{
return get(useGPU);
}

/**
* Heuristic inflation weight, used to speed up the planner at the expense of optimality
Expand Down Expand Up @@ -635,6 +642,7 @@ default FootstepPlannerParametersPacket getAsPacket()
{
FootstepPlannerParametersPacket packet = new FootstepPlannerParametersPacket();

packet.setUseGpu(getUseGPU());
packet.setAStarHeuristicsWeight(getAStarHeuristicsWeight());
packet.setMaxBranchFactor(getMaxBranchFactor());
packet.setEnableExpansionMask(getEnableExpansionMask());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static void copyParametersToPacket(FootstepPlannerParametersPacket packet
return;
}

packet.setUseGpu(parameters.getUseGPU());
packet.setReferencePlanAlpha(parameters.getReferencePlanAlpha());
packet.setCheckForBodyBoxCollisions(parameters.getCheckForBodyBoxCollisions());
packet.setCheckForPathCollisions(parameters.getCheckForPathCollisions());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"title" : "DefaultFootstepPlannerParameters",
"Use GPU" : true,
"AStar heuristics weight" : 1.5,
"Max branch factor" : -1,
"Enable expansion mask" : true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ public RDXDualBlackflyProjection(HumanoidReferenceFrames currentRobotFrames)
{
this.baseUI = RDXBaseUI.getInstance();
this.robotZUpFrame = currentRobotFrames.getMidFootZUpGroundFrame();
robotCameraFrames.set(currentRobotFrames::getSituationalAwarenessCameraFrame);
robotCameraFrames.set(currentRobotFrames::getStereoCameraFrame);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to stereo camera, as it's a better description of what those cameras are. Especially considering that we are dropping the blackflies

RigidBodyTransform stereoMidPoint = new RigidBodyTransform();
MovingReferenceFrame chestFrame = currentRobotFrames.getChestFrame();
stereoMidPoint.interpolate(currentRobotFrames.getSituationalAwarenessCameraFrame(RobotSide.LEFT).getTransformToDesiredFrame(chestFrame),
currentRobotFrames.getSituationalAwarenessCameraFrame(RobotSide.RIGHT).getTransformToDesiredFrame(chestFrame),
stereoMidPoint.interpolate(currentRobotFrames.getStereoCameraFrame(RobotSide.LEFT).getTransformToDesiredFrame(chestFrame),
currentRobotFrames.getStereoCameraFrame(RobotSide.RIGHT).getTransformToDesiredFrame(chestFrame),
0.5);
stereoMidPointFrame = ReferenceFrameTools.constructFrameWithUnchangingTransformToParent("StereoMidPoint", chestFrame, stereoMidPoint);
for (RobotSide side : RobotSide.values)
{
RigidBodyTransform cameraToStereoMidPoint = currentRobotFrames.getSituationalAwarenessCameraFrame(side).getTransformToDesiredFrame(chestFrame);
RigidBodyTransform cameraToStereoMidPoint = currentRobotFrames.getStereoCameraFrame(side).getTransformToDesiredFrame(chestFrame);
cameraToStereoMidPoint.invert();
cameraToStereoMidPoint.multiply(stereoMidPoint);
cameraToStereoMidPoint.invert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public static RDXHighLevelDepthSensorSimulator createOusterLidar(ReferenceFrame

public static RDXHighLevelDepthSensorSimulator createBlackflyFisheye(ROS2SyncedRobotModel syncedRobot)
{
return createBlackflyFisheye(syncedRobot.getReferenceFrames().getSituationalAwarenessCameraFrame(RobotSide.RIGHT), syncedRobot::getTimestamp);
return createBlackflyFisheye(syncedRobot.getReferenceFrames().getStereoCameraFrame(RobotSide.RIGHT), syncedRobot::getTimestamp);
}

public static RDXHighLevelDepthSensorSimulator createBlackflyFisheyeImageOnlyNoComms(ReferenceFrame sensorFrame)
Expand Down Expand Up @@ -226,7 +226,7 @@ public static RDXHighLevelDepthSensorSimulator createChestRightBlackflyForObject
double maxRange = 5.0;
RDXHighLevelDepthSensorSimulator highLevelDepthSensorSimulator
= new RDXHighLevelDepthSensorSimulator("Blackfly Right for Object Detection",
referenceFrames.getSituationalAwarenessCameraFrame(RobotSide.RIGHT),
referenceFrames.getStereoCameraFrame(RobotSide.RIGHT),
timeSupplier,
verticalFOV,
imageWidth,
Expand All @@ -241,8 +241,12 @@ public static RDXHighLevelDepthSensorSimulator createChestRightBlackflyForObject
return highLevelDepthSensorSimulator;
}

public static RDXHighLevelDepthSensorSimulator createChestZED2ForObjectDetection(HumanoidReferenceFrames referenceFrames,
LongSupplier timeSupplier)
public static RDXHighLevelDepthSensorSimulator createChestZED2ForObjectDetection(ROS2SyncedRobotModel syncedRobot)
{
return createChestZED2ForObjectDetection(syncedRobot.getReferenceFrames(), syncedRobot::getTimestamp);
}

public static RDXHighLevelDepthSensorSimulator createChestZED2ForObjectDetection(HumanoidReferenceFrames referenceFrames, LongSupplier timeSupplier)
{
double publishRateHz = 20.0;
double verticalFOV = 70.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ public void update(boolean interactablesEnabled)
boolean desiredHandPoseChanged = false;
for (RobotSide side : interactableHands.sides())
{
if (syncedRobot.getHandWrenchCalculators().get(side) == null)
continue;

// wrench expressed in wrist pitch body fixed-frame
if (interactableHands.get(side).getEstimatedHandWrenchArrows().getShow() != showWrench)
interactableHands.get(side).getEstimatedHandWrenchArrows().setShow(showWrench);
interactableHands.get(side).updateEstimatedWrench(syncedRobot.getHandWrenchCalculators().get(side).getFilteredWrench());

if (!interactableHands.get(side).isDeleted())
{
armIKSolvers.get(side).update(syncedRobot.getReferenceFrames().getChestFrame(), interactableHands.get(side).getControlReferenceFrame());
Expand All @@ -171,6 +163,14 @@ public void update(boolean interactablesEnabled)
desiredHandPoseChanged |= armIKSolvers.get(side).getDesiredHandControlPoseChanged();
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed bug, if the wrench calculator is null, it will skip the armIKSolver part. This means that the IK for the selectable hand didn't work if the robot has no hand


if (syncedRobot.getHandWrenchCalculators().get(side) == null)
continue;

// wrench expressed in wrist pitch body fixed-frame
if (interactableHands.get(side).getEstimatedHandWrenchArrows().getShow() != showWrench)
interactableHands.get(side).getEstimatedHandWrenchArrows().setShow(showWrench);
interactableHands.get(side).updateEstimatedWrench(syncedRobot.getHandWrenchCalculators().get(side).getFilteredWrench());
}

// The following puts the solver on a thread as to not slow down the UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ public RDXInteractableHand(RobotSide side,
ForceSensorDefinition[] forceSensorDefinitions = fullRobotModel.getForceSensorDefinitions();
for (int i = 0; i < forceSensorDefinitions.length; i++)
{
if (wristForceSensorNames.containsKey(side) && wristForceSensorNames.get(side).equals(forceSensorDefinitions[i].getSensorName()))
if (wristForceSensorNames != null)
{
// wristWrenchArrows.put(side, new RDXSpatialVectorArrows(forceSensorDefinitions[i].getSensorFrame(), i));
sensorWristWrenchArrows = new RDXSpatialVectorArrows(forceSensorDefinitions[i].getSensorFrame(),
yoVariableClientHelper,
side.getLowerCaseName() + "WristSensor");
if (wristForceSensorNames.containsKey(side) && wristForceSensorNames.get(side).equals(forceSensorDefinitions[i].getSensorName()))
{
// wristWrenchArrows.put(side, new RDXSpatialVectorArrows(forceSensorDefinitions[i].getSensorFrame(), i));
sensorWristWrenchArrows = new RDXSpatialVectorArrows(forceSensorDefinitions[i].getSensorFrame(),
yoVariableClientHelper,
side.getLowerCaseName() + "WristSensor");
}
}
}
ReferenceFrame afterLastWristJointFrame = fullRobotModel.getEndEffectorFrame(side, LimbName.ARM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public static String getModelFileName(RigidBodyDefinition rigidBodyDefinition)
}
if (modelFileGeometryDefinition == null || modelFileGeometryDefinition.getFileName() == null)
{
LogTools.error("Interactables need a model file or implementation of shape visuals");
LogTools.error("Interactables for {} need a model file or implementation of shape visuals", rigidBodyDefinition.getName());
return null;
}
return modelFileGeometryDefinition.getFileName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public RDXRobotCollidable(FrameShape3DReadOnly shape,
linkFrame = syncedLinkFrame;

RigidBodyTransform collisionToLinkFrameTransform = new RigidBodyTransform();
collisionShapeFrame = new MutableReferenceFrame("collisionShapeFrame" + rigidBodyName, linkFrame);
collisionShapeFrame = new MutableReferenceFrame("collisionShapeFrame" + rigidBodyName + collidableIndex, linkFrame);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need the index for robots like valkyrie which have multiple collidables per single rigid body

mouseCollidable = new MouseCollidable(this.shape);
vrPickRayCollidable = new MouseCollidable(this.shape);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ protected void renderImGuiWidgetsInternal()
ImGui.popItemWidth();
if (ImGui.button(labels.get("Set Configuration to Synced Arm")))
{
for (int i = 0; i < getDefinition().getJointAngles().getLength(); i++)
for (int i = 0; i < armJointNames.length; i++)
{
OneDoFJointBasics syncedJoint = syncedRobot.getFullRobotModel().getArmJoint(getDefinition().getSide(), armJointNames[i]);
if (syncedJoint != null)
Expand Down
Loading
Loading