Okay so we have a lemlib pros file. It’s set up exactly like other files we have that ran in the past. the file runs- but the actual code won’t run with or without a comp. switch. like the opcontrol method just won’t run no matter what. does anyone know what is going on. this is my first post so it wont let me add the file. but i can add the setup if necessary
Files or code would be useful. Do you have the line for initializing the competition and telling it what function is the opcontrol and what is the pre match auton?
Here’s my code:
#include "main.h"
#include "lemlib/chassis/chassis.hpp"
#include "pros/misc.h"
#include "pros/motor_group.hpp"
#include "pros/motors.h"
#include "pros/rtos.hpp"
#include <cstdint>
#include "lemlib/api.hpp"
pros::MotorGroup left_motors({-3, -4, -5}, pros::MotorGearset::blue);
pros::MotorGroup right_motors({6,7,8}, pros::MotorGearset::blue);
pros::Controller controller(pros::E_CONTROLLER_MASTER);
// drivetrain settings
lemlib::Drivetrain drivetrain(
&left_motors, // left motor group
&right_motors, // right motor group
11.75, // track width
lemlib::Omniwheel::NEW_325, // wheel type
450, // drivetrain rpm is 360
2 // horizontal drift is 2 (for now)2
);
pros::Imu imu(11);
// horizontal tracking wheel encoder
pros::Rotation horizontal_encoder(1);
// vertical tracking wheel encoder
pros::Rotation vertical_encoder(20);
// horizontal tracking wheel
lemlib::TrackingWheel horizontal_odom_wheel(&horizontal_encoder, lemlib::Omniwheel::NEW_275, -5.375);
// vertical tracking wheel
lemlib::TrackingWheel vertical_odom_wheel(&vertical_encoder, lemlib::Omniwheel::NEW_275, -0.5);
lemlib::OdomSensors sensors(&vertical_odom_wheel, // vertical tracking wheel 1, set to null
nullptr, // vertical tracking wheel 2, set to nullptr as we are using IMEs
&horizontal_odom_wheel, // horizontal tracking wheel 1
nullptr, // horizontal tracking wheel 2, set to nullptr as we don't have a second one
&imu // inertial sensor
);
lemlib::ControllerSettings lateral_controller(
10, // proportional gain (kP)
0, // integral gain (kI)
3, // derivative gain (kD)
3, // anti windup
1, // small error range, in inches
100, // small error range timeout, in milliseconds
3, // large error range, in inches
500, // large error range timeout, in milliseconds
20 // maximum acceleration (slew)
);
lemlib::ControllerSettings angular_controller(
2, // proportional gain (kP)
0, // integral gain (kI)
10, // derivative gain (kD)
3, // anti windup
1, // small error range, in inches
100, // small error range timeout, in milliseconds
3, // large error range, in inches
500, // large error range timeout, in milliseconds
0 // maximum acceleration (slew)
);
// create the chassis
lemlib::Chassis chassis(
drivetrain, // drivetrain settings
lateral_controller, // lateral PID settings
angular_controller, // angular PID settings
sensors // odometry sensors
);
void opcontrol() {
pros::lcd::print(0, "X: %f", 1);
while (true) {
// get left y and right x positions
int leftY = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
int rightX = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X);
// move the robot
chassis.arcade(leftY, rightX);
pros::delay(25);
}
}
// initialize function in your project. The first function that runs when the program is started
void initialize() {
pros::lcd::initialize(); // initialize brain screen
chassis.calibrate();
}
void disabled() {}
void competition_initialize() {
pros::lcd::initialize(); // initialize brain screen
chassis.calibrate(); // calibrate sensors
}
void autonomous() {
//chassis.setPose(0, 0, 0);
// chassis.moveToPoint(12, 0, 2000);
}
1 Like