Sparto is the control system for Team 997’s arm. The position of potentiometers on the shoulder and elbow of Sparto are translated by software to the position of the shoulder and elbow of 997’s robot. Also included on Sparto are buttons for controlling the gripper and a protected minibot deploy switch. Come check it out at the Autodesk Oregon Regional.
Now it just needs a mini-rack to score on (maybe with mini-tubes?)
Great work!
Do you have a cad drawing or pdf drawings for your design.
In addition, do you also a a schematic of the controls and wiring.
This would be a great tool for any team to use for arm manipulator controls.
This makes me soooo happy. Great idea!
Very cool !!!
Let me guess… you also have a set of red bumpers?
We almost did that this year. We had done something similarly in a previous year, and thought that maybe we should do it again. We used pre-set heights for each peg instead.
Sorry, we don’t have CAD or a schematic of it as of right now. You make an excellent point about the value in sharing this information. I can tell you it uses the Cypress I/O board we received in last year’s kit. The potentiometers are wired to the analog inputs, and the buttons & minibot switch are connected to the digital inputs. FIRST has made the software for reading these inputs really easy, at least in Java, and probably the other languages.
The bumpers are hot glued on. We had planned to make bumper covers to match the ones on our robot, but I don’t think they got done.
How did you code this? We use C++ on our bot and it seems like what you would have to do is set the setpoint of a PID loop to the value of the analog inputs on the model. Could you post the code that you wrote for this? And does it require any programming on the Cypress module?
If I were to program it, I would probably:
-
Take the inputs from the Cypress board (in Teleop.vi) and scale them to some sane units (degrees, radians, etc.), probably by taking the volts in, subtracting a known centerpoint (0 would probably be straight out or vertical, you pick but be consistent), and then multiplying the volts from center by a constant.
-
Send the scaled numbers off to another thread to be processed
-
Said other thread would take the units, and lookup the appropriate scaling on this robot (meaning, the competition or practice robot), and take the analog sensors on the robot and scale the inputs to the same units (with the same 0-point)
-
A P-controller would run in said thread, taking numbers of sane units from 1 and sensors of same sane units from 3 and determining the motor output for each joint. I have actually never used anything but P, because I have not yet found the need for any other terms.
If you do a lot of trig processing (maybe for gain scheduling or elsewhere), storing the value in radians makes everything cleaner. If you want to use stored positions (say, for autonomous), you can store them in radians, so if the sensor calibration changes, it doesn’t affect any other code.
In the spirit of coopertition and code reviews, here you go. The code could use a few more comments. This didn’t require any Cypress module programming other than the standard setup in the FIRST documentation.
We scaled them to a percentage.
public class Arm {
private CANJaguar m_shoulder;
private CANJaguar m_elbow;
private DriverStationEnhancedIO m_enhancedIO;
private int m_shoulderWaldoChannel;
private int m_elbowWaldoChannel;
private double m_shoulderValue = 0;
private double m_elbowValue = 0;
// This is correct. The down value is greater than the up value on the Waldo.
private static final double kDownShoulderVoltage = 2.7;
private static final double kUpShoulderVoltage = 1.3;
private static final double kRetractedElbowVoltage = 2.8;
private static final double kExtendedElbowVoltage = 0.9;
public static final double kDownShoulderPosition = 0.09;
public static final double kUpShoulderPosition = 0.55;
public static final double kRetractedElbowPosition = 0.084;
public static final double kExtendedElbowPosition = 0.665;
public static final double kElbowMinToBeCollecting = .4;
public static final double kShoulderMinWhenElbowInCollecting = 0.155;
private DriverStation m_ds = DriverStation.getInstance();
public Arm(int shoulderCANDevice, int elbowCANDevice, int shoulderWaldoChannel, int elbowWaldoChannel) {
try {
m_shoulder = new CANJaguar(shoulderCANDevice, CANJaguar.ControlMode.kPosition);
m_shoulder.setPositionReference(CANJaguar.PositionReference.kPotentiometer);
m_shoulder.setPID(1000, 0, 100);
m_shoulder.configPotentiometerTurns(1);
m_shoulder.configSoftPositionLimits(kUpShoulderPosition, kDownShoulderPosition);
m_shoulder.enableControl();
m_elbow = new CANJaguar(elbowCANDevice, CANJaguar.ControlMode.kPosition);
m_elbow.setPositionReference(CANJaguar.PositionReference.kPotentiometer);
m_elbow.setPID(700, 0, 50);
m_elbow.configPotentiometerTurns(1);
m_elbow.configSoftPositionLimits(kExtendedElbowPosition, kRetractedElbowPosition);
m_elbow.enableControl();
} catch (CANTimeoutException e) {
DriverStationPrinter.getInstance().println("CAN Arm Init Error!");
}
m_enhancedIO = DriverStation.getInstance().getEnhancedIO();
m_shoulderWaldoChannel = shoulderWaldoChannel;
m_elbowWaldoChannel = elbowWaldoChannel;
}
private void getValues() {
try {
m_shoulderValue = m_enhancedIO.getAnalogIn(m_shoulderWaldoChannel);
m_shoulderValue -= kDownShoulderVoltage;
m_shoulderValue /= (kUpShoulderVoltage - kDownShoulderVoltage);
if (m_shoulderValue < 0) {
m_shoulderValue = 0;
}
if (m_shoulderValue > 1) {
m_shoulderValue = 1;
}
m_elbowValue = m_enhancedIO.getAnalogIn(m_elbowWaldoChannel);
m_elbowValue -= kRetractedElbowVoltage;
m_elbowValue /= (kExtendedElbowVoltage - kRetractedElbowVoltage);
if (m_elbowValue < 0) {
m_elbowValue = 0;
}
if (m_elbowValue > 1) {
m_elbowValue = 1;
}
} catch (DriverStationEnhancedIO.EnhancedIOException e) {
DriverStationPrinter.getInstance().println("Waldo Pos Read Error!");
}
}
public void update() {
getValues();
double dMotorValueShoulder = m_shoulderValue;
dMotorValueShoulder *= (kUpShoulderPosition - kDownShoulderPosition);
dMotorValueShoulder += kDownShoulderPosition;
double dMotorValueElbow = m_elbowValue;
dMotorValueElbow *= (kExtendedElbowPosition - kRetractedElbowPosition);
dMotorValueElbow += kRetractedElbowPosition;
// Make sure that when the elbow is extended to collect that the shoulder stays
// up enough to prevent the forarm from hitting the front of the robot.
if ((dMotorValueElbow > kElbowMinToBeCollecting) && (dMotorValueShoulder < kShoulderMinWhenElbowInCollecting)){
dMotorValueShoulder = kShoulderMinWhenElbowInCollecting;
}
try {
m_shoulder.setX(dMotorValueShoulder);
m_elbow.setX(dMotorValueElbow);
} catch (CANTimeoutException e) {
DriverStationPrinter.getInstance().println("CAN Arm Pos Error!");
}
}
/*
*
* @param shoulderPosition The position value for the shoulder in motor counts.
* @param elbowPosition The position value for the elbow in motor counts.
*/
public void setAutonomousArmPositions(double shoulderPosition, double elbowPosition) {
if (m_ds.isAutonomous()) {
// Make sure the shoulder position is in range.
if (shoulderPosition > kUpShoulderPosition) {
shoulderPosition = kUpShoulderPosition;
} else if (shoulderPosition < kDownShoulderPosition) {
shoulderPosition = kDownShoulderPosition;
}
// Make sure the elbow position is in range.
if (elbowPosition > kExtendedElbowPosition) {
elbowPosition = kExtendedElbowPosition;
} else if (elbowPosition < kRetractedElbowPosition) {
elbowPosition = kRetractedElbowPosition;
}
// Set the positions.
try {
m_shoulder.setX(shoulderPosition);
m_elbow.setX(elbowPosition);
} catch (CANTimeoutException e) {
DriverStationPrinter.getInstance().println("CAN Auto Arm Pos Error!");
}
}
}
/**
* Updates the information on the SmartDashboard.
*/
public void updateSmartDashboard() {
try {
SmartDashboard.log(m_shoulder.getPosition(), "Shoulder Position");
SmartDashboard.log(m_elbow.getPosition(), "Elbow Position");
} catch (CANTimeoutException e) {
DriverStationPrinter.getInstance().println("CAN Get Arm Pos Error!");
}
}
}
Hey frasnow,
Are you guys going to the Championships?
No plans yet. We’d need to qualify at the Oregon Regional first.
My team had discussed making a control system like this, but we found that we didn’t have the time, and a simple gamepad served adequately. However, I’m really glad to see one of these actually have been made! Nice work!
wow this is really quite clever
How bad is the delay from when you make a movement to when the robot executes it? We tried something like this in 2005, but the delay was horrible so we scrapped it.
The delay is negligible if the arm is geared properly. Obviously you can move the model faster by hand then the motors on the arm can move it but if you move it in a smooth motion then it mimics the movement perfectly.
very cool would you mind taking some pictures of the side of it. like a picture of how the cypress broad is mounted