Fixed a problem where the OPControl was trying to pull values from an array that never had any values to begin with

causeing a segmentation fault and crashing the brain.
Also changed how the function lift_range_finder worked.  Instead of just makeing a variable eqaul to a number it also returns the value
so we can use it outside of the function.
We also added actual values to all the arrays.
This commit is contained in:
Carter committed 2026-09-09 13:29:07 -04:00
1 parent c46a581eb1
commit 24ee947fd5
8 files changed
+340 -192

No files matched your search

+36 -27
View File
@@ -1,10 +1,5 @@
#include "main.h"
// Global Variables
Pneumatics pistonControl;
ArmMech armObj;
LiftMech liftObj;
WristMech wristObj;
#include <iostream>
// Chassis constructor
ez::Drive chassis(
@@ -24,22 +19,19 @@ ez::Drive chassis(
ez::tracking_wheel horiz_tracker(8, 2.75, 4.0); // This tracking wheel is perpendicular to the drive wheels
// ez::tracking_wheel vert_tracker(9, 2.75, 4.0); // This tracking wheel is parallel to the drive wheels
// Arm constructor
ArmMech armSetup();
// Default Objects
Pneumatics pistonControl;
ArmMech armObj;
// Lift constructor
LiftMech liftSetup(
LiftMech liftObj(
{0, 100, 200, 300},
4);
{0, 63194, 94246, 139878}, 4);
// Wrist constructor
WristMech wristSetup(
WristMech wristObj(
{0, 100},
2);
{0, -14529}, 2);
/**
* Runs initialization code. This occurs as soon as the program is started.
@@ -53,7 +45,18 @@ void initialize() {
pros::delay(500); // Stop the user from doing anything while legacy ports configure
armObj.set_state_values({1, 2}, {1, 2}, {1, 2}, {1, 2});
armObj.set_state_values(
{0, -5642},
{0, -22702},
{0, -19740},
{0, -17121}
);
liftObj.set_ranges(
{0, 63194},
{63194, 94246},
{94246, 139878},
{139878, 150000}
);
armRotation.reset_position();
liftRotation.reset_position();
@@ -66,7 +69,7 @@ void initialize() {
wristObj.wrist_control();
pros::delay(10);
}
});
});
// Look at your horizontal tracking wheel and decide if it's in front of the midline of your robot or behind it
// - change `back` to `front` if the tracking wheel is in front of the midline
@@ -284,22 +287,28 @@ void opcontrol() {
ez_template_extras();
// Call custom drive functions here
pistonControl.control_piston(Pistons::claw_piston, ControlPeriod::driver,
Controller::slave, Buttons::arrow_buttons);
pistonControl.control_piston(PistonsP::claw_piston, ControlPeriodP::driver,
ControllerP::slave, ButtonsP::arrow_buttons);
armObj.arm_driver_control(Controller::master, Buttons::left_shoulder_buttons);
liftObj.lift_driver_control(Controller::master, Buttons::right_shoulder_buttons);
//armObj.arm_driver_control(ControllerR::master, ButtonsR::left_shoulder_buttons);
//liftObj.lift_driver_control(ControllerR::master, ButtonsR::right_shoulder_buttons);
armObj.arm_driver_control(ControllerR::slave, ButtonsR::left_shoulder_buttons);
liftObj.lift_driver_control(ControllerR::slave, ButtonsR::right_shoulder_buttons);
wristObj.wrist_driver_control(ControllerR::slave, ButtonsR::Y_B_buttons);
//wristObj.rotate_wrist(90);
armObj.arm_driver_control(Controller::slave, Buttons::left_shoulder_buttons);
liftObj.lift_driver_control(Controller::slave, Buttons::right_shoulder_buttons);
wristObj.wrist_driver_control(Controller::slave, Buttons::arrow_buttons);
wristObj.rotate_wrist(90);
// chassis.opcontrol_tank(); // Tank control
chassis.opcontrol_arcade_standard(ez::SPLIT); // Standard split arcade
// chassis.opcontrol_tank(); // Tank control
// chassis.opcontrol_arcade_standard(ez::SINGLE); // Standard single arcade
// chassis.opcontrol_arcade_flipped(ez::SPLIT); // Flipped split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // Flipped single arcade
// Terminal debugging
std::cout << "Arm rotation sensor value: " << "\033[31m" << armRotation.get_position() << " cdg" << "mm\033[0m" << std::endl;
std::cout << "Lift rotation sensor value: " << "\033[32m" << liftRotation.get_position() << " cdg" << "mm\033[0m" << std::endl;
std::cout << "Wrist rotation sensor value: " << "\033[33m" << wristRotation.get_position() << " cdg" << "mm\033[0m" << std::endl;
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}