Sei sulla pagina 1di 7

Assignment 1

11520G Data Capture and Preparations

Due date: 11:59pm, 29nd March

 Laboratory work forms an essential part of the Unit, and as such, students are
expected to complete and submit the scripts on time.
 It is a requirement to achieve at least 25% marks in this assignment.
 This assignment is divided in two parts, in the first part you will collect data from
sensors using Arduinos in groups (done during the labs); in the second part, you will
stored in R the collected data and will carry out a simple data preparation procedure
individually (done during your own time).

Getting Started
In this assignment, you will be able to
demonstrate your ability to integrate and
synthesize the knowledge acquired
throughout the unit by understanding the
basic concepts of data capture in a real
experiment.
All the necessary material to conduct the
experiments will be provided during the
lab sessions. However, you should try to
become familiar with the technical
aspects of the experiments before coming
to the laboratories [1-2]. We will be using
Figure 1. Arduino Uno (image: Wikipedia)
the Arduino Uno for recording sensor
data.
You will be working in groups of 2-3 students (please no more than 3 students) for the data
capturing part, but you should work individually for the data preparation part. Each group
will have access to an Arduino Uno, a breadboard, USB cable, jumping wires, and a
gyroscope (MPU-6050). In addition, you will need to download and install the Arduino IDE
(use Reference [1]) and the terminal emulator Tera Term (Use Reference [3]). Finally, you
also need a USB memory stick to save all your data.
Data sheets and user manuals for all the Integrated Circuits (IC) [4], other components and
equipment could be found over the Internet and will also be posted on the resources
section of the Moodle site.
Refences:
1. https://www.arduino.cc/
2. https://www.arduino.cc/en/Tutorial
3. https://osdn.net/projects/ttssh2/releases/
4. https://www.cdiweb.com/datasheets/invensense/mpu-6050_datasheet_v3%204.pdf

1
Project: Human Activity Data Collection
Introduction
Human Activity Recognition (HAR) is the field of research concerned with identifying specific
physical activities of a person using sensor data. Examples of human activities are: walking,
running, sitting, sleeping, driving, etc. HAR has been applied to keep track of elderly people,
in the design of smart home environments, in human-computer interaction, and smart
driving assistant.
As a data scientist/analyst, you are required to collect sensor data from a group of subjects
and to store the data in a structured way, so it can be used for further analysis. Knowing the
data capture process and how to use sensors to collect data are skills that help the data
scientist to understand the data, identify possible sources of errors, and to determine an
appropriate data preparation procedure.

