Reading compass information
Andrei
Posts: 15
Hi,
I am new with programing and I have one question: I have line follower robot. The start and stop are the same, it's like a circuit. How could I make my robot to turn automaticly at the same angle(at the stop point) as it was when it started following the line?
Thank you, Andrei
I am new with programing and I have one question: I have line follower robot. The start and stop are the same, it's like a circuit. How could I make my robot to turn automaticly at the same angle(at the stop point) as it was when it started following the line?
Thank you, Andrei
Comments
This depends a little on how you have the line sensors configured. I used 4 QTI sensors with the center two closely spaced and the out two set further away from the center pair. I determine when my BOE-BOT comes to the end of a line by monitoring the outer sensors and recording when they see an intersecting line. When I lose the line on the center two sensors and no line is sensed on the sides, the robot will rotate, monitoring for the line. The following snippet of code is the routine called when the line is lost:
Rotate_Right_to_Line:
L_Speed = L_Stop + (LeftS * AdjustL * 3)
R_Speed = R_Stop - (RightS * AdjustR * 3) 'Reverse direction
GOSUB Set_Servos
DO
GOSUB Check_QTIs
PAUSE 10
LOOP UNTIL ((QTIs | %1101) = %1111)
Last_QTI = %0000 'To force the program to use SELECT logic.
RETURN
Since the program was written to be used on a much larger robot in the robotics club I was teaching, all actions were programmed in subroutines (makes it easier to change hardware without changing the logic).
Called Subroutines:
Set_Servos - routine to send speed commands to the servo pal used on the BOE-BOT. This was replaced by a pair of HB-25's in the final robot.
Check_QTIs - subroutine to return the current status of the QTI sensors in a nib size variable (QTI)
Variables and Constants:
L_Speed and R_Speed are variables with the desired pulse width for the servos.
L_Stpp, LeftS, AdjustL, R_Stop, RightS and AdjustR are constants used to calibrate the operation of the robot. Again, going to different hardware is much easier if you only need to adjust one constant than search through the code.
I uploaded a video of the program in operation at www.youtube.com/watch?v=zbhg4OPLQBI
Post Edited (MSDTech) : 6/8/2009 2:30:22 AM GMT
Thanks again very much.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen