程序代写案例-TU857/1
Team Computing – Sensors +
Motor Control
TU857/1 Semester 2 2021
Lecturer: Dr. Cathy Ennis
Email: [email protected]
Credits
• This course is based on material developed by :
• Cathy Ennis
• Dr. Paul Doyle
• Material from other sources is also used (citations included)
2
Overview
• Recap / Feedback
• Control Loops
• Sensors
3
Learning Outcomes
• Explain and compare different approaches to robot control
• List the difficulties facing the development of hardware-based real-
time software systems
• Demonstrate the ability to implement software to run on a specific
hardware base, for example a robot
• Demonstrate an ability to work productively in a team
4
Lab Feedback
• What was easy?
• What did you learn?
• What was hard?
Introduction
• The ability to use sensor feedback to govern its own behaviour is
what sets a robot apart from other machines
• What type of control structure uses sensor feedback?
• Closed Loop
Language Reference Guide
• EV3 RobotC
• Use this link to see all of the possible commands for RobotC
Open vs. Closed Loops
• An open-loop controller (or non-feedback controller) is a type of
controller which computes its input into a system using only the
current state and its model of the system
• The system does not observe the output of the processes that it is
controlling
• Open-loop control is useful for well-defined systems where the
relationship between input and the resultant state can be modeled by
a mathematical formula
Open vs. Closed Loops
• An open-loop controller is often used in simple processes because of
its simplicity and low-cost, especially in systems where feedback is
not critical
• Generally, to obtain a more accurate or more adaptive control, it is
necessary to feed the output of the system back to the inputs of the
controller
Open vs. Closed Loops
• A closed-loop controller uses feedback to control states or outputs of
a dynamical system
• Process inputs have an effect on the process outputs, which is
measured with sensors and processed by the controller; the result is
used as input to the process, closing the loop
Open vs. Closed Loops
Closed-loop controllers have the following advantages over open-loop
controllers:
1. Disturbance rejection (such as unmeasured friction in a motor)
2. Guaranteed performance even with model uncertainties, when the
model structure does not match perfectly the real process and the
model parameters are not exact
3. Unstable processes can be stabilized
4. Reduced sensitivity to parameter variations
5. Improved reference tracking performance
Using EV3 Sensors
The EV3 Robot comes with four sensors:
• Touch
• Ultrasonic
• Light
• Gyro
Introduction
• So far we have learned how to make the robot move without sensing
its environment (using PID):
• How to make it go forward and backward for specific lengths of time
• Now we want to identify obstacles by touching or by ultrasonic
• Become more “aware” of its environment
• We can do more with sensors
Categories of Sensors
Categories of Sensors
Sensor Performance – Basic Sensor Ratings:
• Range: Difference between min and max
• Resolution: Minimum difference between two values that can be
detected by a sensor
• Bandwidth or frequency:
• The speed with which a sensor can provide a stream of readings
• The number of measurements per second is defined as the sensor’s
frequency in hertz
• Because of the dynamics of moving through their environment, mobile robots
often are limited in maximum speed by the bandwidth of their obstacle
detection sensors
Sensor Performance
• Measurement in real world environment is error prone
• Useful terminology when discussing sensor error:
• Cross-Sensitivity: Sensitivity to environmental parameters that are
orthogonal to the target parameters
• E.G.: A compass will be sensitive to both the Earth’s magnetic field and to
ferrous building materials
• Error/Accuracy: Difference between the sensor’s output and the true
value
• Precision: Reproducibility of sensor results
Sensor Performance
• Systematic/Deterministic Error: Caused by factors that can (in theory)
be modelled
• E.G.: calibration of a laser sensor
• Random/Non-Deterministic Error: No prediction possible
• E.G.: Hue instability of camera, black level noise of camera
EV3 Sensors
• The EV3 Robot comes with two type of proprioceptive
sensor: each of the Servo Motors that give your robot
the ability to move have a built-in Rotation Sensor
• The Rotation Sensor measures motor rotations in
degrees or full rotations [accuracy of +/- one degree]
• One rotation is equal to 360 degrees, so if you set a
motor to turn 180 degrees, its output shaft will make half
a turn
• There is also a gyro sensor - can measure the robot’s
rotational motion and changes in its orientation
EV3 Sensors
• The EV3 Robot comes with three exteroceptive sensors:
Touch Sensor
• The Touch Sensor gives your
robot a sense of touch
• The Touch Sensor detects when
it is being pressed by something
and when it is released again
Ultrasonic Sensor
• The Ultrasonic Sensor enables
your robot to see and detect
objects
• Use it to make your robot avoid
obstacles, sense and measure
distance, and detect movement
Ultrasonic Sensor
• The Ultrasonic Sensor measures
distance in centimeters and in
inches
• It is able to measure distances
from 0 to 255 centimeters with a
precision of +/- 3 cm
Ultrasonic Sensor
• The Ultrasonic Sensor uses the
same scientific principle as bats:
• It measures distance by
calculating the time it takes for a
sound wave to hit an object and
return, just like an echo
Ultrasonic Sensor
• Large sized objects with hard
surfaces return the best readings.
Objects made of soft fabric or that
are curved [like a ball] or are very
thin or small can be difficult for the
sensor to detect
• Note: two or more Ultrasonic
Sensors operating in the same
room may interrupt each others
readings
Using EV3 Sensors
• Over the next few labs we will find out how to use each of these
sensors
• However, before you access the information from these sensors you
need to configure the sensors to run in your program
• Today, we’re going to see how to do this
Touch Sensor
Bump Sensor
• Detects: Physical Contact
• Feedback:
• Typical Use: Bumper
• While (SensorValue(touchSensor) == 0 )
• (Will run the while() look as long as the touch sensor is not pressed)
0 if not pressed, 1 if pressed
Configuring Sensor Names in RobotC
Defining names for sensors
Sensor names we can now
reference
Using EV3 Touch Sensors
Configuring Sensors in Simulator
Ultrasonic Sensor
Ultrasonic Sensor
• Detects: Distance to Object
• Feedback:
• Typical Use: Obstacle detection & avoidance
• While (SensorValue(sonarSensor) >25)
• (Will run the while() look as long as there is no object detected within 25cm)
RANGE in cms (1-250)
Ultrasonic Sensor
Using EV3 Ultrasonic Sensors
Controlling Sensor Readings
Ultrasonic Sensor
• The value returned by the sensor type can be different
• Sonar is value in CM 1 - 250
• Bump is 0 or 1
Ultrasonic Sensor
SENSOR DETECTS SURFACE AND STOPS 25CM BEFORE IT
Touch Sensor – Lab
Motor Control using degrees of rotation
Motor Encoding
Syncing Motors and Motor Encoder
LAB Overview
• Students work in teams and
submit a single GIT REPO for
their work covering part B of the
Lab
• Code should be commented and
well structured
• The quiz/Part A may take longer
that the allocated lab time, so
students can complete them
outside of labs
• Additional resource links will be
provided to help students who
are struggling with the material
• You must demo all of your
coding tasks in order to get
marks for your work. All team
members must be present at the
demo
• Reference ROBOTC for EV3 for
additional help on commands
Part A
• Clone a starting REPO from LAB3, it contains a list of useful programs
for you to review for this lab
• Create a new LAB3 subdirectory
• Complete the TRUE/FALSE questions
• Identify the errors in the code listing provided
Part B
• Write a new program teamcomputing/lab3/EncoderSync.c which
USES PID control and implements the functions below using just the
SetMotorSyncEncoder command. Distance should be measured in CM
• void drive(long nMotorRatio, long dist, long power)
• void turn90(long nMotorRatio, long power)
• Using only calls to these functions write a program that makes the
robot
a) Go in a square with a perimeter of 200cm and return to original position
(random direction)
b) Go forward for 100cm at 100%power, then do 180degree spin and at return
to original position at 25% power
Part B
• Complete the challenge in Diagram 1. The challenge is to show that
the same program can start from position 1a, 1b, or 1c and arrive at
the same location position 5 without changing the code
• Start at position (1a, 1b, 1c)
• Go forward until the Lego robot box is detected, then turn left.
• Travel forward until you reach the edge of the table then turn left
• Travel forward until you reach a book then turn left
• Travel forward for 30cm then stop.
• You should use both bump sensor and the ultrasonic sensor and
motor encoding
Challenge 1
• You can build the set of
obstacles using the Playfield ->
Maze/Lines function in
QEV3BotSim.
Part B
• Write a new program teamcomputing/lab3/ButtonEncoderSync.c
which the Lego BUTTONS to set a distance for the robot to travel.
Distance should be measured in CM.
• You should be able to select a distance of 10, 40, 60, 80cm
• Once selected the robot will the travel the distance at a random
speed

欢迎咨询51作业君
51作业君 51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: ITCSdaixie