Modkit to EDR Competition Template, will this work?


#1

After reading some forum posts, I now realize that the Modkit does not supported the EDR competition template. I saw a good post about this and switching the code from Modkit to RobotMesh. But, if what I laid out below works, then I think we can make an easier transition to VEX C++. We are looking at using the VEX C++ because it has a competition template and the Robot configuration tabs are the same for both the Modkit and VEX C++. (Moving to a full C++ language is a step too far for us this year.)

Will this work? Can we switch our Modkit’s Blocks to {M}Text for both the 15 sec Autonomous program and Usercontrol programs, and then copy them into the VEX C++’s Competition template?

For an example, I copied the {M}Text to MS Word, and then copied it into VEX C++’s Competition Template. When I did it, I noticed that the vertical separation and the tab’ing of the code disappeared. Each “WHEN” Control statement became a single sentence. Is this a problem? Is there anything else that we should lookout for? An example of the program for the Usercontrol section looks like:

void usercontrol( void ) {
// User control code here, inside the loop
while (1){
// 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.

when(STARTED){ LeftFront.setRotation(0,degrees); Release.setStopping(hold); Rotate.setStopping(hold); Tower.setStopping(hold); Tower2.setStopping(hold); Tower.setVelocity(20,percent); Tower2.setVelocity(20,percent); x1=0; Y1=0; X2=0;}

when(Controller1.ButtonLeft.PRESSED){ Tower.startRotateTo(375,degrees); Tower2.startRotateTo(375,degrees);}

… plus several other additional “WHEN” Control statements that are not necessary to document this process

// ........................................................................

Thanks in advance,
David


#2

The “WHEN” event system is not supported by C++, it’s specific to Modkit, so direct conversion of a Modkit project to C++ is not possible (unless lots of Modkit library code is also added and that’s not possible with VCS).


#3

Jpearman,

From your response, I was really concerned that we would not be able to translate the code from Modkit to VEX C++ in time. But, it really was not that hard. It was mainly syntax changes. A guy at work told me not to use MS Word as a text editor because it loses all the C++ formatting. He suggested I use any regular text editor. My computer has WordPad as one of the text editors and it worked great. The “Find and Replace” command was especially useful and made the whole job relatively easy. We were able to swap the WHEN commands out with an IF statement. For the WHEN Start command, we placed everything in a forever loop with a “while(1==1) {” statement.

Thank you for help!! Your comments have been most insightful.


For the others in the same boat, here are the syntax changes we had to do. This should help you get started. (When I typed this and now editing this post, everything below was nicely spaced. Just look for the semicolon to see the division between the two syntax.)

Modkit Program Code; VEX C++ Program Code

LeftFront.setRotation(0,degrees); LeftFront.resetRotation();
LeftFront.setStopping(hold); LeftFront.setStopping(brakeType::hold);
LeftFront.setVelocity(25,percent); LeftFront.setVelocity(50,velocityUnits::pct);
LeftFront.rotateFor(90,degrees); LeftFront.rotateFor(90,rotationUnits::deg);
LeftFront.rotation(degrees) LeftFront.rotation(rotationUnits::deg)
LeftFront.spin(forward); LeftFront.spin(directionType::fwd);
RightRear.spin(reverse); RightRear.spin(directionType::rev);
wait(.05,seconds); task::sleep(50);
X1=0; Int x1=0
x1=Controller1.Axis4.position(percent); x1=Controller1.Axis4.position(percentUnits::pct);
when(Controller1.ButtonL1.PRESSED){ if (Controller1.ButtonL1.PRESSED){
When(Controller1.Axis2.CHANGED){ if(Controller1.Axis2.value()!= 0){

Tower.setVelocity(100,velocityUnits::pct);
Tower.startRotateTo(575,degrees); Tower.rotateTo(575,rotationUnits::deg,100,velocityUnits::pct);

Thanks,
DavidC