The Project involves the Desgin and Development of a precise Control model for a 2-wheeled Segway Robot for implementing a parametized( give and input as distance, speed or even a function of angular dip as present in new segways) self-balancing robot. Additionally, the robot can also plan its path and navigate autonomously and implement mapping incrementally. Constraints on the physical model were modelled precisley keeping into account the frictional and electrical resistances. Finally, various high speed and precise Soft Computing techniques were deployed for tuning the controllers and planning path.
The project's Tech Stack Inolved the following:
-
Path Planning Module
- Using Artificial Potential Field for non-dynamic path planning module.
- Used Active - Astar for incremental SLAM. Here the bot could plan dynamically even without initial knowledge of the world.
- Deviational Transformationa and Shift of Frames.
-
Navigation Module
- Modelling of Chasis, Motor, Pole and Battery system.
- LQR Controller Design for Radial movement.
- Advance PID Controller for Angular movement.
- Feedback Balance Scheme for the Verticle Pole.
-
Parameter Tuning
- Ricarti Solver Model was used for LQR's cost equation.
- Bacteria Foraging and Genetic Algorithm were used to find Q and R matrix.
- Ant Colony Optimization was utilized for tuning P,I and D parameters.
The Servo Problem is defined as the dynamic response when the controller changes its set-point and Regulatory Problem is defined when the Controller tries to Manipulate the system input to counteract the effects of disturbances. The figure below shows these responses for the developed LQR Controller
Regulatory Action | Servo Action |
---|---|
The precision in the movement of the Bot is as plotted below ( Input given was 7 units towards North). Notice how the controller does not move in a straight line due to the Real-world contoller constraints and frcitional losses.
The Voltage Supplied to 2 wheels vary as per the requirement. For a simple Servo Acion, where both the wheels get same Input (Theta = 0), the following graph was developed ( note that the Y-axis units are in mV)
The Project has a complex pipeline, scripted in different languages. A central pipeline with a better user interface is under construction. Follow the following steps to run the script.
-
Clone the following repository and install Python( and additionally OpenCV and Spicy.io ) and setup your Matlab ( This project uses 2021b version ).
-
Open the Path Planning folder and run any algorithm. For example, running APF would be like the following:
cd Path Planning
cd Global Path Planning
python main.py
You can change the number and positions of the Obstacles in the main.py script. After running the code, the result would look like the following:
Instead, if you are willing to use Dynamic Path Planning of Incremental Learning, you can run it as per the instructions given here. The output would look like this:
-
After you close the script, a file would be created in the same root directory, with the name points.mat. Add this file to Matlab and release its contents. The workspace would now have an array with the name arr. This vector contains the Angluar deviations needed (as the radial distance is fixed to 10 in main.py (scan distance))
-
SegwayV4_combined.slx contains the final simulation for the Sequential Controller Design. It is already configured to run with the autostep solver (ode45). Also make sure that the simulation time remains 5 second. The following figure shows my simulation file with the 2 subsystems acting as the controllers.
-
Run the MATLAB script Segway_modelV6.m and wait for the results to show up. The following path will show up and this is the actual path that would be generated with the given physical parameters.
-
Other figures showing different parameters are as follows:
Distance Travelled | Angular Dip in Pole | Angular movement by the controller |
---|---|---|
-
Steady State Model - The ss model was made taking into account the Chasis, Motors, Wheel and the Pole. The model used 4 state variables - Radial Distance, Linear Speed, Angular Dip in pole, Rate of Angular Dip. The output of the model were Distance and Angular Dip in Pole.
-
LQR - Linear Quadratic Regulator controller was used to take care of balanced radial movement of the bot (i.e. 1-D movement only). A set point change can be given to any state hence, we can order the bot to autonomously move, attain a speed or even attach a functional block relating the angular dip with the speed of the bot!!! The following figure shows the Regulatory and Servo Response of both the outputs.
- PID - The PID module was used to controller the Bot's angular movement. Both the Wheels recieved different Input in order to move in angular fashion. The tuning was done in a way to achive the same time constant as the LQR controller. A PID fashion was choosen as this model was of SISO type. The following image shows the PID controll in action for an input of 90 degrees (1.57 rad).
The following table shows how the bot tackles the issue of dynamic path planning. In the series of figures below, the bot does not know about an obstacle in its path ahead. As soon as it recieves the map, it dynamically updates the path it has planned.
Phase 1 | Phase 2 | Phase 3 | Phase 4 |
---|---|---|---|
More information about all the phases is available in this folder : Phase_Output
The following Video summarizes the process:
-
For LQR Design - Bacteria Foraging and Genetic Algorithm were used for tuning the params for LQR controller. For the design and given constraints, GA proved to be a better option. The following figure shows the Deviation of Q11 with Iteration number
-
For Tuning PID - Seperate PID Controllers were used for the 2 wheels based on the control function developed. PID controller also used a Low pass Filter for Noise Filteration and other tuning characteristics. The Finas equation was as follows
s = tf('s');
tf_PID = P + I/s + D*N/(1 + N/s);
-
For Path Planning - The following figure is self explainatory. For smapling of the points in the path, I used the technique of constant Radial Scan where the scan radius was fixed to 10.
GSA APF
- The co-ordinate system of different systems are fairly different and this can cause a lot of trouble.
-
Communication to and from MATLAB and Simulink and other user defined functions is only possible through the Base workspace and it is impotant to use evalin() and assignin() functions for that.
-
The Dynamics for the radial and Angular movement differ and thus, we need to model the control scheme accordingly.
-
It is very important to keep into account that the speed varies according to the distance that needs to be covered and that the time taken remain constant.
An incomplete report for the report can be found here.