importedu.wpi.first.wpilibj.Servo;importedu.wpi.first.math.MathUtil;Servoservo=newServo(channel);// PWM channel from the Romi web pageservo.set(position);// 0.0 to 1.0servo.get();// the last position setservo.setAngle(degrees);// 0 to 180, same thing in degreesservo.close();// free the channel (tests)MathUtil.clamp(value,0.0,1.0);// keep a number inside a rangeservo.setBoundsMicroseconds(2400,0,0,0,500);// wider pulse range, only if the gripper needs it
A subsystem can also hand out its own commands. A method on Arm like public Command openGripper() { return runOnce(...); } lets RobotContainer write m_arm.openGripper().
@BeforeEachvoidsetUp(){assertTrue(HAL.initialize(500,0));m_arm=newArm();}@AfterEachvoidtearDown(){m_arm.close();// Arm implements AutoCloseable and closes its servos}assertEquals(0.75,m_arm.getTilt(),1e-3);// positions are stored in whole microseconds