Upload
jasper-cox
View
220
Download
0
Embed Size (px)
Citation preview
Lab 2
Structure, Drivetrains, and Ground Sensing
http://plan.mcs.drexel.edu/courses/robotlab/labs/lab2.pdf
Today
Lego design basicsGears, motors, and drivetrainsOther Lego design tipsDifferential drive, uncertainty,
kinematics, controlGround sensingSensor processing
Building a Lego-Robot
BasicsDrive trainAttachments
Lego-Building Basics
Lego dimensions: vertical unit is 6/5 of horizontal units: I.e. stack of 5 legos is same size as row of 6 legos, or 6-holed stud
Result: can use lego beams vertically with pegs to brace structures
(copyright Prentice Hall 2001)
Lego Bracing Formula
Let a be number of full size vertical bricks, b be number of 1/3 size vertical bricks, and c be number of horizontal units, we need to find integers a, b, and c that satisfy
2(3a +b) = 5c
(copyright Prentice Hall 2001)
Some LEGO Bracing Examples
Structure
Unit LEGO brick i is a conversion factor between “LEGO lengths” and standard units6/5 height full-size brick
Stack of Five LEGO Bricks = Six-Long LEGO Beam
Three of the thin LEGO plates are equal in height to the unit brick2/5 height thin plate
Two-Unit and Four-Unit Vertical LEGO Spacings
(copyright Prentice Hall 2001)
Other Sturdy Design Principles
Black peg is slightly larger; fits snuglyGray peg rotates freely
Square Corners: use 2x plates rather than 1x ones
(copyright Prentice Hall 2001)
Today
Lego design basicsGears, motors, and drivetrainsOther Lego design tipsDifferential drive, uncertainty,
kinematics, controlGround sensingSensor processing
Building a Drivetrain
Motors, motor wires, motor ports
Gears, gear trains Driven wheels,
castors Structure to hold it
all together
(copyright Prentice Hall 2001)
Direct Current (DC) Motors:
Small and cheap Convert electrical energy
into mechanical energy How do they work?
– Current running through loop of wires generates magnetic field which react to permanent magnets and cause shaft to turn
Fast rotational speed but little rotational force (torque)
DC Motors
(copyright Prentice Hall 2001)
DC Motors
Motor Speed vs. Torque, Power: • Solid line: motor speed vs. torque
–right point: motor shaft is spinning freely but doing no actual work– left point: shaft is stalled because of too much load
• Dashed line: motor speed vs. power (speed times torque) output
Idealized Graph
(copyright Prentice Hall 2001)
Gears and Motors
Motor spins very fast but with little torque (angular force)
But torque is needed to move robot – not much speed
Solution: Gear down to reduce speed and increase torque – fit gear with small radius on motor to gear with larger radius
Trade-off speed for torque Gears must mesh properly and
securely Take advantage of lego
dimensions of both blocks and gear teeth
(copyright Prentice Hall 2001)
Gear ratios and spacing
Meshing 8-tooth gear with 24-tooth gear yields 3:1 gear ratio – Power applied to 8-tooth gear
results in 1/3 reduction in speed and 3 times increase in torque at 24-tooth gear
Two 3:1 ratios in sequence yield a multiplicative 9:1 ratio
8, 24, and 40 tooth gears radii have Lego spacing that is a whole number plus ½ a Lego unit (I.e. 0.5,1.5, and 2.5) – two gears together form an integral number of spacing units
8
(copyright Prentice Hall 2001)
Some Diagonal Gearings
(copyright Prentice Hall 2001)
Gear train
What is the gear ratio of this gear train?
(copyright Prentice Hall 2001)
Gear Box from
Previous Slide
(copyright Prentice Hall 2001)
Gear Support
Gearing
•Three parallel planes of motion to prevent the gears from interfering with one another. •Four 2x3 LEGO plates are used to hold the beams square and keep the axles from binding.
Bushings hold axles in place. Options:
•Standard 1-LEGO-long stop bush (upper axle, front) •Small pulley wheel (middle axle) acts as a half-sized spacer—it also grabs tighter than the full bush•Bevel gear (upper axle, back) makes a great bushing•Nut-and-bolt parts (lower axle) can be used to make a tight connection
(copyright Prentice Hall 2001)
Gear Design Tips
• Work backward from the final drive, rather than forward from the motor
1. mount axle shaft
2. put wheel and gear on axle
3. work backwards on gear train to motor
• Diameter of tire affects gear reduction
• Be wary of friction caused by tight bushings and play caused by loose beams
• Drive train backward to test
(copyright Prentice Hall 2001)
Wheels
Driven Casters Axles – keep axles
supported by at least two beams in a gear train
(copyright Prentice Hall 2001)
Today
Lego design basicsGears, motors, and drivetrainsOther Lego design tipsDifferential drive, uncertainty,
kinematics, controlGround sensingSensor processing
Lego-Design Hints and Tips Spacing can be used so that gears mesh
properly (using unit spacing in horizontal direction and 1/3 spacers in vertical direction); diagonal distances are also possible
Gear trains introduce friction and designs must be careful to not introduce additional slippage (though it is better to be too far apart than too tight); do not leave gears on unsupported end of axle
Use spacers, stop bushes, and connector pegs liberally; but leave very small spaces for play to reduce friction
Support axles with at least two beams and keep the beams square to each other
(copyright Prentice Hall 2001)
More Hints and Tips
Use tape for sensor wires -– wires get in the way
Casters can add friction and make things worse rather than better
Try to keep center of gravity of robot low and weight centered
Be careful about making things like gears, motors, or the Handy Board inaccessible
Lego motor is 3 Lego units high Support the motors well to avoid vibration and
loosening of gear train
Design Considerations
Smaller wheelbases are more prone to orientation errors
Castor wheels that bear significant weight induce slippage
Limit speed during turning to reduce slippage Limit accelerations Error changes with wear and load distribution
changes (as well as surface differences) Battery charge effects motor power
LEGO Design
LEGO Clichés (from Fred Martin)
Can lock a beam to an axle with medium pulley wheel
“gear mounter” piece can be used to mount gears that transmit motion or to reverse the direction of rotation.
(copyright Prentice Hall 2001)
LEGO Design
LEGO Clichés (from Fred Martin)
Build outward froma beam wall with connector-peg-with-stud piece
The full-size stop bush can be used in oneorientation to hold an axle through a platehole so that the axle can freely rotate.
(copyright Prentice Hall 2001)
Today
Lego design basicsGears, motors, and drivetrainsOther Lego design tipsDifferential drive, uncertainty,
kinematics, controlGround sensingSensor processing
Differential Drive
Two motors and driven wheels
Robot pivots around center point
Casters support weight at edges
(we will discuss the use of encoders in lab 6)
(From Borenstein et. al.)
Action Uncertainty
Despite carefully calculating equations, predicted movement varies from observed movement
Calibration, uncertain robot geometry
Friction, wheel slippage Errors grow without
bound unless periodic absolute position corrections from other sensors used
(From Borenstein et. al.)
Tires do not grip floor (spinning) – do something to increase friction
Robot does not move – increase torque or decrease friction
Uneven compression on tires – redistribute load
Understand forces involved in motion – action/reaction pairs
Forces on Movement
Actions
(Courtesy of Bennet)
Kinematics Kinematics:
– Given:• Starting point• Motor commands
– Compute• Ending point
Inverse kinematics– Go from starting and ending points to motor commands
We’ll see this in more detail later in the course Problems:
– Systematic and non-systematic errors make computations only approximations of actual results
Solution:– Calculate sequences of small movements and adjust for
observed movements
1) Specify system measurements
Differential drive kinematics
VR
VL
2d
- consider possible coordinate systems2) Determine the point (the radius) around which the robot is turning.
ICC
- each wheel must be traveling at the same angular velocity around the ICC
Rrobot’s turning radius
3) Determine the robot’s speed around the ICC and then linear velocity
R+d) = VL
R-d) = VR
Thus, = ( VR - VL ) / 2d
R = 2d ( VR + VL ) / ( VR - VL )
x
y
So, the robot’s velocity is V = R = ( VR + VL ) / 2
(Courtesy of Dodds)
4) Integrate to obtain position
Differential drive kinematics
VR
VL
2d
ICC
R(t)robot’s turning radius
(t)
Thus,
= ( VR - VL ) / 2d
R = 2d ( VR + VL ) / ( VR - VL )
V = R = ( VR + VL ) / 2
Vx = V(t) cos((t))
Vy = V(t) sin((t))
x(t) = ∫ V(t) cos((t)) dt
y(t) = ∫ V(t) sin((t)) dt
(t) = ∫ (t) dt
with
x
y
Kinematics
(Courtesy of Dodds)
Inverse KinematicsUsual approach: decompose the problem and control
only a few DOF at a time
VR(t)
VL (t)
starting position final position
x
y
Differential Drive
(Courtesy of Dodds)
Inverse KinematicsUsual approach: decompose the problem and control
only a few DOF at a time
VR(t)
VL (t)
starting position final position
x
y
Differential Drive
(1) turn so that the wheels are parallel to the line between the original and final position of the robot origin.-VL (t) = VR (t) = Vmax
(Courtesy of Dodds)
Inverse KinematicsUsual approach: decompose the problem and control
only a few DOF at a time
VR(t)
VL (t)
starting position final position
x
y
Differential Drive
(1) turn so that the wheels are parallel to the line between the original and final position of the robot origin.
(2) drive straight until the robot’s origin coincides with the destination
-VL (t) = VR (t) = Vmax
VL (t) = VR (t) = Vmax
(Courtesy of Dodds)
Inverse KinematicsUsual approach: decompose the problem and control
only a few DOF at a time
VR(t)
VL (t)
starting position final position
x
y
Differential Drive
(1) turn so that the wheels are parallel to the line between the original and final position of the robot origin.
(2) drive straight until the robot’s origin coincides with the destination
(3) rotate again in order to achieve the desired final orientation
-VL (t) = VR (t) = Vmax
VL (t) = VR (t) = Vmax
-VL (t) = VR (t) = Vmax
VL (t)
tVR (t)(Courtesy of Dodds)
Control
Basic input / output relationship:
V = + k R k
V -- input voltage
-- output torque
-- output axle speed
R -- winding resistancek -- motor constant
torque
speed
plotted against for a constant V
(Courtesy of Dodds)
Open-loop control
desired d VThe world
dcompute V from the equation
Basic input / output relationship:We want to control .
V = + k R k
We can control V.
controller
Will it work?
V = + k d R k
(Courtesy of Dodds)
Open-loop control
General idea works for any controllable system...
desired speed Controller solving for V
VMotor
and world
desired position Controller
solving for V(t)
V(t)Motor
and world
actual speed
actual position
(Courtesy of Dodds)
Open-loop analysis
We don’t know everything about .
= guessed required torquea = actual torque required
Guessed voltage Actual world
V = + k a R k V = + k d
R k
+ k d = + k a R k
R k
Difference
= d - a - R
k
The actual speed lags behind the desired speed -- proportional to
.
(Courtesy of Dodds)
Closed-loop control
desired dV
The world
a
actual speed a
- compute V using the error e
d a
Error signal e
Basic input / output relationship:We want to control .
V = + k R k
We can control V.
PID control
(Courtesy of Dodds)
Today
Lego design basicsGears, motors, and drivetrainsOther Lego design tipsDifferential drive, uncertainty,
kinematics, controlGround sensingSensor processing
Use of Infrared Ground Sensor
Reflective Optosensors
• Active Sensor, includes:
•Transmitter: only infrared light by filtering out visible light
•Light detector (photodiode or phototransistor)
•Light from emitter LED bounces off of an external object and is reflected into the detector
•Quantity of light is reported by the sensor
•Depending on the reflectivity of the surface, more or less of the transmitted light is reflected into the detector
•Analog sensor connects to HBs analog ports
(copyright Prentice Hall 2001)
Sensor Input Commands
int digital(int p)– Returns the value of the sensor in sensor port p, as a
true/false value (1 for true and 0 for false). int analog(int p)
– Returns value of sensor port numbered p. Result is integer between 0 and 255. (255 is dark, 0 is bright)
Ports are numbered as marked on Handy Board (analog: 0-6, digital 7-15)
Today
Lego design basicsGears, motors, and drivetrainsOther Lego design tipsDifferential drive, uncertainty,
kinematics, controlGround sensingSensor processing
Infrared Sensor Processing
Correct for ambient lightCalibrate light levels for dark and light
surfaces Process the data to avoid spurious
readings and adapt to changing conditions
Correcting for Ambient Light
• Need to differentiate between transmitted light and normal “ambient” light
• Can do so by using photosensor to read ambient light levels with transmitter off
•Can either use external photosensor
•Or use packaged photosensor if wired correctly
•Subtract ambient light from each IR reading
•Alternating ambient and IR readings
Wiring an LED to bit 2 of Port D (Serial Peripheral Interface) Pin
int active_read(int port){int dark, light; /* local variables */dark= analog(port); /* reading with light off */bit_set(0x1009, 0b00000100); /* turn light on */light= analog(port); /* reading with light on */bit_clear(0x1009, 0b00000100); /* turn light off */return dark - light;}
(copyright Prentice Hall 2001)
Sensor Calibration
• Robot is physically positioned over the line and floor and a threshold setpoint is captured
• Huge improvement over fixed and hard-coded calibration methods
• Declare setpoint variables as persistent and use calibration routine
•NOTE DEBOUNCING BUTTON PRESSES
int LINE_SETPOINT= 100;int FLOOR_SETPOINT= 100;void calibrate() { int new; while (!start_button()) { new= line_sensor(); printf("Line: old=%d new=%d\n",
LINE_SETPOINT, new); msleep(50L); } LINE_SETPOINT= new; /* accept new value */ beep(); while (start_button());
/* debounce button press */ while (!start_button()) { new= line_sensor(); printf("Floor: old=%d new=%d\n",
FLOOR_SETPOINT, new); msleep(50L); } FLOOR_SETPOINT= new; /* accept new value */ beep(); while (start_button());
/* debounce button press */}
(copyright Prentice Hall 2001)
Simple Processing Using Single Threshold
•Robot can be in one of two states:
•State A: Over line
•State B: Over floor
•Compare sensor reading with setpoint value
•If less than this threshold set variable to indicate robot is in State A
•Otherwise, set variable to indicate State B
• What to use as setpoint threshold?
• midpoint between floor value and line value
•E.g. 10 when aimed at the floor, and 50 when aimed at the line choose 30 as setpoint threshold
(copyright Prentice Hall 2001)
Two Thresholds for Hysteresis
•Problem with single threshold – variances in sensor readings
• Bump on floor may spike the readings
• Shiny spots on line may reflect as well as the floor, dropping the sensor readings up into the range of the floor
• Solution: two setpoints can be used
– Imposes hysteresis on the interpretation of sensor values, i.e., prior state of system(on/off line) affects system’s movement into a new state
Line Following performance run :Setpoint =20
int LINE_SETPOINT= 35;int FLOOR_SETPOINT= 10;void waituntil_on_the_line() { while (line_sensor() < LINE_SETPOINT);}void waituntil_off_the_line() { while (line_sensor() > FLOOR_SETPOINT);}
(copyright Prentice Hall 2001)
Avoiding Spurious Readings and Adapting to Changing Conditions
• Dynamically vary thresholds – keep track of history of past sensor readings and take average to determine current thresholds
• Driver code available: install an interrupt routine that periodically samples the sensor values and stores them in a buffer. Other functions, such as the current maximum or current average functions, iterate through the stored values to calculate their results
•Senhis.lis (need to get this library)
(copyright Prentice Hall 2001)
Lab 2
Structure, Drivetrains, and Ground Sensing
http://plan.mcs.drexel.edu/courses/robotlab/labs/lab2.pdf
Lab 2: Structure, Drivetrains, and Ground Sensing
In-class lab overview:– Build single motor, single drivetrain simple robot
base with ground-facing sensor– Program robot to move certain time and speed
(knobs, buttons)– Record 5 data points with two different times and
speeds and graph– Program robot to calibrate ground-facing sensor
(buttons)– Program robot to move forward until ground-facing
sensor changes state, beep, and stop
Lab 2 ProgramsGlobal variables for:
calibrationstate
Function to move a speed and time using knob and buttons
Function to read ground sensor (beep on state change)
Function to calibrate ground sensor using buttons
void main(void) {calibrate ground sensorstart process to read ground sensorwhile (ground sensor has not changed state) {
move forward}
ao();}
Next Week Take-home part of Lab
– Build differential drive robot– Program to move in a pattern of forward, backward, left, right,
movements, in a small area. Include both straight lines, standing turns, and curves
– Demo at start of next class Read on-line documents and answer questions specified at
http://plan.mcs.drexel.edu/robotlab/questions/question2.ps No Help Session Monday (Columbus Day) Lab 3: Light sensors, light following, reactive control,
feedback-based control, algorithmic control, more multi-tasking
Sign up for class mailing list:– Send mail to [email protected] from your
desired email account, – with no subject and – the body “subscribe robotlab”
Pre-lab
Collect Fees, Form Teams, Get Kits, Inventory (http://plan.mcs.drexel.edu
/courses/robotlab/inventory.html)
Tentative Teams
Team 1: Ed Burger, Christopher J Flynn, Andrea J. Glenbockie
Team 2: Matthew A Curran, Michael R. DeLaurentis, Andrew R. Mroczkowski
Team 3: Edward Whatley, Kang Chen, Chris Cera
Team 4: Daryl L Falco, Omar Hasan, Eric D. Pancoast
Team 5: Donovan Artz, Umesh Kumar, Gregory P Ingelmo
Team 6: Lisa P. Anthony, Brian J. Summers, Timothy S. Souder
Team Max: Max D Peysakhov
References
http://plan.mcs.drexel.edu/courses/robotlab/labs/lab2.pdf
http://plan.mcs.drexel.edu/projects/legorobots/handyboard.html
http://plan.mcs.drexel.edu/courses/robotlab/readings/hbmanual.pdf
http://plan.mcs.drexel.edu/courses/readings