Skip to content

Commit 68d293a

Browse files
authored
Merge pull request #65 from calhighrobotics/fix/issue-58/retune-pids
fix/issue 58/retune pids
2 parents ebe509a + 824e7e2 commit 68d293a

File tree

2 files changed

+34
-36
lines changed

2 files changed

+34
-36
lines changed

src/globals.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pros::adi::Pneumatics HangControl('C', false);
3737
pros::adi::Pneumatics SweeperControl('B', false);
3838

3939
pros::Rotation lateral_sensor(16);
40-
pros::Rotation horizontal_sensor(-17);
40+
pros::Rotation horizontal_sensor(17);
4141

4242
pros::Imu inertial_sensor(14);
4343

@@ -59,8 +59,8 @@ pros::MotorGroup drive_({LeftFront.get_port(), RightFront.get_port(), LeftMid.ge
5959
LeftBack.get_port(), RightBack.get_port()});
6060

6161
// Lemlib objects - Used by lemlib drive and odometry functions
62-
lemlib::TrackingWheel horizontal_tracking_wheel(&horizontal_sensor, lemlib::Omniwheel::NEW_2, -5);
63-
lemlib::TrackingWheel vertical_tracking_wheel(&lateral_sensor, lemlib::Omniwheel::NEW_2, -1.45);
62+
lemlib::TrackingWheel horizontal_tracking_wheel(&horizontal_sensor, 2, -2.75);
63+
lemlib::TrackingWheel vertical_tracking_wheel(&lateral_sensor, 2, -1);
6464

6565
// Describes the lemlib objects that are used to control the autonomous
6666
// functions of the robot.
@@ -83,21 +83,21 @@ lemlib::OdomSensors sensors{
8383

8484
// forward/backward PID
8585
// lateral PID controller
86-
lemlib::ControllerSettings lateral_controller(10, // proportional gain (kP)
87-
0, // integral gain (kI)
88-
4.5, // derivative gain (kD)
89-
3, // anti windup
90-
1, // small error range, in inches
86+
lemlib::ControllerSettings lateral_controller(5.25, // proportional gain (kP)
87+
0, // integral gain (kI)
88+
13, // derivative gain (kD)
89+
3, // anti windup
90+
1, // small error range, in inches
9191
100, // small error range timeout, in milliseconds
92-
3, // large error range, in inches
92+
3, // large error range, in inches
9393
500, // large error range timeout, in milliseconds
94-
25 // maximum acceleration (slew)
94+
20 // maximum acceleration (slew)
9595
);
9696

9797
// angular PID controller
98-
lemlib::ControllerSettings angular_controller(2, // proportional gain (kP)
98+
lemlib::ControllerSettings angular_controller(1.73, // proportional gain (kP)
9999
0, // integral gain (kI)
100-
10.5, // derivative gain (kD)
100+
9, // derivative gain (kD)
101101
3, // anti windup
102102
1, // small error range, in degrees
103103
100, // small error range timeout, in milliseconds

src/main.cpp

+22-24
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ struct Electronics {
5353
* to keep execution time for this mode under a few seconds.
5454
*/
5555

56-
pros::rtos::Task MotorNotification(electronic.controllers.notify_motor_disconnect);
57-
pros::rtos::Task LadyBrownNotification(subsystem.ladybrown.edge_check);
56+
5857

5958
void initialize() {
6059
chassis.calibrate();
6160

6261
chassis.setPose(0, 0, 0);
62+
pros::rtos::Task MotorNotification(electronic.controllers.notify_motor_disconnect);
6363

64+
//pros::rtos::Task LadyBrownNotification(subsystem.ladybrown.edge_check);
6465
//screen.selector.selector();
6566
pros::lcd::initialize();
6667
pros::Task screen_task([&]() {
@@ -112,20 +113,27 @@ void competition_initialize() {}
112113
void autonomous() {
113114

114115
pros::lcd::initialize();
115-
pros::Task screen_task([&]() {
116-
while (true) {
117-
// print robot location to the brain screen
118-
pros::lcd::print(0, "X: %f", chassis.getPose().x); // x
119-
pros::lcd::print(1, "Y: %f", chassis.getPose().y); // y
120-
pros::lcd::print(2, "Theta: %f", chassis.getPose().theta); // heading
121-
// delay to save resources
122-
pros::lcd::print(3, "Rotation Sensor: %i", lateral_sensor.get_position());
123-
pros::lcd::print(4, "Rotation Sensor: %i", horizontal_sensor.get_position());
124-
pros::delay(20);
125-
}
126-
});
116+
// pros::Task screen_task([&]() {
117+
// while (true) {
118+
// // print robot location to the brain screen
119+
// pros::lcd::print(0, "X: %f", chassis.getPose().x); // x
120+
// pros::lcd::print(1, "Y: %f", chassis.getPose().y); // y
121+
// pros::lcd::print(2, "Theta: %f", chassis.getPose().theta); // heading
122+
// // delay to save resources
123+
// pros::lcd::print(3, "Rotation Sensor: %i", lateral_sensor.get_position());
124+
// pros::lcd::print(4, "Rotation Sensor: %i", horizontal_sensor.get_position());
125+
// pros::delay(20);
126+
// }
127+
// });
127128

128129
subsystem.autonomous.AutoDrive(subsystem.intake, subsystem.latch);
130+
131+
//chassis.turnToHeading(90, 100000);
132+
// chassis.turnToHeading(180, 2000);
133+
//chassis.moveToPoint(0, 24, 10000);
134+
135+
136+
129137
}
130138

131139
/**
@@ -163,16 +171,6 @@ void opcontrol() {
163171
// Output the current drive mode to the controller screen
164172
controller.print(0, 0, "reversal: %d", Drivetrain::isReversed);
165173
}
166-
if (controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_X)) {
167-
if (LadyBrownNotification.get_state() == 2) {
168-
LadyBrownNotification.suspend();
169-
controller.print(0, 0, "LB-Disabled");
170-
} else {
171-
LadyBrownMotor.set_zero_position(LadyBrownMotor.get_position());
172-
LadyBrownNotification.resume();
173-
controller.print(0, 0, "LB-Enabled");
174-
}
175-
}
176174

177175
subsystem.drivetrain.run();
178176
subsystem.latch.run();

0 commit comments

Comments
 (0)