I am trying to get the following code to compile. I need to make motors on ports 1 & 2 to spin forward with controller axis 3, and a motor on port 3 to spin with axis 1. I want these motors to be reversible(go backwards when the joystick does). My code also reads the temperature of the battery and motors and reports them to the controller, making it rumble when one of them surpasses 75%
Begin Code:
#include “robot-config.h”
int ForwardSpeed = 0;
int LeftRight = 0;
double motor1temp = 0;
double motor2temp = 0;
double motor3temp = 0;
double batterytemp = 0;
int main()
{
getcontroller();
drive();
Controller1.ButtonUp.pressed(diagnosticscheck());
}
int getcontroller()
{
ForwardSpeed = controller.Axis3.value();
LeftRight = controller.axis1.value();
}
int drive()
{
Motor1.spin(directionType::fwd, ForwardSpeed, velocityUnits::rpm);
Motor2.spin(directionType::fwd, ForwardSpeed, velocityUnits::rpm);
Motor3.spin(directionType::fwd, leftRight, velocityUnits::rpm);
}
int diagnosticscheck()
{
motor1temp = Motor1.temperature(percentUnits::pct);
motor2temp = Motor2.temperature(percentUnits::pct);
motor3temp = Motor3.temperature(percentUnits::pct);
batterytemp = Brain.Battery.temperature();
report();
}
int report()
{
Controller1.Screen.clearScreen();
Controller1.Screen.setCursor(1, 1);
Controller1.Screen.print(“Thermal Readings:”);
Controller1.Screen.newLine();
Controller1.Screen.print("Drive Motors: ", motor1temp, " - ", motor2temp);
Controller1.Screen.newLine();
Controller1.Screen.print("Steering Motor: ", motor3temp);
Controller1.Screen.newLine();
Controller1.Screen.print("Battery: ", batterytemp);
Controller1.Screen.newLine();
if (motor1temp > 75)
{
Controller1.rumble("..");
Controller1.Screen.print("Motor 1 overheating!");
}
else if (motor2temp > 75)
{
Controller1.rumble("..");
Controller1.Screen.print("Motor 2 overheating!");
}
else if (motor3temp > 75)
{
Controller1.rumble("..");
Controller1.Screen.print("Motor 3 overheating!");
}
else if (batterytemp > 75)
{
Controller1.rumble("..");
Controller1.Screen.print("Battery overheating!");
}
}
int screensetup ()
{
Controller1.Screen.clearScreen();
Controller1.Screen.print(“T-frame drive system online.”);
Controller1.Screen.clearScreen();
}
End Code.