|
| 1 | +package us.ihmc.commonWalkingControlModules.highLevelHumanoidControl.highLevelStates; |
| 2 | + |
| 3 | +import us.ihmc.commonWalkingControlModules.configurations.HighLevelControllerParameters; |
| 4 | +import us.ihmc.commonWalkingControlModules.controllerCore.command.lowLevel.RootJointDesiredConfigurationData; |
| 5 | +import us.ihmc.commonWalkingControlModules.controllerCore.command.lowLevel.RootJointDesiredConfigurationDataReadOnly; |
| 6 | +import us.ihmc.commonWalkingControlModules.controllerCore.command.lowLevel.YoLowLevelOneDoFJointDesiredDataHolder; |
| 7 | +import us.ihmc.commonWalkingControlModules.momentumBasedController.HighLevelHumanoidControllerToolbox; |
| 8 | +import us.ihmc.communication.controllerAPI.CommandInputManager; |
| 9 | +import us.ihmc.humanoidRobotics.communication.controllerAPI.command.ArmTrajectoryCommand; |
| 10 | +import us.ihmc.humanoidRobotics.communication.packets.dataobjects.HighLevelControllerName; |
| 11 | +import us.ihmc.sensorProcessing.outputData.JointDesiredOutputListReadOnly; |
| 12 | + |
| 13 | +import java.util.List; |
| 14 | + |
| 15 | +/** |
| 16 | + * This controller state accepts controller API commands, manages the trajectories, but |
| 17 | + * passes the desired positions directly to the joint desired output list. |
| 18 | + */ |
| 19 | +public class PositionPassthroughControllerState extends HighLevelControllerState |
| 20 | +{ |
| 21 | + private final static HighLevelControllerName controllerState = HighLevelControllerName.POSITION_PASSTHROUGH; |
| 22 | + private final CommandInputManager commandInputManager; |
| 23 | + private final YoLowLevelOneDoFJointDesiredDataHolder jointDesiredDataHolder; |
| 24 | + /** not used **/ |
| 25 | + private final RootJointDesiredConfigurationData rootJointDesiredConfigurationData = new RootJointDesiredConfigurationData(); |
| 26 | + |
| 27 | + public PositionPassthroughControllerState(CommandInputManager commandInputManager, |
| 28 | + HighLevelHumanoidControllerToolbox controllerToolbox, |
| 29 | + HighLevelControllerParameters highLevelControllerParameters) |
| 30 | + { |
| 31 | + super(controllerState, highLevelControllerParameters, controllerToolbox.getControlledOneDoFJoints()); |
| 32 | + |
| 33 | + this.commandInputManager = commandInputManager; |
| 34 | + |
| 35 | + jointDesiredDataHolder = new YoLowLevelOneDoFJointDesiredDataHolder(controllerToolbox.getControlledOneDoFJoints(), |
| 36 | + controllerToolbox.getYoVariableRegistry()); |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public void onEntry() |
| 41 | + { |
| 42 | + |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public void doAction(double timeInState) |
| 47 | + { |
| 48 | + List<ArmTrajectoryCommand> armTrajectoryCommands = commandInputManager.pollNewCommands(ArmTrajectoryCommand.class); |
| 49 | + |
| 50 | + for (ArmTrajectoryCommand armTrajectoryCommand : armTrajectoryCommands) |
| 51 | + { |
| 52 | + for (int i = 0; i < armTrajectoryCommand.getJointspaceTrajectory().getNumberOfJoints(); i++) |
| 53 | + { |
| 54 | + |
| 55 | +// jointDesiredDataHolder.setDesiredJointPosition(); |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + public void onExit(double timeInState) |
| 64 | + { |
| 65 | + |
| 66 | + } |
| 67 | + |
| 68 | + @Override |
| 69 | + public JointDesiredOutputListReadOnly getOutputForLowLevelController() |
| 70 | + { |
| 71 | + return jointDesiredDataHolder; |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public RootJointDesiredConfigurationDataReadOnly getOutputForRootJoint() |
| 76 | + { |
| 77 | + return rootJointDesiredConfigurationData; |
| 78 | + } |
| 79 | +} |
0 commit comments