MiniRanger
Kyle L. Carithers
REU 2006
Software
MiniRanger was designed as a research
platform to be used in a miniature urban environment. The autonomous navigation software will
be developed in a separate lab at the
The robot is controlled by the velocity of the motor and the position of the steering servo. Timer 0 was initialized to trigger an overflow every few microseconds. When the overflow occurred, a series of statements occurred. The reason the overflow occurred so frequently was to allow this timer to be used as a stopwatch so the sonar functions could record the length of time and therefore know the distance of an object. Timer 0 automatically called functions that checked the sonar readings, read in serial data from the camera, positioned the steering servo, and adjusted the velocity of the motor. Additionally, there exists an actual and desired speed and direction. The actual is what is proportional to what is actually being sent out through PWMs. PWM, or pulse width modulation is the method of communication with the motor controller and servo.
Each time the speed adjustment function is triggered, the object distance is evaluated. The object distance is evaluated by taking the minimum value of the front left and right sonar and the camera mounted sonar. This value determines the desired speed. If the value is past a certain distance, roughly three feet, the desired speed is set to the maximum speed. If the value is below a certain distance, roughly one foot, the desired speed is set to direct the robot backwards with a speed proportional to the distance away from this one foot mark. Therefore, if the robot is right next to an object, the robot’s desired speed is set to go in full reverse. If the distance is about six inches, then the desired speed is in reverse but about half the speed of full reverse. If the distance is one foot, then the desired speed becomes zero. This is intended to make the robot trail about one foot behind the object being tracked.
Once the desired speed is set, the actual speed is adjusted. The actual speed can only increase or decrease by a set amount each time the speed adjustment function is triggered. This allows for a smooth acceleration or deceleration and prevents damage to the motor controller from quick direction changes. Additionally, if the desired speed suddenly jumps, meaning the desired speed is significantly higher than the previous desired speed, the actual speed is not adjusted. This prevents jittery behavior that may result from an inaccurate reading. The speed adjustment function also sets the brake lights, if braking or stopped, and sets the PWM output to the motor controller.
The direction adjustment function is also called by timer 0. This function’s operation is similar to that of the speed adjustment function. The function calls another function to read in serial data from the camera and records the servo position of the panning servo. This value is used to set the desired steering value. The actual direction is adjusted incrementally each time the direction adjustment function is called.