Closed ErikCald closed 1 year ago
Three states with different speeds are reasonable. But I still don't understand how to end at the right balanced spot with the new chargeCommand.
Since we don't use pid to control X, then we basically is using speed + time duration to control where the robot finally ends on the charge station. I feel this is harder to tune.
It's not speed + time duration. It's using the gyro pitch or roll as the core sensor to move accurately. We drive up the ramp, then the moment we cross over the tipping point of the charging station, the gyro senses that, changes to state 2 and then does a reverse voltage to cut all speed and land directly on the center of the charging station.
Position control is not accurate enough for this task, the gyro readings are amazing for this task. This setup of 3 states has proven to work through the humber event, but the position control was giving inaccurate speeds and making it hard for the gyro to take precedence.
It should actually be very easy to tune based on the experiences I had tuning this command on the practice field at humber.
Closed by #100
What is ChargeCommand
ChargeCommand is a command that has 3 states which it cycles through one by one until it reaches the final state.
When we check the roll or pitch values, they're first run through
Math.abs()
so that we don't have to bother managing positive vs. negative pitch/roll values.ChargeCommandRoll vs ChargeCommand
ChargeCommandRoll was quickly added in order to balance on the charging station with cube_0p5_middle_charge but we ran out of time to get it to work and just used ChargeCommand. Instead of the roll being managed in a seperate file, there should be a boolean in the parameters of the constructor of ChargeCommand to decide whether to use roll or pitch. If using pitch, the robot must go up the charging station the narrow way. If using roll, the robot must go up the wider way.
SwerveSubsystem.getInstance().getPitch();
. Instead, have an if statement that will either useSwerveSubsystem.getInstance().getPitch();
orSwerveSubsystem.getInstance().getRoll();
based on the boolean. Make sure to make this change to all the locations we havegetPitch()
in this command.Tasks to improve ChargeCommand
The current solution involves a
ProfiledPidController
and it's not working. TheProfiledPidController
should be removed and replaced with constant speed values instead. Note: TheProfiledPidController
for theta should be kept, it's working great. It just the X direction one, using the variable namepidControlX
that should be removed.pidControlX
variable.pidControlX
is being removed, the deltaX parameter of the constructor can also be removed. It should be replaced with a second boolean that will decide whether the robot is going in the positive X direction or the negative X direction. The speeds below should be flipped if the negative X direction is desired. One way to achieve this is to create an integer that is 1 or -1 based on the boolean and to multiple all the speeds by this integer. (int m_flipXDirection
)pidControlX.calculate(currentX, desiredX);
to decide how much speed in the X direction is needed, have constant values that are decided by the states. See below tasks:SwerveSubsystem.getInstance().drive(YOUR_X_SPEED_HERE * m_flipXDirection, 0, theta, true, false);
state == 0
the X speed should be pretty fast, somewhere between 1.5 m/s and 2 m/sstate == 1
The X speed should be pretty slow, somewhere between 0.5 m/s and 1 m/s.state == 2
it does a small jump back because normally it goes slightly too far. This could probably be kept the same. But if it doesn't go far enough you can either increase the speed in state 1 or decrease the jump back in state 2. To reduce the jump back in state 2, either reduce the time ofTIME_FOR_REVERSING
or decrease the -0.5 m/s in state 2.cube_0p5_middle_charge auto
This auto is basically already done. It was even tested at humber on the practice field. However the ChargeCommand at the time was inadequate and there wasn't time to get it to work.
This auto starts in the middle, lifts the arm, then drives foward, scores a top cube and final schedules the ChargeCommand to go onto the charging station.
All you need to do is:
"wait"
marker, which is actually already in the code.