yea but would this work for people who are already using an arcade drive code?
*----------------------------------------------------------------------------*/
/* /
/ Module: main.cpp /
/ Author: VEX /
/ Created: Thu Sep 26 2019 /
/ Description: Competition Template /
/ /
/----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----
#include “vex.h”
using namespace vex;
// A global instance of competition
competition Competition;
vex::motor motor_right= vex::motor(vex::PORT19);
vex::motor motor_left=vex::motor(vex::PORT20);
vex::motor Hand1 = vex::motor(vex::PORT11);
vex::motor Hand2 = vex::motor(vex::PORT12);
vex::motor tail =vex::motor(vex::PORT13);
vex::controller con(vex::controllerType::primary);
// define your global instances of motors and other devices here
/---------------------------------------------------------------------------/
/* Pre-Autonomous Functions /
/ /
/ You may want to perform some actions before the competition starts. /
/ Do them in the following function. You must return from this function /
/ or the autonomous and usercontrol tasks will not be started. This /
/ function is only called once after the V5 has been powered on and /
/ not every time that the robot is disabled. /
/---------------------------------------------------------------------------*/
void pre_auton(void) {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, …
}
/---------------------------------------------------------------------------/
/* /
/ Autonomous Task /
/ /
/ This task is used to control your robot during the autonomous phase of /
/ a VEX Competition. /
/ /
/ You must modify the code to add your own robot specific commands here. /
/---------------------------------------------------------------------------*/
void autonomous(void) {
motor_right.rotateFor(+1300, rotationUnits::deg, 30, velocityUnits::pct, false);
motor_left.rotateFor(-1300, rotationUnits::deg, 30, velocityUnits::pct,false);
Hand1.rotateFor(+6500,rotationUnits::deg,127,velocityUnits::pct,false);
Hand2.rotateFor(-6500,rotationUnits::deg,127,velocityUnits::pct);
motor_right.rotateFor(-900, rotationUnits::deg, 100, velocityUnits::pct, false);
motor_left.rotateFor(-900, rotationUnits::deg, 100, velocityUnits::pct);
motor_right.rotateFor(+1464, rotationUnits::deg, 40, velocityUnits::pct, false);
motor_left.rotateFor(-1464, rotationUnits::deg, 40, velocityUnits::pct);
tail.rotateFor(-1000,rotationUnits::deg,30,velocityUnits::pct);
wait(1000,msec);
tail.rotateFor(+500,rotationUnits::deg,10,velocityUnits::pct,false);
Hand1.rotateFor(-1000,rotationUnits::deg,40,velocityUnits::pct,false);
Hand2.rotateFor(+1000,rotationUnits::deg,40,velocityUnits::pct);
motor_right.rotateFor(-1000, rotationUnits::deg, 50, velocityUnits::pct, false);
motor_left.rotateFor(+1000, rotationUnits::deg, 50, velocityUnits::pct);
// Insert autonomous user code here.
// …
}
/---------------------------------------------------------------------------/
/* /
/ User Control Task /
/ /
/ This task is used to control your robot during the user control phase of /
/ a VEX Competition. /
/ /
/ You must modify the code to add your own robot specific commands here. /
/---------------------------------------------------------------------------*/
void usercontrol(void) {
// User control code here, inside the loop
while (1) {
while(true){
vexcodeInit();
//Left motor, vertical axis of left joystick plus horizontal axis of left joystick
motor_left.spin(vex::directionType::fwd,con
.Axis4.position(vex::percentUnits::pct) -con
.Axis3.position(vex::percentUnits::pct),
vex::velocityUnits::pct);
//Right motor, vertical axis of left joystick minus horizontal axis of left joystick
motor_right.spin(vex::directionType::fwd,con
.Axis4.position(vex::percentUnits::pct) +con
.Axis3.position(vex::percentUnits::pct),
vex::velocityUnits::pct);
// This is the main execution loop for the user control program.
//Elbow Motor
//Hand Motors
if (con.ButtonR1.pressing())
{
Hand1.spin(vex::directionType::fwd,127,vex::velocityUnits::rpm);
Hand2.spin(vex::directionType::rev,127,vex::velocityUnits::rpm);
}
else if (con.ButtonR2.pressing())
{
Hand1.spin(vex::directionType::rev,127,vex::velocityUnits::rpm);
Hand2.spin(vex::directionType::fwd,127,vex::velocityUnits::rpm);
}
else
{
Hand1.stop(vex::brakeType::coast);
Hand2.stop(vex::brakeType::coast);
}
if( con.ButtonA.pressing() )
{
motor_right.stop(vex::brakeType::hold );
motor_left.stop(vex::brakeType::hold );
}
else if( con.ButtonY.pressing())
{
motor_right.stop(vex::brakeType::coast );
motor_left.stop(vex::brakeType::coast );
}
if (con.ButtonB.pressing())
{
tail.spin(vex::directionType::fwd,60,vex::velocityUnits::rpm);
}
else if (con.ButtonX.pressing())
{
tail.spin(vex::directionType::rev,30,vex::velocityUnits::rpm);
}
else
{
tail.stop(vex::brakeType::hold );
}
}
} // This is the main execution loop for the user control program.
// Each time through the loop your program should update motor + servo
// values based on feedback from the joysticks.
// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................
wait(20, msec); // Sleep the task for a short amount of time to
// prevent wasted resources.
}
//
// Main will set up the competition functions and callbacks.
//
int main() {
// Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
// Run the pre-autonomous function.
pre_auton();
// Prevent main from exiting with an infinite loop.
while (true) {
wait(100, msec);
}
}