# Embedded Motion Control 2017 Group 3 / Initial Design

(Difference between revisions)
 Revision as of 15:00, 20 June 2017 (view source)S162167 (Talk | contribs) (→Interfaces)← Older edit Current revision as of 08:37, 21 June 2017 (view source)S162167 (Talk | contribs) (→Path-finding Supervisor) (One intermediate revision not shown) Line 45: Line 45: ===Path-finding Supervisor=== ===Path-finding Supervisor=== [[File:pledge.PNG|thumb|180px|right|Pledge]] [[File:pledge.PNG|thumb|180px|right|Pledge]] - Path-finding supervisor is the brain of PICO. It make relevant decision for motion throughout PICO's travel. We chose Pledge Algorithm over all other existing maze solving algorithm like Random mouse, shortest path etc. because the maze is unknown before challenge. Hence, the algorithms that calculates optimal path before challenge wont work easier here. Also, there is a time limit of 7 min to  solving maze. If we used some algorithm like Random mouse, it will solve the maze optimally after one full trip through maze which is not possible due time limit. Pledge algorithm works well in the context of an unknown maze with any shape of obstacles in it. The cornering concept came when we decided to code for the corridor challenge in simplest way and then the higher level of junction decision codes can be built over it. + Path-finding supervisor is the brain of PICO. It make relevant decision for motion throughout PICO's travel. We chose Pledge Algorithm over all other existing maze solving algorithm like Random mouse, shortest path etc. because the maze is unknown before challenge. Hence, the algorithms that calculates optimal path before challenge wont work easier here. Also, there is a time limit of 7 min to  solving maze. If we used some algorithm that solves the maze optimally after one full trip through maze is also impossible due time limit. Pledge algorithm works well in the context of an unknown maze with any shape of obstacles in it and starting with any initial point in maze. The cornering concept came when we decided to code for the corridor challenge in simplest way and then the higher level of junction decision codes can be built over it. 1-'''Pledge Algorithm:''' 1-'''Pledge Algorithm:''' Line 72: Line 72: The opening of door is detected by the change in the front distance. Once the door is opened fully, PICO uses motion algorithm to move through open door path. The opening of door is detected by the change in the front distance. Once the door is opened fully, PICO uses motion algorithm to move through open door path. - ===Wall / Path Detection=== + ===Wall / Path Detection supervisor=== [[File:Walldetection.PNG|thumb|180px|right|wall detection method]] [[File:Walldetection.PNG|thumb|180px|right|wall detection method]] - + Wall detection is source of data for rest of the code. Most of the mathematical calculations are done inside this. A huge number (about 1000) of raw data is received from LRF but this supervisor select, transform and share the physical world features in the form of data (distance, angle etc). Instead of using any other heavy algorithm, We used really simple mathematical operators like accumulate, sine etc inside wall detection supervisor for computation because in the initial stage of code implementation, we want better debugging because rest of codes are receiving the data provided by wall detection. 1-'''Read LRF data:''' 1-'''Read LRF data:'''

## Current revision as of 08:37, 21 June 2017

This page is a part of the Embedded Motion Control Group 3 of 2017.

## Overview

There are 2 main goals for PICO (robot).

1. Corridor competition: To navigate through a corridor and take the first exit (that can be either right or left side of PICO) without colliding with the walls.
2. Maze competition: To solve an unknown maze within given time limit, which has doors to be opened and exit the maze without touching any walls.

The overall Initial design of the project is mentioned in the following section:

1. Requirements
2. Specifications
3. Functions
4. Components
5. Interfaces

## Requirements

The following requirements are listed for the robot (PICO) to complete maze successfully:

1. PICO should not touch the walls or any other obstacles in the maze at any time instant.
2. PICO must operate fully autonomous (i.e. without input from the team).
3. PICO should not be idle for more than 3 seconds from the start of program unless it has passed the exit.
4. PICO must be able to detect available space using the Laser Range Finder (LRF) and move to the detected space according to the path finding algorithm (this plans the motion).
5. PICO must be able to find the exit within the provided time (≤ 7 sec for maze and ≤ 5 sec for corridor).
6. PICO must be able to detect the objects (dead ends) that have a high probability of being a door.
7. PICO must be able to open the door in the maze and pass through it.

## Functions

Initial Control Hierarchy

In Initial design, there are 6 functions which has a 'Main Loop' and other separate modules which are called as 'supervisors'. Each supervisor is unaware of what is there inside the other supervisor and there are communicated only through interfaces. This approach is to make software architecture simpler, editing easier and error counts lesser. The reason for concept of independent supervisors came when we thought how PICO will be working if its a human. Each part is independent, has its own features and they have to communicate in order to run whole system peroperly. We used nominal number of supervisors (5), considering number of special skills PICO has to do. Also, the number of members in our team to code in each supervisor. All the functions are listed below:

1. Main Loop
2. Path-finding Supervisor
3. Door Handling Supervisor
4. Wall Detection
5. Motion Supervisor
6. Actuator Supervisor

### Main Loop

Main loop is where

1. IO layer is initialized.
2. Rate of loop is set.
3. every functions is initiated, arranged and called.
4. Communication structs are initialized and interacted to different supervisors.
5. Relevant initial movements are provided.

### Path-finding Supervisor

Pledge

Path-finding supervisor is the brain of PICO. It make relevant decision for motion throughout PICO's travel. We chose Pledge Algorithm over all other existing maze solving algorithm like Random mouse, shortest path etc. because the maze is unknown before challenge. Hence, the algorithms that calculates optimal path before challenge wont work easier here. Also, there is a time limit of 7 min to solving maze. If we used some algorithm that solves the maze optimally after one full trip through maze is also impossible due time limit. Pledge algorithm works well in the context of an unknown maze with any shape of obstacles in it and starting with any initial point in maze. The cornering concept came when we decided to code for the corridor challenge in simplest way and then the higher level of junction decision codes can be built over it.

