so ive got my driver control program working now and i did some coding for the atonamous program and when i take the competition switch and switch it to aton and enabled it sits there and does nothing i dont know if i have to do an include for the main op control file but i wont be able to do an testing till monday or tuesday but from what i did testing two weeks ago it didnt take any reaction to what i was doing.
op control code:
/** @file opcontrol.c
* @brief File for operator control code
*
* This file should contain the user operatorControl() function and any functions related to it.
*
* Copyright (c) 2011-2014, Purdue University ACM SIG BOTS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Purdue University ACM SIG BOTS nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL PURDUE UNIVERSITY ACM SIG BOTS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Purdue Robotics OS contains FreeRTOS (http://www.freertos.org) whose source code may be
* obtained from http://sourceforge.net/projects/freertos/files/ or on request.
*/
#include "main.h"
/*
* Runs the user operator control code. This function will be started in its own task with the
* default priority and stack size whenever the robot is enabled via the Field Management System
* or the VEX Competition Switch in the operator control mode. If the robot is disabled or
* communications is lost, the operator control task will be stopped by the kernel. Re-enabling
* the robot will restart the task, not resume it from where it left off.
*
* If no VEX Competition Switch or Field Management system is plugged in, the VEX Cortex will
* run the operator control task. Be warned that this will also occur if the VEX Cortex is
* tethered directly to a computer via the USB A to A cable without any VEX Joystick attached.
*
* Code running in this task can take almost any action, as the VEX Joystick is available and
* the scheduler is operational. However, proper use of delay() or taskDelayUntil() is highly
* recommended to give other tasks (including system tasks such as updating LCDs) time to run.
*
* This task should never exit; it should end with some kind of infinite loop, even if empty.
*/
void operatorControl() {
// Declare inital values.
//Intial Movement Values.
int X2 = 0;
int Y1 = 0;
int X1 = 0;
int threshold = 7; //Declare Deadzone Limit to zero out all motors if not above.
// Inital Debugging Values.
int debugCtr = 0;
// Motor Port Values.
int frontright = 3;
int backright = 9;
int frontleft = 2;
int backleft = 8;
while(1){/*Loop Forever*/
//Declare Joysticks.
int leftStickUp = joystickGetAnalog(1, 4);
int leftStickLeft = joystickGetAnalog(1, 3);
int rightStickLeft = joystickGetAnalog(1, 1);
//Create "deadzone" for Y1/Ch3, Left Joystick Up and Down.
if(abs(leftStickUp) > threshold){
Y1 = leftStickUp; // If leftStickUp is above +/- 7 then Y1 = Joystick leftStickUp (position)
}else{
Y1 = 0;//If Joystick leftStickUp is below +/- 7 then Y1 = 0
}
//Create "deadzone" for X1/Ch4, Left Joystik Left and Right.
if(abs(leftStickLeft) > threshold){
X1 = leftStickLeft; //If Joystick leftstickLeft is above +/- 7 then X1 = Joystick leftStickLeft (position)
}else{
X1 = 0;//If Joystick leftStickLeft is below +/- 7 then X1 = 0
}
//Create "deadzone" for X2/Ch1, Right Joystick Left and Right.
if(abs(rightStickLeft) > threshold){
X2 = rightStickLeft;//If Joystick rightStickLeft is above +/- 7 then X2 = Joystick rightStickLeft (position)
}else{
X2 = 0;//If Joystick rightStickLeft is below +/- 7 then X2 = 0
}
//Math Logic for each Motor.
motorSet(frontright, -Y1 + X2 + X1);
motorSet(backright, Y1 + X2 + X1);
motorSet(frontleft, -Y1 + X2 - X1);
motorSet(backleft, Y1 + X2 - X1);
delay(20);//Required for any working program at the end of the program. in milliseconds?
//Debugging Command.
/* if( debugCtr++ == 5 ) //Display Y1, X1, X2 Values in PROS Terminal for debugging.
{
debugCtr = 0;
printf("drive vals %d %d %d\r\n", Y1, X1, X2 );
}*/
}
}
auto code:
/** @file auto.c
* @brief File for autonomous code
*
* This file should contain the user autonomous() function and any functions related to it.
*
* Copyright (c) 2011-2014, Purdue University ACM SIG BOTS.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Purdue University ACM SIG BOTS nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL PURDUE UNIVERSITY ACM SIG BOTS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Purdue Robotics OS contains FreeRTOS (http://www.freertos.org) whose source code may be
* obtained from http://sourceforge.net/projects/freertos/files/ or on request.
*/
#include "main.h"
/*
* Runs the user autonomous code. This function will be started in its own task with the default
* priority and stack size whenever the robot is enabled via the Field Management System or the
* VEX Competition Switch in the autonomous mode. If the robot is disabled or communications is
* lost, the autonomous task will be stopped by the kernel. Re-enabling the robot will restart
* the task, not re-start it from where it left off.
*
* Code running in the autonomous task cannot access information from the VEX Joystick. However,
* the autonomous function can be invoked from another task if a VEX Competition Switch is not
* available, and it can access joystick information if called in this way.
*
* The autonomous task may exit, unlike operatorControl() which should never exit. If it does
* so, the robot will await a switch to another mode or disable/enable cycle.
*/
void autonomous() {
// Motor Port Values.
int frontright = 3;
int backright = 9;
int frontleft = 2;
int backleft = 8;
void move(int Y1, int X1, int X2,int timeDelay){
//Math Logic for each Motor.
motorSet(frontright, -Y1 + X2 + X1);
motorSet(backright, Y1 + X2 + X1);
motorSet(frontleft, -Y1 + X2 - X1);
motorSet(backleft, Y1 + X2 - X1);
delay(timeDelay);//Required for any working program at the end of the program. in milliseconds?
}
move(0, 127, 0, 1 );
move(0, 0, 127, 0.25);
move(0, 127, 0, 3);
move(-50, -127, 0, 0.5);
move(0, -127, 0, 2);
move(0, 0, 0, 0);
}
any help is appreciated.