Coding Conversion

Anyone think they can help me covert the following RobotC code into PROS? Sorry, if this is a bother but I have never used v5 until now and I would really appreciate if someone could help me. Thanks.

#pragma config(Motor, port1, right1, tmotorVex393_HBridge, openLoop, reversed, driveRight)
#pragma config(Motor, port2, right2, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port3, right3, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port4, puncher, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, inTake2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, inTake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, adjust, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, left3, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port9, left2, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port10, left1, tmotorVex393_HBridge, openLoop, driveLeft)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

/---------------------------------------------------------------------------/
/* /
/
Description: Competition template for VEX EDR /
/
/
/
---------------------------------------------------------------------------*/

// This code is for the VEX cortex platform
#pragma platform(VEX2)

// Select Download method as “competition”
#pragma competitionControl(Competition)

//Main competition background code…do not modify!
#include “Vex_Competition_Includes.c”

/---------------------------------------------------------------------------/
/* 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 cortex has been powered on and /
/
not every time that the robot is disabled. /
/
---------------------------------------------------------------------------*/

void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks
// running between Autonomous and Driver controlled modes. You will need to
// manage all user created tasks if set to false.
bStopTasksBetweenModes = true;

// Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
// used by the competition include file, for example, you might want
// to display your team name on the LCD in this function.
// bDisplayCompetitionStatusOnLcd = false;

// 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. /
/
---------------------------------------------------------------------------*/

task autonomous()
{
motor[left1] = 115;
motor[left2] = 115;
motor[left3] = 115;
motor[right1] = 115;
motor[right2] = 115;
motor[right3] = 115;
wait1Msec(1400);
motor[left1] = -115;
motor[left2] = -115;
motor[left3] = -115;
motor[right1] = -115;
motor[right2] = -115;
motor[right3] = -115;
wait1Msec(600);
motor[left1] = 0;
motor[left2] = 0;
motor[left3] = 0;
motor[right1] = 0;
motor[right2] = 0;
motor[right3] = 0;

}

/---------------------------------------------------------------------------/
/* /
/
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. /
/
---------------------------------------------------------------------------*/

task usercontrol()
{
// User control code here, inside the loop

while (true)
{
//Drive

	int leftDrive = vexRT[Ch3];
	int rightDrive  = vexRT[Ch2];
	motor[left1] = leftDrive;
	motor[left2] = leftDrive;
	motor[left3] = leftDrive;


motor[right1] = rightDrive;
motor[right2] = rightDrive;
motor[right3] = rightDrive;


//Lift
//if(vexRT[Btn6U]==1)
	//{
		//motor[liftMech] = 100;
	//}
	//else
	//{
		//motor[liftMech] = 0;
	//}
	//if(vexRT[Btn6D]==1)
	//{
		//motor[liftMech] = -127;
	//}
	//else
	//{
		//motor[liftMech] = 0;
	//}

	//Intake

//int in_Take = vexRT[Btn7U];
//motor[inTake] = in_Take;
//motor[inTake] = in_Take;

	if(vexRT[Btn7U] ==1)
	{
		motor[inTake] = 127;
	}
	if(vexRT[Btn7R] == 1)
	{
		motor[inTake] = 127;
	}
	else
	{
		motor[inTake] = 0;
	}
	if(vexRT[Btn7D] ==1)
	{
		motor[inTake2] = 127;
	}
	if(vexRT[Btn7L] ==1)
	{
		motor[inTake2] = -127;
	}
	else
	{
		motor[inTake2] = 0;
	}

	//Shooter
	if (vexRT[Btn8U] ==1)
	{
		motor[adjust] = 75;
	}
	if(vexRT[Btn8R] ==1)
	{
		motor[adjust] = -50;
	}
	else
	{
		motor[adjust] = 0;
	}
	if (vexRT[Btn8D] ==1)
	{
		motor[puncher] = -127;
	}
	else
	{
		motor[puncher] = 0;
	}

}
}

Take a look at this.

Conversion is fairly straightforward
That was for the cortex so the PROS API has changed a little, but you will get the idea.

2 Likes

Thanks so much. This helped a lot.