辅导案例-MTRX1701-Assignment 3

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
page 1 of 8 pages





MTRX1701 Introduction to Mechatronic Engineering

Assignment 3: Working with sensor data 2020

Notes on the Assignment
1. This assignment is worth 12% of your final mark in MTRX1701.
2. You will have the opportunity to ask the tutors for assistance during the tutorial
sessions in weeks 9–11. You should spend approximately one hour preparing for each
of these tutorials so that you can benefit fully from them.
3. The tutors will not assist you further unless you can provide real evidence you have
attempted the questions prior to the tutorials. Beyond the tutorial sessions, it is
estimated that you will need sixteen hours to complete the assignment (about 21
hours total).
4. You may discuss the assignment with your peers, however all written work submitted
for assessment must be strictly your own unless cited.
5. All work must be completed electronically (i.e. typed) including all diagrams.
Assignment Submission
1. Submit your assignment electronically as a PDF file via the “Assignments” page on
the MTRX1701 Canvas site.
2. Your assignment submission should be in the form of a report which includes answers
to the various questions and uses plots when necessary to back-up your answers.
3. Note that all plots in your report
a. Must be presented as numbered figures with figure captions,
b. Must have axis labels including units, a plot title and a legend if there are
multiple lines on one plot.
4. The assignment is due at 11:59 pm, Saturday 16 May (end of week 11).
5. Late submission will be penalised by deducting 5% of the maximum mark for each
calendar day after the due date. Zero will be awarded after ten calendar days late.
6. Submit early enough to ensure that your submission is processed by 11:59 pm.
7. Keep the email that will be generated automatically by the system as proof of your
submission.
Preparation
To complete this assignment, you will need to download and install either MathWorks
MATLAB or its public-domain alternative, GNU Octave, on your computer. Both provide a
programming platform that helps engineers to design and test models of physical systems.
Both are available for Windows, Linux and Mac OSX. GNU Octave is a smaller download,
but you may need a little more knowledge to install it on your computer.
page 2 of 8 pages

Note that you will need to install the MATLAB Phased Array System Toolbox™ for
Question 3, or use the supplied functions CFAR2D() and CFAR2D().
 MATLAB is a commercial software product produced by MathWorks. The University
has a licence that allows students to install MathWorks software on their personally
owned computers while they are enrolled at the University. The MATLAB download
is 17 to 20 GB depending on the operating system.
o To install MATLAB
1. Connect to the University VPN. If you don’t know how to do this, see the
guide to the University of Sydney VPN Service
2. Visit the University MATLAB download page
3. Click on the latest MATLAB link
4. Follow the Standalone Installation prompts.
 GNU Octave is open-source software that is available under the GNU General Public
Licence. The GNU Octave installation is 300 to 500 MB, depending on the operating
system.
o To install Octave
1. Visit the GNU Octave download page
2. Click on the link to your operating system
3. Follow the instructions.
If you do not have access to a computer or are unable to download either MATLAB or GNU
Octave email David Rye directly.
Context of the Assignment
Mechatronic engineering involves the management of data. A sensor is a source of data that
must be read, converted into appropriate engineering units, and then used in some way. If the
sensor is part of a control loop the data processing must be completed well within the loop
time. Understanding and working with data is critical to ensuring the reliability and
correctness of most mechatronic systems.
This assignment explores some of the important aspects of managing and interpreting data by
examining data from a variety of sensors associated with a mobile robot, Groundhog.
Groundhog was designed and built at the ACFR. Each student is expected to work
individually to understand the concepts and produce answers to the questions. Students may
be asked by their tutor to demonstrate their solutions during the tutorials. You will use
MATLAB (or GNU Octave) as a tool to load, modify and visualise data.
When a signal is sampled by a computer-controlled data acquisition or control system the
sampling frequency is only approximately constant; deviations from a constant sampling rate
can be expected to decrease with faster, higher-quality computer hardware, just as the cost of
such hardware will inevitably be higher. A further complication can arise if data are being
transmitted on a network since in that case packets of data may occasionally be lost. When
working with data it is always wise to understand what the data represent, and to inspect the
data for anomalies such as irregular sampling or data losses. Your code should always allow
for such imperfections in data.
page 3 of 8 pages

