Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ board_build.mcu = esp32
upload_protocol = esptool
lib_deps =
fastled/FastLED @ ~3.6.0
https://github.com/PolarRobotics/PR-Lib.git
adafruit/Adafruit PWM Servo Driver Library @ ^3.0.2
https://github.com/PolarRobotics/PR-Lib.git#add-pwm-module #dependent on Adafruit PWM Servo Driver Library
adafruit/Adafruit LIS3MDL@^1.2.4
extra_scripts = pre:pio_build_script.py

Expand All @@ -26,6 +27,8 @@ build_src_filter =
+<*>
-<Pairing/depairingStation.cpp>
-<Pairing/getAddress.cpp>
-<.pio\libdeps\robot\PR-Lib\src\MotorInterface.h>
-<.pio\libdeps\robot\PR-Lib\src\MotorInterface.cpp>
-<Robot/Quarterback_old.cpp>
-<Utilities/ReadBotInfo.cpp>
-<Utilities/WriteBotInfo.cpp>
Expand Down
2 changes: 2 additions & 0 deletions src/PolarRobotics.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#define M2_PIN 33 // | rightMotor | rightFront |
#define M3_PIN 26 // | N/A | leftRear |
#define M4_PIN 27 // | N/A | rightRear |
#define PWM0_PIN 0
#define PWM1_PIN 1

// Pins for special bot features, conveyor, flywheels, etc...
#define SPECBOT_PIN1 18
Expand Down
1 change: 0 additions & 1 deletion src/Robot/Kicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#ifndef KICKER_H
#define KICKER_H

#include <MotorInterface.h>
#include <Robot/Robot.h>
#include <ps5Controller.h> // ESP PS5 library, access using global instance `ps5`
#include <Utilities/Debouncer.h>
Expand Down
4 changes: 1 addition & 3 deletions src/Robot/MotorControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ MotorControl::MotorControl() {
lastRampTime = millis();
}



/**
* @brief setup the given pin to the next free channel, returns channel number or 255 if failure
* @author Rhys Davies
Expand All @@ -64,7 +62,7 @@ uint8_t MotorControl::setup(int mot_pin, MotorType type, bool has_encoder, float
this->enc_a_pin = enc_a_chan_pin, this->enc_b_pin = enc_b_chan_pin;

// Calculate the max rpm by multiplying the nominal motor RPM by the gear ratio
this->max_rpm = int(MOTOR_MAX_RPM_ARR[static_cast<uint8_t>(this->motor_type)] * this->gear_ratio);
this->max_rpm = uint16_t(MOTOR_MAX_RPM_ARR[static_cast<uint8_t>(this->motor_type)] * this->gear_ratio);

// call the logic to attach the motor pin and setup, return 255 on an error
return Motor.attach(mot_pin, MIN_PWM_US, MAX_PWM_US);
Expand Down
11 changes: 6 additions & 5 deletions src/Robot/MotorControl.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include <Arduino.h>
// #include <Robot/PWM_Module.h>
#include <PolarRobotics.h>
// #include <MotorInterface.h>
#include <MotorInterface.h>
#include <PWM_Module.h>
//#include <MotorInterface.h>


// Enum for Increasing or Decreasing Flywheel Speed
Expand All @@ -17,8 +18,8 @@ class MotorControl {
float gear_ratio; // the input / output gear ratio

// Servo:
MotorInterface Motor;

//MotorInterface Motor;
PWM_Module Motor;
// for ramp
float requestedRPM;
float lastRampTime;
Expand All @@ -42,7 +43,7 @@ class MotorControl {
float omega;

public:
int max_rpm; // the motor max rpm * the gear ratio
uint16_t max_rpm; // the motor max rpm * the gear ratio
MotorControl();
uint8_t setup(int mot_pin, MotorType type = big_ampflow, bool has_encoder = false, float gearRatio = 1, int enc_a_chan_pin = -1, int enc_b_chan_pin = -1); // if no encoder, leave blank, will not attach pins

Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void setup() {
default: // Assume lineman
robot = new Lineman();
drive = new Drive(lineman, driveParams);
drive->setupMotors(M1_PIN, M2_PIN);
drive->setupMotors(PWM0_PIN, PWM1_PIN);
}

// drive->printSetup();
Expand Down Expand Up @@ -229,7 +229,7 @@ void loop() {
robot->action();

// DEBUGGING:
// drive->printDebugInfo(); // comment this line out to reduce compile time and memory usage
drive->printDebugInfo(); // comment this line out to reduce compile time and memory usage
// drive->printCsvInfo(); // prints info to serial monitor in a csv (comma separated value) format
// lights.printDebugInfo();

Expand Down