View unanswered posts | View active topics It is currently Sun Jul 31, 2016 1:29 am

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Autonomous mode
Author Message
Rookie

Joined: Fri Jan 11, 2013 4:58 pm
Posts: 2
Autonomous mode
I am currently on a rookie team, and my team and i are trying to use autonomous mode, and to be honest, are failing. We have a while loop and have it able to go forward, but i can't get it to stop until the time is up. I think this is because i dont know how to stop a while loop. This is the progam i am using i can use any help u can give me.

Fri Jan 11, 2013 5:02 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: Autonomous mode
Please read / view the relevant topics in the instructional pages and videos:
Text: http://www.robotc.net/education/curriculum/nxt/
Webinars: http://www.robotc.net/education/webinars/

_________________
sudo rm -rf /

Fri Jan 11, 2013 5:32 pm
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: Autonomous mode
 valleyrobotics wrote:I am currently on a rookie team, and my team and i are trying to use autonomous mode, and to be honest, are failing. We have a while loop and have it able to go forward, but i can't get it to stop until the time is up. I think this is because i dont know how to stop a while loop. This is the progam i am using i can use any help u can give me.

First, the valid motor power range is between -100 to 100. Your code is assigning 10000 as the motor power. That's way too big. Secondly, what do you want to use to determine how to stop the robot? There are many ways to do autonomous:
- Most commonly, people do dead-reckoning (basically timed drive). You turn the motor on for a set time period and turn it off. For example:
 Code:// Run the left and right motor for 2 seconds and then stop.motor[left] = 50;motor[right] = 50;wait1Msec(2000);motor[left] = 0;motor[right] = 0;

- You can also do autonomous with feedback from sensors. For driving the robot, you typically use the encoders for determining the distance of the drive and the gyro to determine the heading of the robot. How precise do you want to control the robot? If you want really precise, you may need to use PID control (i.e. slow down when you are approaching your target). Many people typically do not use PID control, so they will just read the sensors and stop when you reach or exceed the target distance (or heading) such as the following:
 Code:nMotorEncoder[left] = 0;nMotorEncoder[right] = 0;while (true){    if ((nMotorEncoder[left] + nMotorEncoder[right])/2 < TARGET_DISTANCE)    {        motor[left] = 50;        motor[right] = 50;    }    else    {        motor[left] = 0;        motor[right] = 0;    }}

Whereas PID control can slow down and even go backward to make sure you are on-target precisely. But tuning PID constants is very tedious. See my previous thread on the subject.
viewtopic.php?f=52&t=3152

Fri Jan 11, 2013 9:29 pm
Rookie

Joined: Fri Jan 11, 2013 4:58 pm
Posts: 2
Re: Autonomous mode
thanks that should help, and someone must have changed the motor speed while i was away, but i will be using time, and is a while loop required if not i will take it out.

Sun Jan 13, 2013 11:10 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning