Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Assignment 1: Utilising Abstraction of Sensor Classes

10 Mar 2022 – Initial 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 platforms, 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 robotic platform
(vehcile, drone). In large projects to facilitate testing it is common to develop a mock (fake) platform class that behaves
the same as the real platform. This allows for some system testing without the presence of all hardware.

Platform control of similar nature are often abstracted from a base platform (ie. moving apltaform to reach a goal has
similar functionality, but depends on the platform kinematics/design). This allows treating a suite of platforms in an
abstract manner when navigating them to goals for a mission, the remaining of our processing code can be agnostic
to the platform type.

Your task is to:


(a) Create a base control class for platforms and expand it to a range of platforms (ackerman and quadcopter)
(b) Create a class to control platforms for a mission to reach goals (two positions in 2d: x,y) that is agnostic to the
platfrrom type. The user can select goals and mission type, reaching goals in quickest distance travelled, or quickest
time.

Due: As per Subject Outline

Contents
Contents ............................................................................................................................................................................ 1
Assignment Specifics ..................................................................................................................................................... 2
Assessment Criteria ...................................................................................................................................................... 4
Platform: Audi R8 (Akerman Steering).......................................................................................................................... 6
Sensor: Sonar ................................................................................................................................................................ 7
An Example Configuration of Sensors ............................................................................ Error! Bookmark not defined.
Automated testing of code ........................................................................................................................................... 8
FAQ (extract from Teams Discussion) ........................................................................................................................... 9
Assignment Specifics
The assignment uses a physics simulator called gazebo. Students are provided with the simulator, installation
instructions are in the README.md file under skeleton/a1_setup

Students are provided skeleton code in a1_skeleton folder that they need to use and develop from. There are two
Interface Classes MissionInterface and ControllerInterface that stipulate the functionality of the Mission or
Controller/Ackerman/Quadcopter class. The Controller class is the base class for Ackerman/Quadcopter.

There are two platforms that are used to accomplish a mission, a quadcopter (drone) and a Audi R8 (vehicle with
Ackerman steering). Given they have different kinematics, they could reach goals travelling a different distance or
covering the distance in different speed. The Ackerman platform should be controlled via a constant turn rate
(travels in arcs of a circle) at a fixed throttle (0.2) from standing (stationary). The quadcopter can travel in four
directions (forward / backward / left / right) and can turn left / right, all control should be fixed 0.4. These
constraints allow to compute time to travel as approximate value.

Overall the code should allow the user to specify via main:

• goals (locations in 2d with x,y)


• an objective shortest distance tralled OR shortest time to travel via a main.
• If the mission will have:
o single audi R8
o single drone
o a drone and a audi R8

The main instantiates the platforms and provides them to the Mission class with the goals and objective. Calling
runMission (of the Mission class) coordinates the platform(s) to reach these goal(s). Upon completing the current
mission new goals can be provided.

Dynamic constraints for the AUDI R8 are provided below, it grips the road and travels predictably unless it is drifting
(which above throttle will avoid). The quadcopter on the other hand drifts slowly with wind, so requires at least P
control to reach a goal. The axis superimposed on the platforms have red as X (forward) and Y (left).

Figure 1 - (left) quadcopter moving up to the flight position (right) Audi R8 moving with throttle control.
Code development
Create a Base Class (called Controller) and two derived Classes (Ackerman and Quadcopter).

The Controller will need to inherit (use as base class) the ControllerInterface header and implement its virtual
functions without changing the function declarations (signatures). The Controller is the base class for Ackerman and
Quadcopter.

Students need to determine and implement functions from ControllerInterface in Controller and/or Ackerman and
Quadcopter. These design choices are marked and examine your knowledge of Base/Derived classes.

Each derived class from Controller (Ackerman and Quadcopter) will need to

1. Inherit from Controller


2. Initialise all the required variables to enable use via default constructor

C) The Mission Class will need to

1. Inherit from MissionInterface


2. Implement all the functionality specified in MissionInterface

E) The Main that

1. Initialises the platforms as either:


a. 1 x AudiR8
b. 1 x Quadcopter
c. 1 x AudiR8 and 1 x Quadcopter
2. Asks use for mission type
a. reaching goals by shortest distance
b. reaching goals by quickest time
3. Asks the user for locations of two goals
4. Runs the Mission (calls runMission until goals are reached)
5. Repeats steps 2-4 until user terminates program (CTRC+C - user terminates program)
Assessment Criteria
Criteria Weight (%) Description / Evidence Further Breakdown
20 Use of special member functions for initialisation Use of special member functions for initialisation of classes
Classes exploit of classes such that they can be used with default such that they can be used with default settings. 25
abstraction settings. I/O to terminal only in Main 15
(encapsulation, Correct use of access specifiers 15
Correct use of access specifiers.
inheritance and Functions take care of correlated dependencies (coupled
polymorphism) to settings) 15
Inheritance from base class, common data stored
cover a range of Classes that should not be available for instantiation are aptly
and generic functionality implemented solely in
sensors protected. 15
base class (no duplication).
Inheritance from base class, common data stored and generic
Classes that should not be available for functionality implemented solely in base class (no
instantiation are aptly protected. duplication). 15
Proper code execution 35 Audi R8 reaches goals successively. Audi R8 reaches a goal supplied by user 25

Quadcopter reaches goals successively. Quadcopter reaches a goal supplied by user 25