Question 1: Signal sampling [20 marks]
A sensor ‘sample’ is a single reading from a sensor that measures some signal – one datum.
When a sequence of samples is acquired over time the sampling rate is very important. This
question investigates the effect of sampling frequency on the accuracy with which the original
signal can be reconstructed from the sampled data.
For a constant sampling rate, the sampling interval ts is defined as the time (sec) between
successive samples. The sampling frequency fs is the number of samples acquired per second
(1/sec, or Hertz), or the reciprocal of the sampling interval:
fs = 1 / ts.
For example, if a sample is taken every 10 ms, the sampling frequency is = 1/0.010 = 100 Hz.
How should the sampling frequency be chosen? One may choose to sample a signal at a faster
rate (frequency) so that
 The sampled data contain1 more detail, allowing ‘zooming in’ on regions of interest, or
 Any noise that corrupts the signal can be averaged out more precisely.
Conversely, it may be necessary to sample less frequently because
 A sensor may have a limited sampling frequency, or
 The amount of data at a higher rate may overwhelm processing capacity or overflow the
available storage capacity.
The minimum rate at which a signal needs to be sampled depends on the highest frequency
of interest in the signal that we are measuring. The following questions explore why this is
important. Follow the steps outlined and address the important points in your report.
Creating a dataset
You will use MATLAB (or Octave) to generate an idealised, noise-free set of data.
1. Generate a vector of data t representing a set of time values in seconds. Create five
seconds of time data at an interval of 0.001 seconds (1 ms) as follows.
t = 0:0.001:5;
2. Generate a vector y containing a sinusoidal signal with a frequency of 8 Hz.
y = sin( 8 * t * (2*pi) );
3. Because the vector t only contains data at intervals of 1 ms, the sinusoidal signal y is
effectively sampled at that interval. What sampling frequency corresponds to this
sampling interval? How many samples are taken of each complete period of the sine
curve?
4. Plot the sampled signal amplitude y against time t using
plot( t, y );
Add labels to the plot axes and add a title to the plot. Type help plot in MATLAB
or Octave to find out how to do this.
5. Zoom in to the graph using the tools in the figure, or programmatically, to display the
first second of data. How many times does the signal repeat? Is this what you expected?

1 Yes, “data” is plural; the singular form is “datum”.
page 4 of 8 pages

Sampling from this Dataset
What will happen when the 8 Hz signal is sampled at different sampling frequencies?
Investigate this by creating more time vectors, say t1, t2, etc., and generating responses from
the functions as in step 2 to create the corresponding outputs y1, y2, etc.
6. What happens if the 8 Hz signal is sampled at 20 Hz, 9 Hz, 8 Hz, 7 Hz and 5 Hz?
To see additional plots overlaid on the original plot axes, use the MATLAB command
hold on. This command retains the previous plot and draws any subsequent plots on
the same axes. The command subplot creates multiple plots in one figure
environment.
7. Explain what is happening. Hint: try plotting with markers: plot(t, y, ‘o’) to see
where the samples are falling. Use legend() to show which markers are which.
8. Research the Nyquist rate and find what the minimum sampling frequency should be for
an 8 Hz signal. Sample the function at the Nyquist rate plus a small amount and show
your results.
Question 2: Noisy data and filtering [25 Marks]
In this section, we will look at some data collected from a millimetre-wave radar. The data is
available in the comma-separated variable (CSV) file radar-2020.csv. This file contains
512 columns of numbers, with each column corresponding to the power received by the radar
(in radar units) at a particular range. The radar rotates in azimuth at a constant speed and the
samples are taken at a constant sampling rate that corresponds to an increment of 0.144
degrees of azimuth.
Important note: The outline solution provided below is not as complete as the one provided
in question 1; more, and larger, ‘gaps’ have been left for you to fill in...
1. Find out what millimetre-wave radar is and what “time of flight” means in that context.
2. Research how to convert a time of flight measurement (in nanoseconds) into a range (in
metres).
3. Load the data from the CSV file.
raw_data = csvread( ‘radar2020.csv’ );
4. Find out how many samples are in the dataset using the command
[num_angles num_ranges] = size(raw_data)
5. Generate a vector angles containing the azimuth angle of each sample set (each row)
del_angle = deg2rad( 0.144 ); % angles must be in rads!
angles = 1:num_angles;
angles = angles * del_angle;
6. Create a vector ranges containing the ranges of each radar measurement using the
equation you found in part 2 of this question, with the time difference between
successive radar measurements set at 0.633 ns.
7. We want to be able to plot these data for visualisation. Start by associating each range
measurement with an angle using meshgrid():
[rr, tt] = meshgrid( ranges, angles );
zz = zeros( size( raw_data ) );
page 5 of 8 pages

