程序代写代做 c++ Assignment 2: Utilising Abstraction for a Range of Sensor Classes

Assignment 2: Utilising Abstraction for a Range of Sensor Classes
Updated:
07 April 2020 – First Release.
Intent: Skills in utilising, classes, functions, pointers and utilising abstraction, encapsulation, inheritance, polymorphism with appropriate documentation will be assessed.
Individual Task
Weight: 20%
Task: Write a program in C++ using object oriented paradigms that embodies a range of Mechatronics sensors, utilising abstraction, encapsulation, inheritance and polymorphism. Supply appropriate auto- generated documentation utilising inline source mark-up.
Rationale: In a Mechatronics System we would use a class to represent a real-world object such as a Sensor. In large projects to facilitate testing it is common to develop a mock (fake) sensor class that behaves the same as the real sensor. This allows for some system testing without the presence of all hardware.
Sensors producing data of similar nature are often abstracted from a base sensor (ie. sensor that produce range to the sensor surrounding such as a radar/laser/sonar). This allows treating a suite of sensors in an abstract manner when processing the data, the remaining of our processing code can be agnostic to the sensor type.
Your task is to:
(a) Create a base sensor class and expand it to a range of sensors
(b) Create a class to process this data that is agnostic to the sensor type and process that data to produce fused from sensor output data.
Due: As per Subject Outline
Contents
Assignment 2: Utilising Abstraction for a Range of Sensor Classes ……………………………………………….. 1 Assignment Specifics…………………………………………………………………………………………………………… 2 Assessment Criteria ……………………………………………………………………………………………………………. 3 Sensor: Laser Rangefinder Scanner ………………………………………………………………………………………. 4 Sensor: Sonar …………………………………………………………………………………………………………………….. 4 An Example Sensor Configuration ………………………………………………………………………………………… 5 Cell Fusion Methodology …………………………………………………………………………………………………….. 6
Examples ……………………………………………………………………………………………………………………….. 7

Assignment Specifics
The physical sensors are collocated; the spatial separation of sensors can be disregarded. For the purpose of this assignment assume that all sensor data is obtained instantaneously (disregard acquisition time).
A) Create a Base Sensor Class (called Ranger) and two derived Sensor Classes (Laser and Sonar) that contain:
1. Orientation Offset of Sensor (relative to centre reading of sensor)
2. Field of View of Sensor
3. Angular Resolution
4. Number of Samples
5. Sensing Type
6. Data
The Ranger will need to inherit (use as base class) the RangerInterface header and implement its virtual functions without changing the function declarations (signatures).
B) Each
1. 2. 3. 4. 5.
Sensor will need to
Initialise all the required variables to enable using the sensor
Enable obtaining all the hardware specific fixed parameters of the sensor
Enable setting configurable parameters of the sensor
Inform if the values to be set are sane, use default values otherwise
Obtaining sample sensor data at specific sensor angular resolution and within sensing range: generated as random value from a normal distribution [link] (mean 4m & std deviation 5m)
C) The RangerFusion Class will need to
1. Accept a STL container of Sensors
2. Accept a STL container of Cells (cells are essentially squares)
3. Produce a fusion of sensor readings at the supplied cells, dealing with readings that are on
the boundary of the sensing range (max range). Cell Fusion is discussed
4. Return an STL container of raw unfused data (data must be that of raw data used for fusion)
5. You will need to inherit (use as base class) the RangerFusionInterface header and
implement its virtual functions without changing the function declarations (signatures)
D) Created a static library called ranger_lib, from the classes specified. E) Create a Main that
1. Initialises the sensors (1 Laser, 2 Sonars)
2. Queries the fixed sensor parameters
3. Sets (a) sensor parameters (b) offset of sonars and (c) number of cells as specified by the
user.
4. Continuously calls (each second) the RangerFusion class, invokes the fusion
5. Prints to screen the status of the cells (free , occupied, unknown)

Assessment Criteria
Criteria
Weight (%)
Description / Evidence
Sensor classes exploits abstraction
(encapsulation, inheritance and
polymorphism) to cover a range of sensors
40
Use of special member functions for initialisation of classes such that they can be used with default settings. Correct use of access specifiers.
Inheritance from base class, common data stored and generic functionality implemented solely in base class (no duplication).
Classes that should not be available for instantiation are aptly protected.
Proper code execution
30
User input of parameters works as expected. Data values reported as per sensor description (values and timing).
Data fusion reports correct number of readings, fused according to min, max and average.
Documentation
10
ALL classes contain comments to understand methods, members and inner working (ie border case handling of fusion, method of fusing readings)
Modularity of software
20
Creates a library, links executable to the library.
No implicit coupling between classes that disables reuse.
Appropriate use class declarations, definitions, default values and naming convention allowing for reuse.
Sensor classes interface in ways allowing use of class in others contexts and expansion (more sensors can be added, sensors rearranged, can handle other offsets).
No dependency on ordering of sensors, no “hard coded” values or assumptions of sensor order in fusion class.

Sensor: Laser Rangefinder Scanner
The laser returns NL number of measurements (distances) which are related to the specified angular resolution. Each measurement is a single point in space.
For the purpose of this assignment assume that the measurement of the entire scan is obtained instantaneously (disregard acquisition time).
Sensor: Sonar
The sonar returns 1 measurement (distance). The measurement is from an area of space (a cone in space). The distance returned is to the closest object within that area of space; therefore the return can be approximated as a triangle in space (an origin and two points at the return distance).
Model
SICK-XL
Field of View
180 degrees
Angular Resolution
10 or 30 degrees
Max Distance
8.0m
Min Distance
0.2m
Model
SN-001
Field of View
20 degrees
Max Distance
16.0m
Min Distance
0.2m

An Example Sensor Configuration
The sensors can have a spatial separation, an example sensor configuration example is presented
Sensor
Field of View [°]
Angular Resolution [°]
Orientation offset [°]
Laser
180
10
0.0
Sonar1
20
-30.0
Sonar2
20
+30.0
+30.0° -30.0°
Figure 1 – Configuration 1 with sample readings; blue – laser; red – sonar 1; green – sonar 2

Cell Fusion Methodology
Cells can have one of three states : Free , Unknown and Occupied (as per the typedef for State in cell.h). We will use White (Free), Blue (Grey) and Black (Occupied) respectively for the visualisation.
When the sonar sensor interacts with the cell it change it’s state, if the end of the sonar return lies inside the cell then the cell is occupied, if it goes through the cell then it is free. If it does not intersect the cell then it is unaffected.
Similarly, when the laser sensor interacts with the cell it can change its state. If any single laser reading lies inside the cell then the cell is occupied, if a ray goes through the cell then it is free. If it does not intersect the cell then it is unknown.

Examples
If the Cell was placed in a few locations it would be Free –3 and 4
Occupied –2, 5 and 6
Unknown –1
1
4
3