Lab 5: DS4Drop — Part 1 Solution

$35.00 $29.05

You'll get a: . zip file solution, download link after Payment


NOTE: This is part 1 of a 2 week lab. A program with most of your functions tested is due at the beginning of lab next week. An undergraduate TA check-off for the first part will be required BEFORE the beginning of next week’s lab so it is important to work hard in this lab session. If you want the bonus points for this lab, it must be demonstrated to your undergraduate TA before the part 2 lab starts.

There will be one lab report for both parts and it will be due in two weeks.


  • Develop problem solving skills

  • Develop skills in the use of numerous loops to solve a problem

Starting Point:

You will want the mag function and close_to function from previous labs to save yourself time and effort.


Creating a New Folder

Create a new folder named lab5 on the U: drive. You will want to copy over ds4rd.exe to the lab5 folder.


Understanding freefall is the basis of practical applications such as landing

rovers on Mars

( as well as

fun projects such as Eggdrop competitions


Freefall in a vacuum


lu5456eej3y tmp 27617dcd634d8652

This week, we will develop an application that we will call DS4Drop to detect free fall and narrate the action. In this week’s lab, you drop the DualShock 4 into your neigbor’s hands (about 1 meter). During next week’s lab, you will use a specially padded, wireless DualShock 4 and drop it off of the 3rd floor balcony in Coover. FOR SAFETY (YOURS AND THE DS4), DO THIS NEXT WEEK ONLY UNDER SUPERVISION OF AN UNDERGRADUATE TA.

Sample Output

Your code’s output should look like the following.

<First Name> <Last Name>


Ok, I’m now receiving data.

I’m Waiting …………..

Help me! I’m falling!!!!!!!!!!!!!

Ouch! I fell 1.633 meters in 0.577 seconds.

Initially, you should print your name and your netID. This is meant to help distinguish your output from someone else’s because they will all look very similar.

After your code has read its first line of data, it should output “Ok, I’m now receiving data.” This is so that we can tell that it receiving data from the ds4rd.exe.

Each period on the “I’m Waiting” Line should correspond to some number of input lines from ds4rd.exe. Try 10 or so to see what works well. The exclamation points on the falling line should work similarly. (Note: You may want to use a counter and mod (%) for this. Challenge version, 5 bonus points: output them approximately every k milliseconds.) Whatever you do, be sure to use constants defined at the beginning of the program to specify how many lines or seconds equate to one period or punctuation mark.

The distance fallen and time it took to fall that distance should be calculated by you. Do not just print out the static numbers given in the example.

Development Tips

Several loops in this program read and throw away data from the DualShock 4 until some condition is met. Do one loop and see if it works, then add another feature and see if it works.Don’t try to write it all at once!

Feel free to use any functions from past assignments. Mag and close_to are probably good ones to reuse.

The tee command can be used to capture the data your program sees.

./ds4rd.exe -d 054c:05c4 -D DS4_BT -t -g | tee output.csv | ./DS4Drop

will write the output of ds4rd.exe to output.csv and pass it to DS4Drop.

Capturing data to a file by

./ds4rd.exe -d 054c:05c4 -D DS4_BT -t -g > output.csv

will allow you to then click on output.csv and look at your data in excel. This can be helpful in planning your solution.

Questions and Experiments

  1. Do the same drop 5 times in the classroom and record the distances. How consistent are your results? What could cause any variation?

  1. Run your program with sample data from a previously recorded drop by using the following command:

./DS4Drop < lab5_sampledata2013_1.csv

How far is it from the third floor railing to the bottom floor according to your code, using the sample data?

  1. In your report, include a graph of the magnitude of the acceleration as a function of time from the sample data. Label where the freefall is happening, where it hits the ground, and your tolerances. Explain and justify any tolerances you are using.

To get this graph in excel, implement the mag function by typing the following into the box E1:


Extend this calculation to every row by clicking the dragging the small black box that appears when cell E1 is highlighted down to the last row of data. Graph columns E vs A.

You will not be able to use the sample data file as input to your code once you add column E. Rename the file once you have your graph and redownload the original file.

  1. Demo your source code to an undergraduate TA using our 3 story drop data set and have them enter your demo score into the “Lab 05 Demo” column in Blackboard. Be sure your comment your code and functions that you write.


x= x+ vt + (1/2) gt2where v is the initial velocity (0) and t is the fall time. x0 is

1 0

the location before and x1 is the location after the fall.

g = 9.8 m/sec^2


Your lab report including answers to the above questions and your source code checked off by your undergraduate TA. This report is due in two weeks, after next week’s part of the lab.

Note: By the end of this week, your code needs to be capable of determining the time passed during a drop and the distance covered.