View unanswered posts | View active topics It is currently Sat Aug 02, 2014 2:31 am






Reply to topic  [ 3 posts ] 
FTC Autonomous period Programing 
Author Message
Rookie

Joined: Sat Feb 26, 2011 11:18 pm
Posts: 1
Post 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)
{}
}


Mon Feb 28, 2011 11:54 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: FTC Autonomous period Programing
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
Profile
Rookie

Joined: Sun Dec 05, 2010 11:58 am
Posts: 28
Post 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.


Wed Mar 02, 2011 8:01 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.