Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this problem, we will calculate the magnitude of the acceleration from the DualShock 4. You will read from ds4rd.exe, but this time you will

For this problem, we will calculate the magnitude of the acceleration from the DualShock 4. You will read from ds4rd.exe, but this time you will read the inputs over and over inside the while loop. Your code should be written in a modular fashion and include 3 or more of your own functions.

When the DualShock 4 is not moving, your program should output a line saying which side of the DualShock 4 is facing up. Consider using the magnitude of the acceleration (-a) for movement detection. You will need a tolerance value for this---experiment to find one that seems reasonable. You will need to use the gyroscope values (-g) to determine the orientation. Again, you may want a separate tolerance value. (see development tips below about the close_to function and tolerance values)

For instance, when laying flat and still on the table with buttons up, it should output TOP. Flipping the DualShock 4 over, when still, it should output BOTTOM. When setting the left side of the DualShock 4 (i.e. side with the d-pad buttons) down and the right side up, your program should output RIGHT and when flipped (ie side with the shape buttons down), LEFT. When the LED light bar is pointed up, output FRONT and similarly when the LED light bar is down it should read BACK.

Requirements

Basics

  • Program outputs orientation of Dualshock when not moving

  • Program includes and uses 3 or more of your own functions

/*----------------------------------------------------------------------------- - Includes -----------------------------------------------------------------------------*/ #include #include

/*----------------------------------------------------------------------------- - Defines -----------------------------------------------------------------------------*/ #define TRUE 1

/*----------------------------------------------------------------------------- - Prototypes -----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------- - Implementation -----------------------------------------------------------------------------*/

int main(void) { int t, b1, b2, b3, b4; double ax, ay, az, gx, gy, gz;

while (TRUE) { scanf("%d, %lf, %lf, %lf, %lf, %lf, %lf, %d, %d, %d, %d", &t, &ax, &ay, &az, &gx, &gy, &gz, &b1, &b2, &b3, &b4 );

/* printf for observing values scanned in from ds4rd.exe, be sure to comment or remove in final program */ printf("Echoing output: %d, %lf, %lf, %lf, %lf, %lf, %lf, %d, %d, %d, %d ", t, ax, ay, az, gx, gy, gz, b1, b2, b3, b4);

/* It would be wise (mainly save time) if you copy your code to calculate the magnitude from last week (lab 3). You will also need to copy your prototypes and functions to the appropriate sections in this program. */

//printf("At %d ms, the acceleration's magnitude was: %f ", t, mag(ax, ay, az));

}

return 0; }

/* Put your functions here */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Compare levels of resolution in conflict outcomes?

Answered: 1 week ago

Question

Strategies for Managing Conflict Conflict Outcomes?

Answered: 1 week ago