FRC2706 / 2023-2706-Robot-Code

Code for the 2023 game.
Other
4 stars 2 forks source link

ChargeCommand and cube_0p5_middle_charge auto #94

Closed ErikCald closed 1 year ago

ErikCald commented 1 year ago

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.

Tasks to improve ChargeCommand

The current solution involves a ProfiledPidController and it's not working. The ProfiledPidControllershould be removed and replaced with constant speed values instead. Note: The ProfiledPidControllerfor theta should be kept, it's working great. It just the X direction one, using the variable name pidControlXthat should be removed.

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:

weizhang-2706 commented 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.

weizhang-2706 commented 1 year ago

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.

ErikCald commented 1 year ago

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.

ErikCald commented 1 year ago

Closed by #100