I started coding my teams asterisk drive and when I tested it only the front left wheel (A1 on port 11) was spinning. All of the cords are plugged into the correct ports and when I run the default drive program all of the wheels spin.
I tried a different brain, system reset on both brains, copy and pasted the code into a new program, and redownloaded vscode on my laptop.
I also was able to add a display section to the user control loop but when I commented out all uses of A1 the program still ran A1 (at the correct speed), I then tried to just delete it and it kept running A1 (Yes I did confirm the new program downloaded).
I have no idea what the issue is as our sister teams coder, chat GPT, and Copilot all see no problems with the code (AI is usually good at finding stupid mistakes I miss).
This is all of the code but hopefully all you need is above the motor struct and in the user control loop. My apologize for the lack of comments.
#include "vex.h"
using namespace vex;
competition Competition;
controller cont = controller(primary);
motor A1 = motor(11, true);
motor B1 = motor(15, true);
motor C1 = motor(20, true);
motor A2 = motor(10, false);
motor B2 = motor(5, false);
motor C2 = motor(1, false);
#define CX1 cont.Axis4.position(percent)
#define CX2 cont.Axis1.position(percent)
#define CY1 cont.Axis3.position(percent)
#define CY2 cont.Axis2.position(percent)
struct Motor
{
int e = 0;
int f = 0;
int g = 0;
int h = 0;
int i = 0;
int P = 0;
int I = 0;
int D = 0;
int PID()
{
h = e;
e = g - i;
P = e * .1;
if (abs(e) < 45)
{
I = (e + I) * .1;
}
else
{
I = 0;
}
D = (h - e) * .1;
f = P + I + D;
return f;
};
};
Motor a1;
Motor a2;
Motor b1;
Motor b2;
Motor c1;
Motor c2;
void move(int x, int y, int z)
{
A1.setPosition(0, degrees);
A2.setPosition(0, degrees);
B1.setPosition(0, degrees);
B2.setPosition(0, degrees);
C1.setPosition(0, degrees);
C2.setPosition(0, degrees);
a1.g = ((y + x) * (360 * sin(45))) + (z * 18.1 * 90);
a2.g = ((y + x) * (360 * sin(45))) - (z * 18.1 * 90);
b1.g = ((y * 360 * sin(45)) + (z * 13.8 * 90)) * (5 / 7);
b2.g = ((y * 360 * sin(45)) - (z * 13.8 * 90)) * (5 / 7);
c1.g = ((y - x) * (360 * sin(45))) + (z * 18.1 * 90);
c2.g = ((y - x) * (360 * sin(45))) - (z * 18.1 * 90);
do
{
a1.i = A1.position(degrees);
a2.i = A2.position(degrees);
b1.i = B1.position(degrees);
b2.i = B2.position(degrees);
c1.i = C1.position(degrees);
c2.i = C2.position(degrees);
A1.spin(forward, a1.PID(), percent);
A2.spin(forward, a2.PID(), percent);
B1.spin(forward, b1.PID(), percent);
B2.spin(forward, b2.PID(), percent);
C1.spin(forward, c1.PID(), percent);
C2.spin(forward, c2.PID(), percent);
wait(20, msec);
} while (abs(a1.e) + abs(a2.e) + abs(b1.e) + abs(b2.e) + (abs(c1.e) + abs(c2.e)) > 20);
A1.stop();
A2.stop();
B1.stop();
B2.stop();
C1.stop();
C2.stop();
}
void pre_auton(void)
{
A1.setPosition(0, degrees);
A2.setPosition(0, degrees);
B1.setPosition(0, degrees);
B2.setPosition(0, degrees);
C1.setPosition(0, degrees);
C2.setPosition(0, degrees);
}
void autonomous(void)
{
move(10, 20, 45);
move(-20, -10, 90);
}
void usercontrol(void)
{
A1.spin(forward, 0, percent);
A2.spin(forward, 0, percent);
B1.spin(forward, 0, percent);
B2.spin(forward, 0, percent);
C1.spin(forward, 0, percent);
C2.spin(forward, 0, percent);
while (1)
{
A1.setVelocity(CY1 + CX1 + CX2, percent);
A2.setVelocity(CY1 + CX1 - CX2, percent);
B1.setVelocity(CY1 + ((13.8 * 5) / (18.1 * 7)) * CX2, percent);
B2.setVelocity(CY1 - ((13.8 * 5) / (18.1 * 7)) * CX2, percent);
C1.setVelocity(CY1 - CX1 + CX2, percent);
C2.setVelocity(CY1 - CX1 - CX2, percent);
wait(20, msec);
}
}
int main()
{
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
pre_auton();
while (true)
{
wait(100, msec);
}
}