8. Convert these data into Cartesian coordinates and visualise them as a point-cloud. Label
each axis (including the colour axis) and give the graph a title. Axes labels must include
units of measurement.
% Convert to Cartesian, etc.
PC = pointCloud( points, ‘Intensity’, intensities );
pcshow( PC );
9. The radar measurements have distinct returns, however there is noise introduced into
these due to thermal noise, imperfect power-matching, and manufacturing variations in
component fabrication. It is important to extract return signals that we are fairly certain
come from real objects rather being a result of noise. To do this we will use a CFAR
detector. Research CFAR detectors to find out what they are, and what the different
variants are.
10. MATLAB provides a CFAR detector in the in the Phased Array System Toolbox™
which can be used as shown below. This example introduces constant false alarm rate
(CFAR) detection and shows how to use CFARDetector()to perform cell-averaging
CFAR detection.
cfar = phased.CFARDetector( ‘Num Training Cells’, ...
10, ‘Num Guard Cells’, 2 );
exp_pfa = 1e-3;
cfar.ThreasholdFactor = ‘Auto’;
cfar.ProbabilityFalseAlarm = exp_pfa;
x_detected = cfar( x, CUTIdx );

CFAR Detector Implementation Notes
a. We have supplied two functions (thanks Jacob!) which implement 1-D and 2-D
CFAR detectors in files CFAR1D() and CFAR2D(). If you are using Octave you
will need to use these functions. If you are using MATLAB, you can use either
these functions or the CFAR functions built into MATLAB.
b. The supplied detectors have variable window lengths at the edges of the data.
c. An example using CFAR2D() is shown below
x = raw_data;
[ hits2D, thresholds2D ] = ...
CFAR2D( x , pFA, nGuard , nTrain );
11. Try the same with a 2-D filter using CFARDetector2D()or CFAR2D() and compare
the outputs to those from the 1-D filter. How are they similar or different? Why is this
so?
page 6 of 8 pages

Question 3: Correction of sensor bias [25 marks]
This question relates to the ACFR Groundhog Robot, shown in Figure 1. Groundhog
navigates autonomously using data from an inertial navigation system (INS). The INS
contains a triaxial accelerometer and three gyroscopes oriented in the same directions as the
accelerometer axes. An accelerometer is a sensor that measures acceleration relative to an
inertial frame of reference; a triaxial accelerometer measures acceleration components in
three orthogonal directions.


Figure 1: The ACFR Groundhog robot.

The data for this question are from the triaxial accelerometer which is part of the INS installed
on Groundhog. The INS is fixed to the Groundhog frame with the accelerometer oriented so
the +x-axis points forwards, the +y-axis to the right and the +z-axis downwards. INS data
were acquired as the robot drove around a field. The data are in a file called acc-2020.csv
with the columns ordered as time (seconds), then the x, y, z acceleration components of
acceleration (m/s2).
1. In MATLAB, Load the data into a vector acc. Generate a time vector t from the data
and scale this appropriately.
2. Plot acc against t for each of the axes. What do each of the peaks represent? What is
the greatest acceleration experienced by the robot in each axis? Overall?
3. Acceleration data represent the time rate of change of velocity. If acceleration values are
integrated with respect to time, what do we end up with? What if we do it again?
Integration of a signal involves summing the area under the curve. In sampling this
signal, we are sampling a continuous (analogue) signal—acceleration—at a set of
discrete times. There is no information available about the signal except at the discrete
page 7 of 8 pages

