|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
[FTC]: Autonomous
At my team's first competition nobodies autonomous code seemed to work. We believe the field managment system was at fault. Our code worked when we ran it on the field managment system we downloaed. Anyone have something similar happen? If not could someone possibly post their autonomous code or at least something that worked at competition for them?
|
|
#2
|
||||
|
||||
|
Re: [FTC]: Autonomous
I have a couple of questions:
1. Did your team use the latest software templates from the www.ftctraining.com web site? 2. Did your team start the autonomous program running on the NXT after it was placed on the playing field? 3. Did the robot behave as expected during the tele-op portion of the match? 4. Which programming language did you use? 5. Could you post a copy of your code? Michael |
|
#3
|
||||
|
||||
|
Re: [FTC]: Autonomous
Yes we used the latest templates (they worked with our software following the setup process that the competition used too)
yes we started the autonomous code manually ( we had it working with our software) tele-op went smoothly program in robotC (side note - only two or three teams there had autonomous code that worked. every other team's robot just sat there during autonomous, but they may not have even tried to use autonomous) |
|
#4
|
|||
|
|||
|
Re: [FTC]: Autonomous
We have competed in VA in December and Delaware on Jan 31. Our autonomous has always started. We use LabView however. I know in Delaware teams used RobotC in autonomous successfully.
One thing we did was to arrive the night before and check out our code while the tournament organizers checked out their field. It was a win-win situation. |
|
#5
|
||||
|
||||
|
Re: [FTC]: Autonomous
1. Did you install the new JoystickDriver.c file?
2. I will check the ROBOTC code of you post a copy. I would like to see the autonomous and tele-op files so that I can verify that the motor and servo settings are the same in both files. Michael |
|
#6
|
||||
|
||||
|
Re: [FTC]: Autonomous
I don't have the teleop code, it is on a laptop that stays at my school. I worked on the autonomous code primarily. This is what ours looked like..
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none) #pragma config(Sensor, S3, , sensorTouch) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Servo, srvo_S1_C3_1, ser1, tServoNormal) #pragma config(Servo, srvo_S1_C3_2, ser2, tServoNormal) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// const tSensors touchSensor = (tSensors)S3; ///////////////////////////////////////////////////////////////////////////////////////////////////// // // Autonomous Mode Code Template // // This file contains a template for simplified creation of an autonomous program for an FTC // competition. // // You need to customize two functions with code unique to your specific robot. // ///////////////////////////////////////////////////////////////////////////////////////////////////// #include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages. ///////////////////////////////////////////////////////////////////////////////////////////////////// // // initializeRobot // // Prior to the start of autonomous mode, you may want to perform some initialization on your robot. // Things that might be performed during initialization include: // 1. Move motors and servos to a preset position. // 2. Some sensor types take a short while to reach stable values during which time it is best that // robot is not moving. For example, gyro sensor needs a few seconds to obtain the background // "bias" value. // // In many cases, you may not have to add any code to this function and it will remain "empty". // ///////////////////////////////////////////////////////////////////////////////////////////////////// void initializeRobot() { // Place code here to sinitialize servos to starting positions. // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize. return; } ///////////////////////////////////////////////////////////////////////////////////////////////////// // // Main Task // // The following is the main code for the autonomous robot operation. Customize as appropriate for // your specific robot. // // The types of things you might do during the autonomous phase (for the 2008-9 FTC competition) // are: // // 1. Have the robot follow a line on the game field until it reaches one of the puck storage // areas. // 2. Load pucks into the robot from the storage bin. // 3. Stop the robot and wait for autonomous phase to end. // // This simple template does nothing except play a periodic tone every few seconds. // // At the end of the autonomous period, the FMS will autonmatically abort (stop) execution of the program. // ///////////////////////////////////////////////////////////////////////////////////////////////////// task main() { initializeRobot(); waitForStart(); // Wait for the beginning of autonomous phase. //variables int moveforwarddone = 0; //flag for once done moving forward short startTime; //time at start of loops int turnleftdone = 0; //flag for once done turning left int turnrightdone = 0; //flag for once done turning right int liftarmdone = 0; //flag for once done lifting arm int lowerarmdone = 0; //flag for once done lowering arm int reversedone = 0; //flag for once done reversing robot short pulleymotor1; //motor variable that assists servos short pulleymotor2; //motor variable that assists servos /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //// //// //// Add your robot specific autonomous code here. //// //// //// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// while (true) { startTime = (short)nPgmTime; //set the program time back to 0 while(nPgmTime < startTime + 3000) //approximate distance from wall needed to turn { //while the sensor reads more than 13 cm. away from wall move forward full speed motor[motorD] = 127; motor[motorE] = -128; moveforwarddone = 1; } // turn robot left if(moveforwarddone == 1) { startTime = (short)nPgmTime; while(nPgmTime < startTime + 500) // change to compass sensor -- need to get bearings once we get to competition location { motor[motorD] = 127; //full speed with right wheel(make sure right wheel is motor A) motor[motorE] = 127; //full reverse left wheel (make sure the left wheel is motor B) } turnleftdone = 1; moveforwarddone = 0; //reset moveforward done } //move robot towards the trough (3' 5.5") about 106 cm. NEED TO TEST PROBABLY HAVE TO RUN FOR TIME if(turnleftdone == 1) { startTime = (short)nPgmTime; //set the program time back to 0 while(nPgmTime < startTime + 2000) //may need to lower or increase the amount of time for raising arms { motor[motorD] = 127; //move forward maximum speed motor[motorE] = -128; } turnleftdone = 0; //reset turnleftdone moveforwarddone = 1; //move forward done == 1 after bot reaches required position } //turn back to original position if(moveforwarddone == 1) { startTime = (short)nPgmTime; //set the program time back to 0 while(nPgmTime < startTime + 250) // run while heading != original heading (forward) { motor[motorD] = -128; //full reverse with right wheel motor[motorE] = -128; //full speed with left wheel } turnrightdone = 1; moveforwarddone = 0; //reset moveforward done } //lift arm to necessary hight (20.75") raise for time if(turnrightdone == 1) { startTime = (short)nPgmTime; while(nPgmTime < startTime + 2000) // make pulleymotors lift to assist servos { motor[pulleymotor1] = 127; motor[pulleymotor2] = 127; } servo[ser1] = 80; //make both servos lift the arm at maximum speed servo[ser2] = 175; liftarmdone = 1; moveforwarddone = 0; //reset move forward done } //move robot towards the wall to get arm close enough if(liftarmdone == 1) { startTime = (short)nPgmTime; //set the program time back to 0 while(nPgmTime < startTime + 250) //approximate distance from wall needed to turn { //while the sensor reads more than 13 cm. away from wall move forward full speed motor[motorD] = 127; motor[motorE] = -128; } liftarmdone = 0; //reset lift arm moveforwarddone = 1; } //lower arm if near a wall if(moveforwarddone == 1) { startTime = (short)nPgmTime; while(nPgmTime < startTime + 2000) // make pulleymotors lower { motor[pulleymotor1] = -128; motor[pulleymotor2] = -128; } servo[ser1] = 0; //make both servos lower the arm at maximum speed servo[ser2] = 255; lowerarmdone = 1; moveforwarddone = 0; //reset move forward done } //turn robot so that back faces straight towards the scoring area if(lowerarmdone == 1) { startTime = (short)nPgmTime; //set the program time back to 0 while(nPgmTime < startTime + 150) // run while heading != original heading (about 20 degrees) { motor[motorD] = -128; //full reverse with right wheel motor[motorE] = -128; //full speed with left wheel } turnleftdone = 1; lowerarmdone = 0; //reset lower arm done } //reverse robot to scoring area if(turnleftdone == 1) { while(SensorValue[touchSensor] < 100 ) // run while touch sensor is not pushed in { motor[motorD] = -128; //full reverse with right wheel motor[motorE] = 127; //full reverse with left wheel } turnleftdone = 0; //reset lower are done reversedone = 1; } //score pucks until time runs out if(reversedone == 1) { startTime = (short)nPgmTime; while(nPgmTime < startTime + 2000) // make pulleymotors lift to assist servos { motor[pulleymotor1] = 127; motor[pulleymotor2] = 127; } servo[ser1] = 110; //raise arm at full speed servo[ser2] = 145; } } } |
|
#7
|
||||
|
||||
|
Re: [FTC]: Autonomous
I adjusted the code to work with a simple test setup of an NXT connected to two NXT DC motors. I implemented the changes below and tested them with the Field Management System. I didn't test the servo code, however, you will be able to do this on your robot after making the following changes:
1. startTime should be declared "long", not "short". nPgmTime starts counting when the program starts on the NXT. By the time all four robots are on the field and ready to go and the Field Management System starts the autonomous mode, nPgmTime is a very large number, exceeding the range of the short variable startTime. You can observe the value of nPgmTime (scaled to seconds) in the System Parameters Debug Window while executing the program inside ROBOTC. Also, see next item 2 below. 2. Remove "(short)" in the code where startTime = (short)nPgmTime; 3. Reduce the maximum motor commands. The HiTechnic and NXT motors have a range of -100 to +100. 4. pulleymotor1 and pulleymotor2 are not declared in the Motor Setup. From the ROBOTC task bar select: Robot --> Motors and Sensors Setup. Select the Motors tab and assign pulleymotor1 and pulleymotor2 to a Port. 5. The autonomous code will continue to loop [run again] unless you add a "StopAllTaks():" after the last while loop. 6. Set motor commands to zero when leaving motor and servo while loops. Create a function such as: void stopMotors() { motor[motorD] = 0; motor[motorE] = 0; } You can implement a similar function if you want to stop servo movement: void stopServos() { servoTarget[servo1] = ServoValue[servo1]; } Replace "servo1" with the name of your servo. Call the appropriate function(s) after exiting a while loop. 7. Add the stopMotors(); and stopServos(); function calls to the initialization section of the autonomous program. See "void Initialize Robot()" towards the top of the program code. Michael |
|
#8
|
||||
|
||||
|
Re: [FTC]: Autonomous
Thank you for all of those points. I had thought of several, but forgot to fix them in my code.
|
|
#9
|
||||
|
||||
|
Re: [FTC]: Autonomous
OK I HAD A PROBLEM WITH RUNNING AUTONOMOUS, BUT I FIXED IT...
DOWNLOAD THE AUTONOMOUS FIRST THEN DOWNLOAD TELEOP... CONNECT TO THE FMS THEN RUN AUTONOMOUS... WHEN THE AUTONOMOUS RUNS (on the FMS) IT'LL RUN AUTONOMOUS THEN IT'LL SWITCH TO AUTONOMOUS AUTONOMOUS WILL STILL BE SHOWN AS TELEOP THOUGH yeah I had a huge problem and i couldn't delete my post, so i decided to post MY solution Quote:
Last edited by nate15810 : 19-02-2009 at 13:08. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [FTC]: FTC Controller Station Connectivity (Bluetooth and USB) Issue | jbbjjbt | FIRST Tech Challenge | 6 | 05-11-2008 11:49 |
| [FTC]: Rookie Team Needs Help With Tetrix FTC Kit! | rjustice4 | FIRST Tech Challenge | 8 | 05-10-2008 09:44 |
| [FTC]: FTC]: FTC Champ Tournament - Ontario (Scoring Breakdown) | Mr. Lim | FIRST Tech Challenge | 2 | 03-03-2008 11:54 |
| Video: FTC 3 Cloverfield Autonomous | Synergy1848 | Robot Showcase | 0 | 26-02-2008 14:34 |
| [FTC]: [FTC]: Ontario Provincial FTC Start/End Times | cbhl | FIRST Tech Challenge | 8 | 16-12-2007 13:37 |