Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Added logic for autoaim
Browse files Browse the repository at this point in the history
  • Loading branch information
superrm11 committed Apr 7, 2024
1 parent bdbd87b commit 816623d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .vscode/vex_project_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"json": 2
},
"project": {
"name": "RED_Jover",
"name": "Jover_WithLight",
"description": "",
"creationDate": "Sun, 10 Mar 2024 19:16:09 GMT",
"creationDate": "Sun, 07 Apr 2024 17:47:14 GMT",
"platform": "V5",
"language": "cpp",
"slot": 8,
"slot": 1,
"sdkVersion": "V5_20240223_11_00_00",
"cpp": {
"includePath": [],
Expand Down
2 changes: 1 addition & 1 deletion src/automation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void drive_tank_autoaim(TankDrive::BrakeType brake) {
}
);

const double kP = 0.003; // Units: percent per delta pixels
const double kP = 0.0035; // Units: percent per delta pixels
const int setpoint = 160;
double correction = 0;

Expand Down
18 changes: 10 additions & 8 deletions src/competition/opcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <atomic>

#define Tank
#define EN_AUTOAIM

std::atomic<bool> disable_drive(false);
std::atomic<bool> brake_mode_toggled(false);
Expand Down Expand Up @@ -108,11 +109,11 @@ void setupJoeControls()
*/
void opcontrol() {
// ================ TUNING CODE (Disable when not testing) ================
testing();
// testing();

// ================ INIT ================
// Ensure the catapult system is enabled during driver control
if (cata_sys.get_cata_state() == CataOnlyState::CataOff) {
// Disable catapult while in driver (sadface)
if (cata_sys.get_cata_state() != CataOnlyState::CataOff) {
cata_sys.send_command(CataSys::Command::ToggleCata);
}

Expand All @@ -131,10 +132,11 @@ void opcontrol() {
double l = con.Axis3.position() / 100.0;
double r = con.Axis2.position() / 100.0;
if (!disable_drive && !enable_matchload) {
if (brake_mode_toggled)
drive_sys.drive_tank(l, r, 1, TankDrive::BrakeType::Smart);
else
#ifdef EN_AUTOAIM
drive_tank_autoaim(TankDrive::BrakeType::None);
#else
drive_sys.drive_tank(l, r, 1, TankDrive::BrakeType::None);
#endif
}

if (!disable_drive && enable_matchload) {
Expand Down Expand Up @@ -195,8 +197,8 @@ void testing() {
// if (!disable_drive)
// drive_sys.drive_tank(f, s, 1, TankDrive::BrakeType::None);
if (!disable_drive)
// drive_tank_autoaim(TankDrive::BrakeType::None);
drive_sys.drive_tank(l, r, 1, TankDrive::BrakeType::None);
drive_tank_autoaim(TankDrive::BrakeType::None);
// drive_sys.drive_tank(l, r, 1, TankDrive::BrakeType::None);

// ================ Drive Tuning =================
static bool done_a = false;
Expand Down

0 comments on commit 816623d

Please sign in to comment.