1 LAB 9 Mobile Robot Control Rajesh Rajamani ME 4231 Department of Mechanical Engineering University Of Minnesota OBJECTIVES Lab Objective To design and implement a motion control system for a wheeled mobile robot Tasks Moving to a desired position Translation and rotation Designing trajectories and avoiding obstacles Underlying tools Finite state machines PID controllers in each state of operation2 ROBOT NI Robotics Starter Kit - A mobile robot platform Comes equipped with sensors, motors and a single RIO (reconfigurable input-ouput) board NI Labview and the Labview robotics module can be used for programming the mobile robot The robot has 2 DC motors and 4 wheels The DC motors are positioned between the front and rear wheels on each side and connected via a 2-1 gear train to both wheels. Each motor has a 400-tick encoder. The motor for each side can be controlled independently (skid-steer). ROBOT COMPONENTS3 ROBOT COMPONENTS NI single-board RIO 9631 embedded control platform Built-in analog and digital I/O Ultrasonic range finder Parallax 40 kHz ultrasonic sensor Senses objects in the 2cm – 3 meters range and measures position The sensor is installed on a stepper motor that can be rotated ±90 degrees Built in 10/100 Mbits/s ethernet port to conduct programmatic communication ROBOT CONTROL NI sbRIO-9631, single board RIO, is programmed using NI LabVIEW software Basic robot program provided Only high level programming required for motion control Controller and sensor data are communicated at 100 Hz4 ROBOT CONTROL Control of forward motion The internal controller accepts forward (or backward) velocity commands The PID control gains of the internal controller have been tuned, but can be changed by the user if desired Control of orientation The internal controller accepts rotational velocity commands Again, PID control gains have been tuned but can be changed if needed Rotational control of the robot is achieved by supplying differential torque to the left and right sides TASKS IN LAB Tasks are described in detail in handout Pre-labs Exercises 1, 2 and 3 (understanding a finite state machine, translational motion control and rotational motion control) In Lab and Post-Labs: Exercise 1 Calibration of translational and rotational position measurements Exercise 2 Control of translational motion Exercise 3 Control of rotational motion Exercise 4 Moving to a desired location with obstacle avoidance5 FINITE STATE MACHINES A finite state machine is especially useful when a number of sequential tasks need to be completed The sequence of the tasks could be pre-determined or could be determined in real time based on events encountered in the environment A “state” is a general description of behavior One state at each time The robot can exhibit different behavior in each state Rotate to a desired final orientation Travel at constant speed along body-fixed x-axis Travel to a specific location “State transitions” are defined FINITE STATE MACHINES Example Speed Control Stop at desired location Rotate State transitions State transitions6 FINITE STATE MACHINES Make a state machine diagram for each task before writing the program for it Converting a finite state machine to code Caution: 1) Avoid using mixed commands. Mixed command example: “Translate = 3” + “Rotate = 2” (“left wheels = 5” and “right wheels = 1”) 2) When the robot is in the translation or rotation mode, the robot should be stopped before switching to another mode. Otherwise, error in robot motion can occur. ROBOT BASIC COMMANDS Command Description Name Stop 0 Translate 1 Rotate 27 The robot’s microcontroller accepts translational and rotational velocity commands and controls motors Transfer function from command to actual motion of the robot with default setup. Motor with PID Motor with PID ROBOT DYNAMIC MODEL B A Note: Due to significant slip, the position and angle calculated from encoders can be quite different from actual values IMPLEMENTATION OF CONTROLLER Labview is used to write programs for the robot For a basic overview of Labview, see lab handout Front panel and block diagram Sub front panel and sub block diagram Control icon, indicator icon, and color Understand Labview “while-loop” “while-loop” with formula node (c code) See example in handout for details Use state machines to design controllers before writing code8 LABVIEW FOR ROBOT Front Panel Window LABVIEW FOR ROBOT Block Diagram Window9 LAB VIEW FOR ROBOT Labview Formula Node Example program to track a reference sine wave input LABVIEW FOR ROBOT Basic while loop10 LABVIEW FOR ROBOT While loop with stored variables Note: This example uses 100 mill-sec sampling time, not 100 Hz LABVIEW FOR ROBOT All formula node output variables are fed back into the formula node as inputs using “shift registers”, . In Labview, this directs the program to store the variable so that it can be used during the next loop iteration. Any variable declared in the formula node that is not wired in this way will be removed from memory after finishing the loop. New “shift registers” can be added by right-clicking on either the left or right wall of the while loop. Similarly, new input or output variables can be added by right-clicking on the wall of the formula node.11 LABVIEW FOR ROBOT A basic Labview program for the robot is provided for you The program sets up a real-time “while” loop You will write the code for each of the tasks in the lab inside this “while” loop The code for obtaining readings from the robot and for sending commands to the robot is already provided Variables available for you to use inside the “while” loop See table on next slide Variables to be determined by your code comd vel LABVIEW FOR ROBOT Pre-defined Formula Node Variables Variable Data Type Description FT Double FR Double sonar Double Filtered sonar reading (in) count Int Current iteration (cycles) delay Int Initial delay time (cycles) Ts Double Sampling period (s) state Int State (case) of the state machine program reset Int Command to reset encoder (0 = do not reset, 1 = reset) cmd Int Robot command (0 = stop, 1 =
View Full Document