times when the signal was sampled. In the time between the samples it could be
assumed either that the signal is constant or that it changed linearly. Assuming a linear
change is arguably the better assumption. Under this assumption the sampled signal can
be integrated by summing the trapezoidal areas defined by connecting adjacent sample
points with straight lines. This is known as the Trapezoidal Rule for numerical
integration.
4. Calculate the cumulative sum of the individual velocities using the Trapezoidal Rule to
generate a vector of velocity measured in metres per second.
Note: MATLAB has a cumulative trapezoidal sum function called cumtrapz() which
takes an input vector and returns the cumulative sum of that vector.
5. Do the same for position.
6. Plot the cumulative sums against time. When does the robot start moving? When does it
stop? What is its speed whilst moving?
7. Turn on the grid for the plot using the command grid on. Can you see any long-term
trends that should not be there? When the robot is not moving, its position should be
constant, and its velocity should be zero; neither the position nor the velocity
cumulative sums should change. Are the position and velocity lines exactly horizontal
during periods when the robot was stationary? Can you see a trend where (supposedly)
horizontal lines have a non-zero slope?
A trend where the data ‘drifts’ in an unexpected way often comes from integrating a
signal bias. The bias is noticeable here when we expect a horizontal line (constant
position), but the bias in fact influences the entire dataset. An INS has a bias that
changes for several reasons, mostly related to temperature. Because of this, we need to
calculate and remove this bias for each dataset. A good way to identify the bias is to
leave the INS stationary for a period of time, usually at the start or at both the start and
finish. If there is no bias, the average of the samples collected will be zero2.
8. The samples between 4400 and 4497 inclusive were acquired while the robot was
stationary. Plot a histogram of these values. MATLAB can plot a histogram using the
hist() function. Type help hist to find out how to use it.
Note: A subset of a vector can be selected using subset = vector( start:end ).
For the current example, stationary_data = scaled_data( 4400:4497 );
9. Does the average value of the histogram look like it is zero? Find the actual average
value using MATLABs mean function and store in the variable bias.
10. This calculated mean value indicates that on average, each sample is moved away from
zero by this amount. Make a new variable acc_unbiased where you subtract bias
from the biased data acc.
11. Repeat steps 3-8 using the new vector acc_unbiased. Generate a set of plots
containing the cumulative sums of acc and acc_unbiased together and comment on
the difference.

2 Provided that all noise present is zero-mean.
page 8 of 8 pages

Question 4: GPS data [20 marks]
Groundhog was also receiving satellite navigation data during the same mission as in part 3.
We wish to compare the inertial measurements to the GPS tracks in this part.
1. The GPS data were collected from a differential GPS system. Research differential GPS
and compare it to regular GPS.
2. Load the GPS data from the file GPS_2020.csv. From the latitudes and longitudes in
the file, where in the world did the measurements take place?
3. The GPS unit provides navigation solutions as coordinates in the latitude, longitude, and
altitude frame of reference. These coordinates are difficult to work with for most
ground-based robotic navigation tasks, so an alternative coordinate system—Universal
Transverse Mercator, or UTM—is used. Research this coordinate system and find the
transform from LatLonAlt to UTM. There are several different UTM spatial reference
systems in use; you should preferentially use Map Grid of Australia 2020 (MGA2020)
or WGS 84.
4. Apply this transform to the GPS data provided.
5. Plot the data in the UTM frame of reference and compare it to the results for position
found in Question 3. How are they similar/different? What are some ways that these two
sets of data could be used together?




Record of Changes


— DCR 21/04/2020 First release
Revision Made by Date Detail



51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468