1-Pledge Algorithm:

This algorithm is mainly used in Maze challenge to solve the loop structures inside the maze. When an obstacle like loops are present, PICO continue the wall of obstacle until the sum of turns it took become zero. When the rurn counter sum is equal to zero, Pledge algorithm directs PICO to another path which make it to detach from the loop. The input to this function is the wall information which includes front, left and right side space information. Using the inputs, the algorithm sets a motion goals and then PICO moves to achieve those.

2- Cornering:

Cornering concept is introduced mainly for Corridor challenge. If space in right or left side is detected, this function instruct for a turn by changing bool turn_corner to true and wait until the motion supervisor is finished turning to set back the turn_corner to false.

### Door Supervisor

As it was mentioned in the maze challenge that the door is situated at a dead end and the door will be fully opened within 5 sec from PICO request, we used Door supervisor specifically react to this part of challenge.

1-Ring Bell:

If detected dead-ends, actuate the bell by <io.sendOpendoorRequest()> and activates rest of relevant algorithms of door-handling.

2-Standstill:

Wait for 5 sec at every dead-ends. The times is counted using loop counter which resets to zero when left from dead-ends. If there is no change in front distance after 5 sec, the motion algorithm is continued.

3-Door opening:

The opening of door is detected by the change in the front distance. Once the door is opened fully, PICO uses motion algorithm to move through open door path.

### Wall / Path Detection supervisor

wall detection method

Wall detection is source of data for rest of the code. Most of the mathematical calculations are done inside this. A huge number (about 1000) of raw data is received from LRF but this supervisor select, transform and share the physical world features in the form of data (distance, angle etc). Instead of using any other heavy algorithm, We used really simple mathematical operators like accumulate, sine etc inside wall detection supervisor for computation because in the initial stage of code implementation, we want better debugging because rest of codes are receiving the data provided by wall detection.

Obtain raw data from the LRF sensor

2-Filter LRF data:

Reduces noise from raw LRF data and splits it into 3 directions (left, right and front).

3-Transform data:

Calculate one distance approximation for the 3 directions by finding mean of distance in particular direction.

4-Space detector:

Calculate for all directions if space is there to move in that direction by checking if the distance is more than the threshold given.

5-Data sharing:

The relevant data like distances, angles etc are set for communication.

### Motion Supervisor

Whether it is corridor challenge or maze challenge, the attempt is failed if PICO hits the wall. In order to manage PICO without hitting walls, a good motion control over it is required and this made us to put code for avoid collision in motion supervisor. Apart from that, to solve both challenges, the motion skill of 'turning up to required angle' is also required. Hence, motion supervisor takes care all motion related tasks that PICO may require. It activates the actuator supervisor according to different situations.

1-Avoid Collision:

In order to avoid bumping into walls, PICO keeps a safety margin from the wall and align to the center of the corridor by calculating center point using the distance to the left and right. Alignment is done along with forward speed.

2-Turn Corner:

When algorithm for turning at corner is activated, there will be only angular velocity send to <io.sendBaseReference>. ie, velocity in X and Y direction will be Zero until the turning at corner is finished. PICO will be taking a 90 degree turn either on left or on right.

### Actuator Supervisor

This supervisor is like a servant of 'motion supervisor'. All it will receive is numerical data (velocities) to move the motion components on PICO. The idea of making an actuator supervisor came when we want to call the actuator supervisor only once in a loop and to avoid writing <io.SendbaseReference> at every situation of motion.

1-Steady PICO: Keep the front of the PICO aligned to the direction of movement.

2-Omni-wheels handling: Set speed and angle of Omni-wheels according to received data.

## Interfaces

Interface Diagram

We described above what is different parts of PICO (functions) in software level. Now, there should be carriers of contents (interfaces) between each supervisors. So, interfaces are defined as the movement/flow of data between the functions. One thing is noticeable here that only the content that each supervisor allow to share is carried by the interfaces. Hence, each team members sets the relevant data from interfaces in their code and use it for writing the code they want without interfering other's code. The getter and setter is the main feature of interfaces.

The different interfaces Data types are described below.

### Forward information

1. The information about the space in front, right and left are used in the form of 'Struct of Boolean'.
2. The left, right and front distances are 'Struct of floats'.

### Turning information

1. To turn left 'integer' value 1 is used while to turn right 'integer' value 2 is used.
2. To indicate finishing turn, 'Boolean' is used.

### Door information

1. If a dead-end is detect, the door handling algorithm is activated using 'Boolean'.
2. Confirmation of finishing door handling is by using 'Boolean'.

### Actuator information

1. Setting different velocity values for actuator using 'struct of floats'.

## Components

1- Sensors: Laser Range Finder (LRF), Odometry (Wheel Encoder).

2- Holonomic base (omni-wheels): Maximum translational speed of 0.5 m/s , Max angular speed of 1.2 rad/s.

3- Embedded platform Computer with Ubuntu 14.04 on an Intel i7 (other specifications are unknown)

4- Bell: To produce sound from PICO so as to open the door.

## Documents

The initial design document File:Emc-design-specification.pdf briefly indicates the approach taken towards the problem of solving the maze by the PICO robot, the algorithm used and the system design.

The slides for the initial design presentation can be found here: File:Group3 2017 Initial design presentation.pdf