Part 1. Collecting Data using Sensors (in groups during labs time) – 50 points
In this task, you are required to use an Arduino Uno development board (presented in
Figure 1) to collect sensor data and to measure different human activities. You will use a
gyroscope (MPU-6050) to obtain orientation information (x,y,z) and the Arduino Uno to
read that information from the gyroscope.
The MPU-6050 has a 3-Axis accelerometer, a 3-Axis
gyroscope, and a temperature sensor integrated on
a single chip. However, for this assignment, we will
use the 3-Axis gyroscope data only.
The gyroscope measures rotational velocity or rate
of change of the angular position over time, along
the X, Y, Z axis. The outputs of the gyroscope are in
degrees per second, to obtain the angular position
we need to integrate the angular velocity. In this
Figure 2. Orientation of axes of sensitivity
assignment, we do not need to compute the
and polarity of rotation (image: MPU-6050
angular velocity, we only need to record the raw datasheet).
data.
You need to record the 3-Axis data produced by the gyroscope, these data will be used for
further analysis in R. The gyroscope’s data will be read by the Arduino and then transmitted
over the USB port. We will capture the data using the terminal emulator Tera Term and save
it as .CSV file.
Every member of your team (or participants of the experiment) will need to perform a
group of activities (you can see an example of these activities on this link:
https://www.youtube.com/watch?v=XOEN9W05_4A) while wearing the sensor on the right wrist.
Each activity should be done for 30 seconds, with a 10 seconds rest period before and after
each activity. Use the reset button to start and finish each activity, an example of the
procedure is presented in Figure 3. The activities are:

2
1. Sitting (act1). The participants will be in a sitting position on a chair, try to maintain a
still position (do not move your feet and arms) as much as you can.
2. Sitting while working at a computer (act2). The participant will be typing and using
the mouse in this task. Open a word document and type a few of lines for 30 seconds
(s). For example, type your name and describe the reasons why you are studying a
Master’s degree. After the activity is finished, close the word document and do not
save the file.
3. Standing and look around (act3). The participant will stand up from a sitting position
and will remain in standing position while looking to the right, front, and left
(repeatedly).
4. Standing and walking on the spot (act4). The participant will stand up from a sitting
position and will simulate walking on the same place.
Reset

Reset
Rest Activity Rest

Press Reset 10s 30 Sec. 10s Press Reset


button button

Figure 3. Timing diagram to carried out each activity.


Remember that prior a subject can participate in the experiment, you must obtain inform
consent from the participant. You can obtain a copy of the consent form at:
https://www.education.act.gov.au/__data/assets/word_doc/0004/441715/2013-04-17-
Consent-Form-template-ETD.doc. (10 points)
Once you obtained inform consent from each participant, you can start with the
experiment. Please complete the following steps:
1. Make sure you have these components: Arduino Uno, Gyroscope (MPU-6050), jumper
wires, breadboard, and USB cable.
2. Mount the gyroscope on the breadboard and connect the gyroscope to the Arduino
using the jumper wires, use the configuration presented in Figure 4. (5 points)

SDL reset

SDA
5V

GND

Gyroscope MPU 6050


Figure 4. Wiring diagram to connect the gyroscope (MPU-6050) and the Arduino Uno.

3
3. Before connecting the Arduino to the PC using the USB cable, call your tutor to check
your circuit. Once your tutor has checked the wiring, you can connect the Arduino to the
PC. DO NOT connect the Arduino to the PC if your tutor has not checked your wiring.
4. Once the Arduino is connected to the PC, download the Arduino script (sensor.ino) from
Canvas, save it into your PC, open it (File  Open) and upload the script (use the in
the toolbar) on the Arduino using the Arduino IDE. You should not modify the script.
5. To visualize the data sent to the PC, open the serial monitor (Tools  Serial Monitor),
you don’t need to change the settings of the serial monitor. Figure 5, presents an
example of the data read by the Arduino and sent to the PC, the data represents X, Y,
and Z axis.

Figure 5. Example of the data in the serial monitor.


6. Before you start running the actual experiment, try the system with some of the tasks
(e.g., sitting, standing while walking on the spot, etc.) to familiarize with the experiment
and observe the output in the serial monitor. Use the reset button (please refer to
Figure 4) to start and stop recording signals. You will see “gX, gY, gZ” every time you
press the reset button.
Note: use the reset button as a marker of your data, so you will know when the task
started and finished. This will help you to identify the data you need for further analysis.
7. To observe the data as time series, close the serial monitor and then open the serial
plotter (Tools  Serial Plotter). You will see a graph showing the variables (Figure 6
presents an example) and their respective time series. Observe the signals while trying
some of the tasks. Do you see any pattern in the data? Please explain your observations.
E.g., x variable goes up while y remains still during waking … (10 points)

Figure 6. Example of the data in the serial plotter.

4
8. Also, practice saving the data as CSV files. For that, you need to close the Arduino’s serial
monitor (or the serial plotter, whichever is open) and then open Tera Term. Once Tera
Term is open, a window (Tera Term: New connection) will open, select Serial and select
the Port in which the Arduino is connected to from the drop-down list, finally click the
OK button. You should be able to observe the data in the main screen. Figure 7 exhibits
an example of the data in Tera Term. For an running example you watch the following
video: https://www.youtube.com/watch?v=MSUHY18zIm8

Figure 7. example of the data in the serial plotter.


9. To save the data in Tera Term go to main menu, select File  Log… then select the
folder where you want to save the file, chose a name and use the .csv extension to safe
the file (e.g., subj1_act1.csv) and click Sav; finally, uncheck “Append” and check “include
screen buffer”. Open the file and observe the format of the data.
10. If you feel comfortable with the procedures and the system you can start with your first
recoding. Keep in mind, that all the tasks start at a sitting position, so I recommend you
that you have practised in that position a few times before you start.
11. Once the participant is in a sitting position, you can start the experiment:
a. Make sure that the Arduino is connected to the PC (step 3 and 4) and Tera Term
is open (follow step 8), you should be able to look at the stream of data.
b. Remember to follow the procedure as presented in Figure 3. Press the reset
button to begin the experiment, then the participants should stay in a relax
position for 10 seconds. After that, the participant should carry out the activity
(e.g., sitting while working at a computer) for 30 seconds. Then the participants
remain in a relax position for another 10 seconds and finally press the reset
button again to stop the experiment.
c. To save the data follow step 9.
d. Repeat the previous two steps for each activity in the experiment. At the end,
you should have 12 csv files (3 subjects x 4 activities). (25 points)
12. Once you have finished the data capture procedure and saved the data you can start
with the second stage of the experiment.

5
Part 2. Reading Data into R (individually during your own time) – 50 points
It is now required to store the data into RStudio for data processing and simple
visualization/exploration. In this part of your assignment, you should apply the concepts
learned during the lectures and tutorials/labs. It is desirable to use functions/methods
employed in this unit, use of special packages is not allowed in this assignment.
1. Load dataset. Load each of the files you captured in Part 1 as a data frame and save
each data frame, use names that are meaningful and consistent (e.g.,
df_subj1_act1). You should have created 12 data frames at the end of this task. (2
points)
2. Name Variables. Once you have stored your data into data frames, name each of
your variables (i.e., columns). Use the following names for each of the variables:
samples, aX, aY, aZ, Temp, gX, gY, gZ. You should have named each of the variables
from each data frame. (2 points)
3. Remove Specific Data. For this assignment we only need the number of samples and
gyroscope’s data, which is stored in the first column (samples) and last three
columns of each data frame (gX, gY, gZ), respectively. Thus, drop the four columns in
the middle (aX, aY, aZ, Temp) from each data frame. At the end, each data frame
should have four columns only. (2 points)
4. Find the data markers which determine the actual data (human activity) needed for
this assignment. Obtain the indexes for the start and end markers. (3 points)
5. Obtain the desire data. Once you identify both markers, use these markers to obtain
the data between these markers only. Save the new data in a separate data frame.
(4 points)
6. Remove variables. Remove from the environment variables that are not needed,
maintain only the data frames after Step 5. (2 points)
*** For those aiming for Credit: ***
7. Remove empty cells or NAs. Make sure that there are not empty cells or NAs in your
variables. If so, remove the whole row that contains an empty cell or a NA; if not
deeded, inform that within your code. (6 points)
8. Check data Structure. Make sure that the variables in the data frame are numeric, if
not, convert the variables into a numeric data type; you might need to remove any
character/symbol within the observations. At this point, you should have a ready-to-
use data frame. (4 points)
*** For those aiming for Distinction: ***
9. Signal Calibration. Use the baseline of each activity to remove the offset (the amount
in which the signal is above the horizontal axis) of each variable. You will need to
compute the mean of the baseline (use the first 300 samples) and then subtract the
mean value from the entire variable. (6 points)
10. Plot data. Explore the data by visualising its content. Using the data from a single
data frame (e.g., df_subj1_act1) plot the three variables in a single plot. Each
variable should be represented with a different colour, label the plot accordingly.
Repeat the same procedure for the rest of the subjects, at the end you should have
three plots (one for each subject). (4 points)

6
*** For those aiming for High Distinction: ***
11. Simple statistical metrics. Compute the mean and standard deviation for each
activity and for each participant. (2 points)
12. Plot the statistical metrics. Using a boxplot, build a plot using the mean values from
the three subjects for each activity. Build another plot using the standard deviation
from the three subjects and for each activity. (3 points)
13. Using the collected data, do you see any difference between the activities? Explain
your observations. (10 points)
14. Remember, good use of comments, indentations, and code separations is expected
in your code. Extra points, when total is less than 100. (3 points)

Note: You should submit in a .zip folder (named: “your_name-studentID”) the following:

 A scanned copy of your consent form.


 The CSV files from each member of your team and for each activity
 Your R script containing the code to solve each of the questions. Number your
answers using the number for each question.
 Add your answers, in line, to the questions requiring an explanation. You do not
need to add a word/text document.

Potrebbero piacerti anche