- About the Project
- Getting Started
- Theory and Approach
- Results and Demo
- Future Work
- Troubleshooting
- Contributors
- Acknowledgements and Resources
- License
Modeling and Control of Two-Legged Wheeled Robot: In this project, we will be building a two wheeled robot (with a hip and knee joint) which can balance at variable heights including a provision for jumping.
- C
- Python
- SolidWorks
- ESP-IDF
- AutoCad
- Creality
π¨βπ» Balance_On_Wheels
β£ π CAD Designs
β β£ π Final Design for Laser Cut (3mm)
β β£ π Design For Laser Cut (5mm)
β β£ π Intermediate Design
β β£ π Prototype 2
β β π Prototype
β
β£ π Examples
β β£ π Jump Code
β β£ π Mpu Readings Code
β β£ π Mpu Readings and Servo Rotation Code
β β£ π Printing Info on terminal using Wifi Code
β β£ π Self Balancing Code
β β£ π Self Balance Servo set zero Code
β β£ π Variable Height Code
β β π OLED Code
β
β£ π Assets
β
β£ π Notes
β β£ π Arsh Notes
β β π Shreyas Notes
β
β£ π Model
β β£ π calculation_of_parameters.py
β β£ π calculation_of_angle_from_parameters.py
β β π graph.ipynb
β
β£ π Components
β β£ π sra-board-component
β β π rosserial_esp32
β
β£ πfirmware
β β π Self_Balancing_Variable_Height
β β£ π components
β β β£ π include
β β β β£ π websocket_server.h
β β β β π websocket.h
β β β£ π CMakeLists.txt
β β β£ π Kconfig
β β β£ π websocket_server.c
β β β π websocket.c
β β£ π frontend
β β β π index.html
β β£ π main
β β β£ π include
β β β β£ π tuning_websocket_server.h
β β β β π wifi_handler.h
β β β£ π CMakeLists.txt
β β β£ π Kconfig
β β β£ π self_balancing.c
β β β£ π servo_set.c
β β β£ π jump.c
β β β£ π tuning_websocket_server.c
β β β π wifi_handler.c
β β£ π CMakeLists.txt
β β π sdkconfig
β π README.md
-
Used Solidworks 2022 for Designing our Robot.
-
Used Creality Software used for 3D Printing
-
Used ESP-IDF v4.4 for building and flashing the code on ESP-32 Microcontroller.
-
Used Python Scripts for calculation of specifications of Bot.
-
Used Matplotlib for plotting the graphs.
-
Clone the Repository
git clone git@github.com:KudoC0nan/Balance_On_Wheels.git
-
Install ESP-IDF on your System
-
Open ESP-IDF Terminal on Windows or Terminal on Linux
-
Run get_idf in Linux.
-
Goto The Repository
cd Balance_On_Wheels
-
Goto firmware folder
cd firmware
-
Goto Self Balancing Code at Minimum Height
cd Self_Balancing_Variable_Height
-
Run Command for Building the Code
idf.py build
-
Run Command for Opening the Configurations Tab to Setup the WIFI.
idf.py menuconfig
When running the above command it will open a Configurations tab.
Then select
Component Config
option.Then search for
Wall-E Configurations
and select this option.Then select
Wifi Config
option. -
Run Command on Flashing the Code on our Bot.
idf.py flash monitor
-
Our First Approach was to design our robot on Solidworks.
We designed a Bi-Pedal BOT on the Pantograph Mechanism, which is a mechanical linkage connected in a manner based on parallelograms.
The Kinematics of the Bot were Derived for Pentograph design from which the key parameters such as the length of the linkages were able to be modified and optimized during the design process.
The Hip Joint is defined to rotate in a 180 degree arc which results in the legs moving between Parallel and Anti-Parallel configurations. The angle between the vertical and the legs is shown for both the parallel and anti-parallel configurations and defined as the angles
$\phi$ 1 and$\phi$ 2 as shown in Figure. The trapezoid which represents the body of the robot.In the above Figure Leg extension is defined as the variable L is the vertical distance between the axis of the hip joints and the foot joint. The leg is shown at minimum extension Lmin the anti-parallel configuration and at maximal extension Lmax in the parallel configuration.
The above figure shown when the bot is at an arbitary position. Here,
L1 ---> Length of Upper Leg Segment (From Hip Joint to Knee Joint)L2 ---> Length of Lower Leg Segment (From Knee Joint to Foot Joint)
L3 --> Length from the Hip joint to the Mechanism's axis of Symmetry.
-
Equations Used To Derive the System Design Variables
In Above Image we have equations to calculate the
$\phi$ 1,$\phi$ 2, L1, L2 and L3 . Also In above Image at end , it is the General Equation of Length (vertical distance between the axis of the hip joints and the foot joint) which was used to plot the graph between the leg extension vs change in driver motor angle which is given below. Here, G (Gear Ratio) which is taken to be 1 for our Bot.The above Graph gives is about change of Leg Extension wrt change in Driver Motor Angle. In the middle, the slope is large. This means that small changes in motor angle cause a large amount of leg extension.
-
CAD Design
CAD design consist of 3D modeling of Bot design. We needed to check if various other aspects of systems and mechanical design satisfy our requiements. So CAD design form a very important part of our project.
-
Parts Description
-
CAD Model of Bot
-
-
Specfications of Bot
Lmax = 13 cm
Lmin = 4 cm
$\phi$ 1 =$45{\textdegree}$ $\phi$ 2 =$15{\textdegree}$ -
Hardware Bot
- Bot Parts of Acrylic Material (Laser-Cutted)
- N20 motor Shaft for Wheels (3D Printed)
- SRA PCB
- N20 motors
- MG90 Servo Motors (Connected to all Hip joint)
- Buck Converter (LM2596) (Regulates 12v to 5v for SRA PCB and 12v to 6v for N20 Motors)
- Bearings
- Shafts
π Note: SRA Board Components
π Note: N20 Motors
π Note: Mg90 Servo Motors
A PID controller is one kind of device used to control different process variables like pressure, flow, temperature, and speed in industrial applications.
PID stands for Proportional,Derivative and Integral controller. It is used in our Project for Self Balncing the bot.
For self balancing our bot should be able to minimize pitch error ,i.e, difference between current pitch angle to the initial angle of reference (Set point).
In self balancing P-Term reduces the pitch error, but this correction leads to instability and oscillations.
To prevent the oscillations of the bot along the setpoint, we use D-Term, which tries to flatten the error trajectory in horizontal line which it achieves achieves by damping the force of P term which prevents overshooting the setpoint
Sometimes applied Force is not enough to bring the error to zero (bot is in steady state),to correct this error, we use I-term, which will increase
force as the time passes and will correct the steady state error.
π Note: More on PID Explanation
-
Here, we First wrote the algorithm for Self-Balancing using the PID controller for the bot.
For self-balancing the bot, we need to keep the bot a bit above our desired angle (Setpoint), since the bot is very fast and will fall down once it's past the desired angle.
The pitch angle is required for Self-Balancing which is obtained from the Inertial Measurement Unit(IMU sensor) plug-in.
-
After Successful Run of Self Balancing Code, we than wrote the code for Servo moving from Maximum to Minimum Length (Variable Height).
-
After that we wrote the code of integrating Self Balancing Code with servos locking up at Minimum Height or Maximum Height for Self Balancing of Bot. PID is used for balancing along with servo set zero which servos lock the bot in minimum height or maximum height simultaneously so that the bot can remain stable at that position or otherwise the bot may collapse. Also before Balancing the bot we set servo zero first and then the self balancing code starts to function.
-
After Which we wrote the Jumping Code for Bot to Jump from Minimum Position.
Here, basically we are increasing the Height of the Robot in iterations rather than in a single movement.
This is because, such movement with appropriate delays produce a thrust which pushes the bot upwards.
Such thrust is not produced is a single down-up movement.
π Note:Link to Explanation of Jump Code
-
After finally we wrote the code for Self Balancing at Variable Height, which is self balance algorithm integrated with servo movement from maximum to minimum position (Variable Height).
-
Bot moving from Min to Max Height
servo_sweep.1.mp4
-
Bot given forward velocity when castor attached
Forward.Vel_Castor_attached.1.mp4
-
Self Balancing Code with servos locking up at minimum height
Self_Balance_Min_Ht.mp4
-
Self Balancing Code with servos locking up at maximum height
Self_Balance_Max_Ht.mp4
-
Self Balancing Code with servos locking up at medium height
SelfBalance_MiddleHt.1.1.1.mp4
-
Jumping of Robot
Jumping_Bot.mp4
-
Self Balancing at Variable Height
Self_Bal_Variable_Ht.mp4
-
Movement on uneven terrains like stairs using jump.
-
Implementation of LQR controller for balancing and position control
-
Implementation of Roll Stabilization
-
Segway Bot (Assistant Type Robot)
-
For obstacle avoiding (using Ultrasonic sensors or Lidar and Computer Vision)
-
Mounting of motors at wheel joint. As we were using BO motors wheels, we weren't able to use for our N20 motors. The fix was we designed a mount in Solidworks and 3D printed that mount.
-
In the Original Design of our Bot, Gears were used. But then Gears were removed from the design, considering much torque was lost due to the gear mechanism. Instead, MG90s servos were used.
-
Length of legs and distance from the AOS were reconsidered many times.
-
Base plate of the bot had some design flaws regarding placement of holes for Servos and Mpu. Currently we have made holes manually by Drilling and the changes has been made in CAD Design.
-
No holes made in Base plate to for Castor Wheels (castor wheel used for experimental purposes like checking torque and rpm of motors in forward and backward direction). Currently we have made holes manually by Drilling and the changes has been made in CAD Design.
-
N20 heating up within a few moments of testing. As we were giving 12V directly to 6V N20's due to which they were heating up. To fix this issue ,we used a LM2596 buck converter to convert the 12V to 6V.
-
During a few tests of Jumping, we found that the MG90 Servo gears either got broken or got misaligned due to high strain (sudden Jerk) on it during jumping. To fix this issue, we opened the Servos and tried fixing it and if the gear was completely broken we had to replace it with spare Mg90 servos or in worst case used Sg90 servos until the workaround is found or to perform some other tasks.
Special Thanks to Our Mentors Marck Koothoor,Ayush Kaura,Priyal for Mentoring and Guiding us in our project.
Special Thanks to SRA VJTI for giving us the chance to do the project.
Resources