Log in

View Full Version : Autonomous Driving


dboisvert
01-03-2009, 16:01
What our robot currently does is move around randomly.

This is that code

m_robotDrive->Drive(ajoysticky,aajx);
Wait(2.0);
aajx = aajx * .5;
m_robotDrive->Drive(ajoysticky,aajx);
Wait(3.0);
aajx = aajx * -.1;
m_robotDrive->Drive(ajoysticky,aajx);
Wait(4.0);
aajx = aajx * -.1;
m_robotDrive->Drive(ajoysticky,aajx);
Wait(6.0);
aajx = aajx * -.8;
m_robotDrive->Drive(ajoysticky,aajx);
Wait(5.0);
aajx = aajx * -1.2;
m_robotDrive->Drive(ajoysticky,aajx);

That works perfectly for what its for, but what we want our robot to do instead is move forward for a few seconds and spin in circles and I was wondering what would be the proper technique.



I would assume something similar to this
RobotDrive *m_robotDrive;
Jaguar* rightmotor;
Jaguar* leftmotor;

m_robotDrive = new RobotDrive(1,2);
rightmotor = new Jaguar(1);
leftmotor = new Jaguar(2);

m_robotDrive->Drive(1,0)
Wait(3.0);
(Set right motor and left motor to 1) so it will cause one side to go forward and the other to go in reverse

(Both are 1 because one cim has to go in reverse)

Im not sure of the proper syntax to set the jaguars speed and I dont have access to the robot so any insight would be much appreciated

-Dan

excel2474
01-03-2009, 16:48
under the autonomous portion of the code do something like:

rightmotor->Set(1);// motor speeds range from -1 to 1
leftmotor->Set(1);// so this sets both motors full speed forward
Wait(3.0); //Both motors will remain full speed forward for 3 seconds
rightmotor->Set(-1);// right motor turns backward full speed
leftmotor->Set(1);// left motor turn forward full speed
Wait(2.0);// So the robot will spin in circles(right) for 2 seconds
rightmotor(0.0);// stop right motor
leftmotor(0.0);// stop right motor



I hope this helps. I put the comments in there so you can see what is going on.

dboisvert
01-03-2009, 18:56
Thanks I will let you know how it goes when I test it on our robot!

Analog
03-03-2009, 22:24
The spin move seems to be popular.

brianelite
07-03-2009, 01:17
Haha, I used a timer class instead of Wait. Why didn't I use wait:yikes: