|
Rahman
Rookie
Joined: Sat Feb 26, 2011 11:18 pm Posts: 1
|
 FTC Autonomous period Programing
HI,
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....
HERE IS HOW I DID MY CODE
#pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Sensor, S2, top_touch_sensor, sensorTouch) #pragma config(Motor, motorB, betonarmright, tmotorNormal, PIDControl, encoder) #pragma config(Motor, motorC, betonarmleft, tmotorNormal, PIDControl, encoder) #pragma config(Motor, mtr_S1_C1_1, right_wheel, tmotorNormal, openLoop, reversed) #pragma config(Motor, mtr_S1_C1_2, left_wheel, tmotorNormal, openLoop) #pragma config(Servo, srvo_S1_C2_1, arm_servo_right, tServoStandard) #pragma config(Servo, srvo_S1_C2_2, arm_servo_left, tServoStandard) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
///////////////////////////////////////////////////////////////////////////////////////////////////// // // 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. // /////////////////////////////////////////////////////////////////////////////////////////////////////
#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.
motor[mtr_S1_C1_1] = 100; wait1Msec(5000); motor[mtr_S1_C1_2] = -100; wait1Msec(5000); //Now I want robot to turn right or left motor[mtr_S1_C1_1] = 100; wait1Msec(2000); motor[mtr_S1_C1_2] = 0; wait1Msec(2000); // Now NOw I want 2 NXT motors (same possision) to make a 2 turn motor [motorB]= 100 motor[motorC] = 100 wait1Msec(99000) // while NXT motors turns , I want robot to go straight until touch sensor pressed motor[mtr_S1_C1_1] = 100; wait1Msec(54000); motor[mtr_S1_C1_2] = -100; wait1Msec(54000); //I DONT KNOW HOW TO CODE TOUCH SENSOR...????? ROBOT WILL STOP WHEN TOUCH SENSOR PRESS AND nxt MOTORS WILL TURN UNLIMITED. while (true) {} }
|