I am trying to write a code for autonomous period. 1.I write a code but it did only first action it is not continue second action?2. I have 2 12 V motor for wheels , 2 NXT motors I want them turn unlimited , 2 Servo motors to open robot arm. I want robot run 5 second straight and turn right and go straight until touch sensor press and 2 NXT motors turn unlimited.I appreciate your help....

///////////////////////////////////////////////////////////////////////////////////////////////////////// Autonomous Mode Code Template//// This file contains a template for simplified creation of an autonomous program for an Tetrix robot// competition.//// You need to customize two functions with code unique to your specific robot.///////////////////////////////////////////////////////////////////////////////////////////////////////

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

Here is my understanding of you code. In other words, I don't know what you are trying to do.

Code:

task main(){ initializeRobot(); waitForStart(); // Wait for the beginning of autonomous phase. // // I don't understand this. You run the right wheel 100% power and left wheel at zero for 5 seconds. // This will cause the robot to turn left pivoting on the left wheel. // motor[mtr_S1_C1_1] = 100; wait1Msec(5000); // // From looking your code forward, I suspect you forgot to check "reverse" on your left wheel. So you really // meant to run the left wheel forward for 5 seconds. This means after turning left for 5 seconds, you now // run forward for another 5 seconds. // motor[mtr_S1_C1_2] = -100; wait1Msec(5000); // // Setting the right wheel to 100 changed nothing since the right motor was already at 100. // So you are still spinning left in place. So the robot continue forward for another 2 seconds. // motor[mtr_S1_C1_1] = 100; wait1Msec(2000); // // Now you stopped the left motor for 2 seconds, so the robot is now turning left pivoting on the left wheel. // motor[mtr_S1_C1_2] = 0; wait1Msec(2000); // // Now you are running the left and right arm motor for 99 seconds?! Not to mentioned you are missing a bunch // of semicolons at the end of the statements. And also the robot is still turning left in the mean time. motor [motorB]= 100; motor[motorC] = 100; wait1Msec(99000); // // This does not change anything because the right motor is already running at 100. // motor[mtr_S1_C1_1] = 100; wait1Msec(54000); // // Now you are running forward again for 54 seconds?! // motor[mtr_S1_C1_2] = -100; wait1Msec(54000); // // Now you are entering a never ending wait loop. // while (true) {}}

Mon Feb 28, 2011 1:36 pm

jorge_the_awesome

Rookie

Joined: Sun Dec 05, 2010 11:58 amPosts: 28

Re: FTC Autonomous period Programing

Also, at a couple points you wait for more than 32767 milliseconds. These functions take maximum values of 32767, according to the robotC documentation. Use wait10Msec and wait100Msec for longer times.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum