Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   OCCRA Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=181)
-   -   [OCCRA]: OCCRA Software Template for RobotC (http://www.chiefdelphi.com/forums/showthread.php?t=151592)

jimk3038 29-09-2016 11:27

[OCCRA]: OCCRA Software Template for RobotC
 
Did I hear there is a software template for RobotC and OCCRA? Can I assume this is a C skeleton for basic robot control? Or, do I have this completely wrong? If yes, where I can I find this source code skeleton / template.

Thanks,
Jim Kemp
Benzene Bots

pjt0620 29-09-2016 16:31

Re: [OCCRA]: OCCRA Software Template for RobotC
 
Here is a simple example of a tank drive with the left motor being on pwm 1 and the right motor being on pwm 2
Code:

/*
Basic OCCRA Tank drive example
Disclaimer: Not tested due to lack of cortex
*/
#pragma platform(VEX2) //This is to tell the compiler that you are using the cortex
#pragma competitionControl(Competition) //This tells the compiler that your robot will have to listen to the field for when it can go
#include "Vex_Competition_Includes.c" //This is telling it how the field will talk to it

//Here we assign variables to more friendly names
int leftMotor = port1;
int rightMotor = port2;
//Refrence guide for controler at http://www.robotc.net/wikiarchive/VEX2_Functions_Remote_Control_-_VEXnet
int leftJoystick = Ch3;
int rightJoystick = Ch2;
//End of declarations



void pre_auton(){}//This is a function used to set up tasks before the match
task autonomous(){}//This is a function used for an autonomous mode, OCCRA does not have autonomous modes so ignore this function
task usercontrol()//When the match begins the field tells the cortex to run the code in this function
{
        while (true) //This function tells your robot to keep running the code inside this loop
        {
                motor[leftMotor] = vexRT[leftJoystick]; //Here we set the speed of the left motor, -127 being full reverse 0 being neutral and 127 being full forward to the left joysticks output
                motor[rightMotor] = vexRT[rightJoystick]; //Here we set the speed of the right motor, -127 being full reverse 0 being neutral and 127 being full forward to the right joysticks output
        }
}



All times are GMT -5. The time now is 21:44.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi