Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C, how would you implement the solution with the given code # include 2 enum scenario t Error = 0, LeftTooClose = 1, RightTooClose2,

Using C, how would you implement the solution with the given code

image text in transcribed

image text in transcribed

image text in transcribed

# include 2 enum scenario t Error = 0, LeftTooClose = 1, RightTooClose2, CenterTooClose4, Straight - 8, Le ftTurn = 9, RightTurn = 10, TeeJoint- 11 LeftJoint12 RightJoint = 13, CrossRoad 14, Blocked- 15 10 12 13 15 16 17 18 #define SIDEMAX 354 // largest side distance to wall in mm 19 #define SIDEMIN 212 // smallest side distance to wall in mm 20 #define CENTERO PEN 600 // distance to wall between open/blocked 21 #define CENTERMIN 150 // min distance to wall in the front 22 scenario t Classify(int32 t Left, int32 t Center, int32 t Right) [ 23 24 / write this code 25 26 typedef enum scenario scenario_t; scenario t result=Error; return result; Straight Cross Road Tee Joint right Blocked center right 45 right 45 center Right Turn Left Turn Left Joint Right Joint left right left right 45 right 45 Figure 2 Four possible sceneros as the robot approaches a decision point.The three variables (left, center, and right) are defined as the distance from the center of the robot to the wall Figure 3. Four more scenerios as the robot approaches a decision point We begin to define the algorithm design with the most important classification, the danger conditions. The algorithm will return a LeftTooClose (4) error if the left sensor is less than 212, and return a RightTooClose (2) error if the right sensor is less than 212 The algorithm will return a CenterTooClose (1) error if the front sensor is less than 150 mm. It will be possible for there to be multiple simultaneous enum scenario danger conditions. For example, 5 will signify both too close to center and too close to left. 7 will mean all three directions are too close Brror0, LeftTooClose 1 , RightTooClose 2, First we will consider the right and left sensors. In this lab, we will use #define statements to specify the distance thresholds. Once the robot and arena are built, these numbers will need to be tuned. In this example we use numbers derived from a road that is 400 mm wide and side sensors that are placed at 45 degrees. cente rTooClose 4 , Straight 8, LeftTurn-9, RightTurn 10, TeeJoint 11, LeftJoint 12, If the robot were in the middle of a road with the straight or blocked scenarios, both side sensors (placed at 45 degrees) would read 283 mm. If the robot were within +50mm from the center of the road with the straight or blocked scenarios the side sensors could range from 212 to 354 mm. The 354 threshold will be used to classify whether or not it is possible to turn left or right at the next intersection. Less than 354 means turn path not possible; 354 or above means turn path is possible RightJoint = 13, CrossRoad14 Blocked 15 typedef enam scenario scenario t: We will use #define statements to specify the bounds to make it easier to understand the classification algorithm. Finally, consider the center sensor. As the robot approaches the intersection, the center sensor will be used to classify the difference between (Blocked, Right Turn, Left Turn, and Tee Joint) (center sensor less than 600 mm) and (Straight Right Joint, Left Joint, and Cross Road) (center sensor more than 600 mm) Because there could be a long straight road, there is no maximum acceptable value for the sensors #define SIDE MAX 354 // largest side distance to wall in mm #define SIDE MIN 212// smallest side distance to wall in mm #define CENTEROPEN 600// distance to wall between open/blocked #define CEN TERMIN 150 // min distance to wall in the front The prototype for your classification algorithm is Note: The particular sensor has a measurement r However, for this algorithm the smallest distance will be 50 mm because the distance is specified to the center of the robot, not from the sensor from 10 to 800 mm scenario t Classify(int32 t Left, int32 t Center, int32 t Right); You are asked to develop an algorithm that will enable your robot to explore the arena (maze) and provide the necessary classification. Assume you will take three distance measurements with the sensors placed on the robot as inputs and return the most likely scenario based on the above criteria 4.3 Experiment set-up This lab uses the LaunchPad without any input/output. 4.4 System Development Plan 4.4.1 Functions and debugging There are 16 possible outputs of the classification algorithm. To make the software more readable, we define an enumerated data type for the return parameter. In this case, we assign specific integers for each possibility. This allows us to combine 1, 2, and 4 to represent the 7 possible danger situations For example, a 5 means left sensor too close AND to center sensor too close. In addition you should return an Error if any input is below 50 or greater than 800 In particular, we define Build and debug the SineFunction example. Using the debugger, observe the input and output parameters of the function while you single step through the # include 2 enum scenario t Error = 0, LeftTooClose = 1, RightTooClose2, CenterTooClose4, Straight - 8, Le ftTurn = 9, RightTurn = 10, TeeJoint- 11 LeftJoint12 RightJoint = 13, CrossRoad 14, Blocked- 15 10 12 13 15 16 17 18 #define SIDEMAX 354 // largest side distance to wall in mm 19 #define SIDEMIN 212 // smallest side distance to wall in mm 20 #define CENTERO PEN 600 // distance to wall between open/blocked 21 #define CENTERMIN 150 // min distance to wall in the front 22 scenario t Classify(int32 t Left, int32 t Center, int32 t Right) [ 23 24 / write this code 25 26 typedef enum scenario scenario_t; scenario t result=Error; return result; Straight Cross Road Tee Joint right Blocked center right 45 right 45 center Right Turn Left Turn Left Joint Right Joint left right left right 45 right 45 Figure 2 Four possible sceneros as the robot approaches a decision point.The three variables (left, center, and right) are defined as the distance from the center of the robot to the wall Figure 3. Four more scenerios as the robot approaches a decision point We begin to define the algorithm design with the most important classification, the danger conditions. The algorithm will return a LeftTooClose (4) error if the left sensor is less than 212, and return a RightTooClose (2) error if the right sensor is less than 212 The algorithm will return a CenterTooClose (1) error if the front sensor is less than 150 mm. It will be possible for there to be multiple simultaneous enum scenario danger conditions. For example, 5 will signify both too close to center and too close to left. 7 will mean all three directions are too close Brror0, LeftTooClose 1 , RightTooClose 2, First we will consider the right and left sensors. In this lab, we will use #define statements to specify the distance thresholds. Once the robot and arena are built, these numbers will need to be tuned. In this example we use numbers derived from a road that is 400 mm wide and side sensors that are placed at 45 degrees. cente rTooClose 4 , Straight 8, LeftTurn-9, RightTurn 10, TeeJoint 11, LeftJoint 12, If the robot were in the middle of a road with the straight or blocked scenarios, both side sensors (placed at 45 degrees) would read 283 mm. If the robot were within +50mm from the center of the road with the straight or blocked scenarios the side sensors could range from 212 to 354 mm. The 354 threshold will be used to classify whether or not it is possible to turn left or right at the next intersection. Less than 354 means turn path not possible; 354 or above means turn path is possible RightJoint = 13, CrossRoad14 Blocked 15 typedef enam scenario scenario t: We will use #define statements to specify the bounds to make it easier to understand the classification algorithm. Finally, consider the center sensor. As the robot approaches the intersection, the center sensor will be used to classify the difference between (Blocked, Right Turn, Left Turn, and Tee Joint) (center sensor less than 600 mm) and (Straight Right Joint, Left Joint, and Cross Road) (center sensor more than 600 mm) Because there could be a long straight road, there is no maximum acceptable value for the sensors #define SIDE MAX 354 // largest side distance to wall in mm #define SIDE MIN 212// smallest side distance to wall in mm #define CENTEROPEN 600// distance to wall between open/blocked #define CEN TERMIN 150 // min distance to wall in the front The prototype for your classification algorithm is Note: The particular sensor has a measurement r However, for this algorithm the smallest distance will be 50 mm because the distance is specified to the center of the robot, not from the sensor from 10 to 800 mm scenario t Classify(int32 t Left, int32 t Center, int32 t Right); You are asked to develop an algorithm that will enable your robot to explore the arena (maze) and provide the necessary classification. Assume you will take three distance measurements with the sensors placed on the robot as inputs and return the most likely scenario based on the above criteria 4.3 Experiment set-up This lab uses the LaunchPad without any input/output. 4.4 System Development Plan 4.4.1 Functions and debugging There are 16 possible outputs of the classification algorithm. To make the software more readable, we define an enumerated data type for the return parameter. In this case, we assign specific integers for each possibility. This allows us to combine 1, 2, and 4 to represent the 7 possible danger situations For example, a 5 means left sensor too close AND to center sensor too close. In addition you should return an Error if any input is below 50 or greater than 800 In particular, we define Build and debug the SineFunction example. Using the debugger, observe the input and output parameters of the function while you single step through the

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

More Books

Students also viewed these Databases questions

Question

1-4 How will MIS help my career?

Answered: 1 week ago