View unanswered posts | View active topics It is currently Wed Nov 26, 2014 12:07 am






Reply to topic  [ 4 posts ] 
Autonomous mode 
Author Message
Rookie

Joined: Fri Jan 11, 2013 4:58 pm
Posts: 2
Post 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.


Attachments:
autotest.c [3 KiB]
Downloaded 359 times
Fri Jan 11, 2013 5:02 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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
Profile
Guru
User avatar

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

Joined: Fri Jan 11, 2013 4:58 pm
Posts: 2
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.