Okay, our robot has a problem and I don’t know if it is happening to other people as well. When we try to run an autonomous program the first few lines of code do the opposite of what they are supposed to do. It does it almost every time although every once and a while it works perfectly fine. It also works perfectly when running the program on the “Programming Skills” and the “Timed Run” option on the controller, but when we connect it to a competition switch or TM it doesn’t. I have tried a couple things:
Using a different controller
Using a different code
Tried multiple cables to connect the controller to the comp. switch and TM
Tried a different motor cable
We have a competition tomorrow, any ideas?
As usual, post the code or it’s almost impossible to help.
6 Likes
#include "main.h"
std::shared_ptr<OdomChassisController> chassis =
ChassisControllerBuilder()
.withMotors(20, -15, -2, 8) // left motor is 1, right motor is 2 (reversed)
.withGains(
{0.0009, 0, 0.0000096}, // distance controller gains
{.002, 0, 0.000005}, // turn controller gains
{0.0015, 0, 0.0000009} // angle controller gains (helps drive straight)
)
// left encoder in ADI ports A & B, right encoder in ADI ports C & D (reversed)
.withSensors(ADIEncoder{'A', 'B'}, ADIEncoder{'C', 'D',true}, ADIEncoder{'E','F'})
.withDimensions(AbstractMotor::gearset::green, {{2.60_in, 12.375_in, 1_in, 7.25_in}, quadEncoderTPR})
// specify the tracking wheels diameter (2.75 in), track (7 in), and TPR (360)
.withOdometry()
.buildOdometry();
std::shared_ptr<AsyncPositionController<double, double>> frontIntake =
AsyncPosControllerBuilder()
.withMotor({-10, 4}) // intake motor port 3
.build();
std::shared_ptr<AsyncPositionController<double, double>> bottomRoller =
AsyncPosControllerBuilder()
.withMotor(13) // intake motor port 3
.build();
std::shared_ptr<AsyncPositionController<double, double>> topRoller =
AsyncPosControllerBuilder()
.withMotor(6) // intake motor port 3
.build();
void initialize() {}
void disabled() {}
void competition_initialize() {}
void frontIntakeOn(float check = true) {
if(check == true){
frontIntake->reset();
frontIntake->setTarget(1000000);
} else {
frontIntake->reset();
frontIntake->setTarget(0);
}
}
void waitChassis(){
chassis->waitUntilSettled();
}
void autonomous() {
//frontIntake->setMaxVelocity(12000); //from here
topRoller->setMaxVelocity(12000);
bottomRoller->setMaxVelocity(12000);
frontIntake->setTarget(1000);
frontIntake->waitUntilSettled(); //to here is where the problem has been
chassis->moveDistance(28_in);
chassis->waitUntilSettled();
frontIntake->setTarget(3000);
frontIntake->waitUntilSettled();
chassis->moveDistanceAsync(16_in);
bottomRoller->setTarget(1000);
chassis->waitUntilSettled();
frontIntake->waitUntilSettled();
chassis->turnAngle(-30_deg);
frontIntake->setTarget(2000);
frontIntake->waitUntilSettled();
chassis->moveDistanceAsync(5_in);//might need to be one inch less
pros::delay(600);
frontIntake->setTarget(10000);
topRoller->setTarget(2000);
topRoller->waitUntilSettled();
chassis->moveDistanceAsync(-12_in);
pros::delay(100);
frontIntake->setTarget(9000);
chassis->waitUntilSettled();
chassis->turnAngle(175_deg);
chassis->waitUntilSettled();
chassis->moveDistanceAsync(2_ft);
pros::delay(600);
topRoller->setTarget(5000);
bottomRoller->setTarget(2000);
chassis->waitUntilSettled();
topRoller->waitUntilSettled();
bottomRoller->waitUntilSettled();
chassis->moveDistance(-2_ft);
chassis->turnAngle(-60_deg);
topRoller->setTarget(-2000);
bottomRoller->setTarget(4000);
frontIntake->setTarget(17000);
chassis->moveDistanceAsync(60_in);
pros::delay(2950);
bottomRoller->setTarget(8000);
topRoller->setTarget(4000);
topRoller->waitUntilSettled();
chassis->moveDistanceAsync(-2_ft);
waitChassis();
chassis->turnAngle(-130_deg);
waitChassis();
chassis->moveDistanceAsync(38_in);
pros::delay(500);
frontIntake->setTarget(15000);
pros::delay(1000);
frontIntake->setTarget(20000);
chassis->waitUntilSettled();
chassis->turnAngle(-30_deg);
waitChassis();
chassis->moveDistanceAsync(38_in);
pros::delay(230);
frontIntake->setTarget(19600);
pros::delay(1000);
frontIntake->setTarget(21000);
bottomRoller->setTarget(9000);
waitChassis();
chassis->turnAngle(30_deg);
chassis->moveDistanceAsync(2_ft);
pros::delay(1000);
bottomRoller->setTarget(20000);
topRoller->setTarget(8000);
}
The first 4 lines in autonomous is where it starts, the frontIntake is where the problem has been.
system
Closed
November 6, 2021, 7:10pm
6
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.