So, I’ve been trying to code 2 drivetrains , and i ended up getting this error, what should i do to fix this issue
This is the code
#include “vex.h”
using namespace vex;
using signature = vision::signature;
using code = vision::code;
brain Brain;
controller Controller1 = controller(primary);
controller Controller2 = controller(partner);
motor Leftlift = motor(PORT3, ratio6_1, false);
motor Rightlift = motor(PORT4, ratio6_1, true);
motor LeftDrive = motor(PORT1, ratio18_1, false);
motor RightDrive = motor(PORT2, ratio18_1, true);
drivetrain Drivetrain2 = drivetrain(LeftDrive, RightDrive, 219.44, 295, 165, mm, 1);
drivetrain Drivetrain = drivetrain(Leftlift, Rightlift, 219.44, 295, 165, mm, 1);
motor Motor5 = motor(PORT5, ratio18_1, false);
motor Motor6 = motor(PORT6, ratio18_1, true);
bool RemoteControlCodeEnabled = true;
bool Controller1RightShoulderControlMotorsStopped = true;
bool DrivetrainNeedsToBeStopped_Controller1 = true;
bool Drivetrain2NeedsToBeStopped_Controller1 = true;
int rc_auto_loop_callback_Controller1() {
while(true) {
if(RemoteControlCodeEnabled) {
int drivetrainLeftSideSpeed = Controller1.Axis3.position() + Controller1.Axis4.position();
int drivetrainRightSideSpeed = Controller1.Axis3.position() - Controller1.Axis4.position();
if (abs(drivetrainLeftSideSpeed) < 5 && abs(drivetrainRightSideSpeed) < 5) {
if (DrivetrainNeedsToBeStopped_Controller1) {
Leftlift.stop();
Rightlift.stop();
DrivetrainNeedsToBeStopped_Controller1 = false;
}
} else {
DrivetrainNeedsToBeStopped_Controller1 = true;
}
if (DrivetrainNeedsToBeStopped_Controller1) {
Leftlift.setVelocity(drivetrainLeftSideSpeed, percent);
Leftlift.spin(forward);
}
if (DrivetrainNeedsToBeStopped_Controller1) {
Rightlift.setVelocity(drivetrainRightSideSpeed, percent);
Rightlift.spin(forward);
}
if(RemoteControlCodeEnabled) {
int driveleft = Controller1.Axis1.position() + Controller1.Axis2.position();
int driveright = Controller1.Axis1.position() - Controller1.Axis2.position();
if (abs(driveleft) < 5 && abs(driveright) < 5) {
if (Drivetrain2NeedsToBeStopped_Controller1) {
LeftDrive.stop();
RightDrive.stop();
Drivetrain2NeedsToBeStopped_Controller1 = false;
}
} else {
Drivetrain2NeedsToBeStopped_Controller1 = true;
}
if (Drivetrain2NeedsToBeStopped_Controller1) {
LeftDrive.setVelocity(driveleft, percent);
LeftDrive.spin(forward);
}
if (Drivetrain2NeedsToBeStopped_Controller1) {
RightDrive.setVelocity(driveright, percent);
RightDrive.spin(forward);
}
if (Controller1.ButtonR1.pressing()) {
Motor5.spin(forward);
Motor6.spin(forward);
Controller1RightShoulderControlMotorsStopped = false;
} else if (Controller1.ButtonR2.pressing()) {
Motor5.spin(reverse);
Motor6.spin(reverse);
Controller1RightShoulderControlMotorsStopped = false;
} else if (!Controller1RightShoulderControlMotorsStopped) {
Motor5.stop();
Motor6.stop();
Controller1RightShoulderControlMotorsStopped = true;
}
}
wait(20, msec);
}
return 0;
}
}
void vexcodeInit( void ) {
task rc_auto_loop_task_Controller1(rc_auto_loop_callback_Controller1);
}
Attach the whole project (as a zip file). I added that code to a project and it builds without issue.
v5code-project-Controller.zip (12.1 KB)
sorry, i just realized i put this under blocks, i use text
yea, don’t include .cpp files in other .cpp files. remove this from main.cpp and it will build.
#include "robot-config.cpp"
To use the additional drivetrain, add the definition in the robot-config.h header file
So I was able to build it, but I wasn’t able to move my bot at all