sta-titansrobotics / 19447-CENTERSTAGE

BSD 3-Clause Clear License
2 stars 1 forks source link

Auto Programming #16

Open gordonfdsa opened 11 months ago

gordonfdsa commented 11 months ago

47 Autonomous workflow

Oct 19:

gordonfdsa commented 11 months ago

Tele Op: Implemented Tank Drive:

Reconfigured the robot motors, now its working as intended Autonomous movement/vision next

DreamChaser0719 commented 11 months ago

Auto:

gordonfdsa commented 11 months ago

May use MeepMeep to implement and test roadrunner auto, which will have more precise movements than the current encoder system.

gordonfdsa commented 11 months ago

.

gordonfdsa commented 11 months ago

Nov 2:

To do:

gordonfdsa commented 11 months ago

Nov 8:

PID controller

Basically, its a calculation which takes in the inputs of:

  1. where the encoder position (e.g. 300 ticks) is currently at and
  2. where the encoder position is set to be. (e.g. 2000 ticks) In order to calculate the power to set the robot to. the output of this calculation will be the power which the robot should be set to for optimal movement.

The formula is: f(t) = (Kp)P(t) + (Kd)D(t) + (Ki)I(t), where t represents any given time and f(t) determines what power the robot should be set to at that given time.

Kp, Ki, and Kd are constants which will eventually be tuned according to robot.

First term {(Kp)P(t)} is the Proportional term. P(t) is basically [set encoder distance - current encoder distance] at any given time t, meaning how much further the robot have to go until target location.

Second term {(Kd)D(t)} is the Derivative term. D(t) calculates the instantaneous rate of change of how fast the error is changing, and this is used to try to keep the error constant. For instance, taking two points on a graph of a curve, if you connect those two points, you will get a slope using (y2-y1)/(x2-x1). However, imagine the x values of two points moving closer towards each other, then the line which connects those two points will be almost tangent to the curve at that specific x value. This line represents the instantaneous slope at that specific x value. The code basically uses the error of the encoder distances from the last iteration and the current iteration of the loops as the y1 and y2 values, and the time at the last iteration and time at the current iteration as the x1 and x2 values. this is how D(t) is calculated.

Another way to think of this is you want to robot to go fast when its far away from your target location, but as it closes in, you want to gradually decrease power so it doesn't overshoot and comes to a nice stop, we can achieve this by using the Proportion term. As the robot gets closer to the location, the target encoder position - current encoder position will be smaller, thus resulting in a smaller power, recall that f(t) is the power which the robot will be set to at a given time.

However, this will encounter issues as for example, the motor doesn't rotate at constant power, so when you set the power to 0.5, it actually moves at 0.48, which will make the code less accurate, this is what the D(t) attempts to do, such that when you set the power to 0.5, it actually moves at 0.5 speed.

For more details, visit: https://gm0.org/en/latest/docs/software/concepts/control-loops.html

gordonfdsa commented 10 months ago

Nov 23:

Added secondary controls. Motors and Servos are basically the same thing, motors have 360 degree continuous motion and more power, while servos have a limit of usually 270 degrees rotation and less power.

Current motor and servo setup (excluding drivetrain): Motors: DcMotor Intake (Intakes the pixels) --> Done DcMotor Sliders (The linear slider which moves the board up and down, actual motor rotates a string spool which pulls on the sliders) --> Done DcMotor Climbing1 (for the robot to hang during endgame, one on each side of the robot) --> Done DcMotor Climbing2 (for the robot to hang during endgame, one on each side of the robot) --> Done

Servos: Servo DropperTop (The top servo to drop the pixel from the board) --> Done Servo DropperBottom (The bottom servo to drop the pixel from the board) --> Done Servo Wrist (the thing that rotates the board contains the pixels) --> still have to work on Servo AirplaneLauncher (Servo which rotates to release a rubber band, launching the airplane) --> Still have to work on