Audi R8 reaches goals in two missions supplied by user 10
The correct platform is chosen in a mission for time Quadcopter reaches goal in two missions supplied by user 10
or distance metric. Correct implemented distance metric (executed on 2 missions
of 2 goals) 10
Performs execution of missions according to Correct implemented time metric (executed on 2 missions of 2
specification. goals) 10
Correct Selection of vehicles for time or distance metric.
10
BONUS MARKS: Control of quadcopter done smoothly rather
than zig-zag. 10
Unit Testing 20 Unit tests created that guarantee performance of: Control of Ackerman platform correct (10 points for each 40
* underlying control algorithms for either Platform tests)
(Ackerman or Quadcopter). 4 tests with different goal and pose (position and orientation
* underlying selection of distance / time metric of goals)
Control of Quadcopter platform correct (10 points for each 40
tests)
4 tests with different goal and pose (position and orientation
of goals)
Correct time and distance calculation to target 20
Documentation 10 ALL classes contain comments to understand ALL source files contain useful comments to allow understand 80
methods, members and inner working (ie border inner working (and description consistent with code)
case handling of fusion, method of fusing readings) In addition to previous point, contains index.dox cover file 20
which produces description of usage and anticipated output.
Modularity of 15 Appropriate use class declarations, definitions, Methods from ControllerInterface implemented (NO
software default values and naming convention allowing for CHANGES TO INTERFACE) 20
reuse.
Methods from MissionInterface implemented (NO CHANGES
Controller classes interface in ways allowing use of TO INTERFACE) 20
class in others contexts and expansion (more Mission class can handle different ordering of platforms (no
Platforms can be added, rearranged). dependency on the ordering of platforms) 20
The Controller class could handle another platform with
No dependency on ordering of platforms, no “hard
different control (such as Segway – that turns on spot). 20
coded” values or assumptions of platform order in
mission class. No hard coded values, constants used and values obtained by
using getters and STL container sizes. 20
BONUS MARKS: Mission controller can handle 5 goals in
searching correct order to visit by distance/time. 20
Platform: Audi R8 (Akerman Steering)
The Audi R8 is a vehicle that has Ackerman Steering, for a video introduction on how to use the Ackerman steering
model please see an excellent video by Jonathan Sprinkle. In essence, for control the vehicle can be approximated
with a single tyre at front and back (known as bicycle model -geometric vehicle model), the wheel base T and
distance between front/back wheel L. δ and the radius of turn r are related as per below equation. We assume only
geometry plays part and no dynamics (no drifting on track).

Figure 2 - The pure pursuit method to control Ackerman steering vehicle. From: Automatic Steering Methods for Autonomous, Jarrod M.
Snider, Feb 2009

The relationship between angle of wheels δ, the distance to goal ld (goal at gx, gy) and heading difference α is:

The steering wheel to wheel position is via a STEERING RATIO, the total number of turns (lock to lock) governs
maximum steer angle. The distance between wheels is knows as wheel base (L).

Property Values
STEERING RATIO 17.3
LOCK TO LOCK_REVS 3.2
MAX STEER ANGLE (M_PI * LOCK_TO_LOCK_REVS / STEERING_RATIO)
TRACK WIDTH 1.638 [m]
WHEEL RADIUS 0.36 [m]
WHEELBASE 2.65 [m]
MAX BRAKE TORQUE 8000.0 [Nm]

The control of the platform is via 3 values


Property Values
brake 0 to MAX BRAKE TORQUE
throttle 0 to 1.0 (at 0.1 vehicle top speed 29m/s)
steering - MAX STEER ANGLE to + MAX STEER ANGLE
Platform Drone: Quadcopter

The quadcopter has four rotors that allow it to move in any direction on the plane as well as up/down. The up/down
motion is irrelevant to reach goals (we only consider X,Y location for goals). However, if the platform is not above
ground it could crash.

The control of the platform is via 4 values


Property Values
Turn on spot left / right Left positive (0.4 sane value)

Move left right Left positive (0.4 sane value)

Move up down Up positive (0.4 sane value)

Move forward / backward Fwd positive (0.4 sane value)


Automated testing of code

We will provide a test stub in the test folder of a1_skeleton. The testing will attempt to test the Controller Classes
developed, as well as Mission. These ARE NOT THE ONLY tests we will be undertaking on your code, but they provide
some indication of how your code will be thoroughly evaluated.

THIS IS IN COMPLETION as of 13th March 2022 5:40PM

To compile and install testing students must install google testing framework (refer canvas for instructions, as you
have done for quiz 0 & quiz 1).

Instructions to compile and run the tests on your own code are in the README.md file located within the test folder.
Whenever testing, after making changed to your code, you should recompile the test folder and run the two test
scripts.

If your tests are succeeding you should get all green in execution of tests.
FAQ (extract from Teams Discussion)

Should I implement this function in Controller or Ackerman and Quadcopter?

Students need to decide whether to implement the function, whether in base class or derived class (whether it is
pure virtual in Controller, or virtual in Controller or fully implemented in Quadcopter/Ackerman). The base class
SHOULD not know anything about the derived classes.

Can we create additional functions and classes?

Certainly, yes, you can create own functions/classes and this is good practice. This is subject to following

• You cannot add functions to interface classes


• Only the functions in ControllerInterface are accessed by Mission
• Only the functions in MissionInterface are accessed by main (unit tests we have supplied show these two
things and marking criteria is also showing this)
• Additional classes can be added, as long as above constraints are applied (that is you cannot expect
someone using your code to have to create objects of the classes or functions from this class. The
class/functions you add can only be accessed via the derived classes of the interface class. The existing
classes and functions can interact with them. (Check that our supplied unit tests have to pass).

Can I have additional constructors in the Classes supplied


You absolutely NEEED a default constructor, which takes no values, and this constructor will need to initialise the
class to default values. If you do not have a default constructor none of the unit tests will pass (including those
supplied) and we will not be able to mark execution. You can have additional constructors for you own code, but
ONLY default constructors will be called for unit testing.

You might also like