Robotic Challenges STEM Robotic Challenges 1

Find the perfect balance between agility and balance adapting the Robot´s behaviour parameters in real time

You are the robot designer now. Tune the B-robot up to make it carry a beverage can wherever you want. Can you move the robot not dropping the load? Try this challenge and know how.

 

Any ideas or contributions will be more than welcome in the community

Scheme 1
The concept: place a can on top of the B-robot and move it around. Depending on the size of the can (330 ml or 500 ml), the B-robot will need some adjustments in order to keep its balance and the can in place.

WHAT:

With the default settings, the B-robot EVO is quite stable, but if you change its centre of gravity the balance will be compromised.

 

centre of gravity

Depending on the size of the can you are using, the system centre of gravity will change. So the overall behaviour of the robot will change in correspondence. As its behaviour is dictated by the PID control parameters, just modify them in real time via the jjrobots control APP and make the system stable again.

HOW:

First, download and print (not mandatory but recommended), the BEVERAGE CAN HOLDER 3D part from here:

beverage can holder
This shelf have been created with a emboss/fillet that will make holding the can easier.

Replace the regular TOP SHELF PART for the new one so the robot will be ready to carry the can.

WHERE:

You just need some room on the floor (or desktop). Create a simple circuit using obstacles (pencil bowls, cans…) and place a starting line somewhere.

INSTRUCTIONS:

1. Print some traffic cones using your 3D printer: Traffic Cone 3D model (stl) or use any other obstacles and create a small circuit with them (4-6 cones will be enough)

traffic cone

2. Customise your CAN with your own design! (not mandatory 😀 )

Go to https://www.jamlabelizer.com/ or https://www.beerlabelizer.com/ and create your own one

labels

 

3. Replace the regular B-robot top Shelf with the BEVERAGE HOLDER SHELF

4. Turn on the B-robot and once it is standing up, place the can on top of it.

5. Control your robot with your smartphone and try to complete a lap not dropping the can!

6. Failed? Modify the B-robot behaviour tuning it up! (go to “How do I improve the B-robot´s balance while I am carrying the can?” to know how)

7. Compete against other B-robots! Get to the goal first not dropping the can 🙂

 

It is quite easy if you use the jjRobots control APP (free at Google Play)

real time parameters HQQ

Once you have connected your B-robot to your smarphone/tablet (WIFI ID: JJROBOTS-XX, password: 87654321) you can control it with the APP. If you tap on the GEAR (top right on the control screen), you will access to the PID settings window, where you can modify IN REAL TIME the PID parameters which are determining the robot´s behaviour.

Moving to the TOP the slicers, you are increasing the default values by 100%. If you move the slicers down (to the very end), by 0%. What are the default values? They are set in the Arduino CODE BROBOT_EVO2_XX.ino file (the segment of the mentioned code shown below) :

// NORMAL MODE PARAMETERS  
 #define MAX_THROTTLE 550  MAXIMUM VELOCITY
 #define MAX_STEERING 140 MAXIMUM SPINNING VELOCITY
 #define MAX_TARGET_ANGLE 14 MAXIMUM ANGLE REACHED WHEN MOVING

// PRO MODE = MORE AGGRESSIVE (MAXIMUM SETTINGS)
 #define MAX_THROTTLE_PRO 860  MAXIMUM VELOCITY. PRO MODE
 #define MAX_STEERING_PRO 280 MAXIMUM SPINNING VELOCITY. PRO MODE
 #define MAX_TARGET_ANGLE_PRO 32  MAXIMUM ANGLE REACHED WHEN MOVING. PRO MODE

// Default control terms for EVO 2 THESE PARAMETERS DEFINE THE GENERAL BEHAVIOUR OR THE ROBOT (STABILITY AND SPEED OF RESPONSE) MORE INFO ABOUT THE B-ROBOT PID PARAMETERS HERE. WE ARE NOT GOING TO PLAY WITH THEM HERE. 
FOR THAT, TAKE A LOOK TO THE CHALLENGE: "The Robotic Waiter" 
 #define KP 0.32 
 #define KD 0.050 
 #define KP_THROTTLE 0.075 
 #define KI_THROTTLE 0.1 


 

Highlighted in red, the PID parameters values used to keep the balance of the robot. Why those values? Trial an error and fine (very fine) tuning. These parameters will work in many cases, even if you add some weight to the robot, but will not work as good as expected if you dramatically shift the centre of gravity.

Let´s start with how the PID loop control works in this robot.PID Scheme 1024x367

 From Wikipedia: “A PID controller calculates an ‘error’ value as the difference between a measured [Input] and a desired setpoint. The controller attempts to minimize the error by adjusting [an Output].”

 

The B-robot uses two PID controls in cascade. This is a very popular PID control in robotics. The first block, the PI, is in charge of controlling the SPEED, and with SPEED me mean… angle. The bigger the angle, the faster the robot will advance. That makes sense. Actually the B-robot is a unstable system by default. What we are achieving here is keeping the balance of an unstable system moving the robot forward and backwards. Imagine that you have to keep an inverted broom in balance. As the broom increases its tilt the faster you will have to move your hand to keep it vertical. The same applies for the B-robot.  The first PID, is the SPEED CONTROL BLOCK (PI) uses the DESIRED SPEED (input from the smartphone/command), the current B-ROBOT´s SPEED (we know this speed because we know how much the motors have rotated per second) and according to those two values, it will give you a DESIRED TILT ANGLE as output:

B-robot BRAIN: “I know my current speed and the input command wants me to increase it: increase the tilt ANGLE”

B-robot BRAIN: “Ops, I should start decreasing my speed , I am moving too fast: decrease the tilt ANGLE!”

The B-Robot knows it has to keep continuously under control its tilt angle (it does that hundred of times per second), and the P and I values (defined as KP_THROTTLE and KI_THROTTLE respectively in the Arduino CODE) are in charge of defining how “strong” this control actuates on the Speed output.

Examples:

The higher the KP_THROTTLE -> the faster the B-robot reacts against an excessive inclination (but it might cause the B-robot to oscillate too much)

The higher the KI_THROTTLE -> That will make the robot to behave …plummy. With a very conservative way to move. A high KI_THROTTLE value will make harder to tilt the B-robot.

The I (Integral value) will reduce the gap between the REAL situation and the DESIRED situation. It is like a supervisor always looking for getting the most perfect outcome not allowing the offset to be present. It is like your smart-ass friend telling you: “put some more salt on that to make it taste perfect”.

The Integral value will force your hand to achieve the perfect verticality with the broom (and keep it)

broom balancing
If the broom falls forward, you will have to move the hand forward too to keep the balance. The bigger the inclination of the broom, the faster you will have to move your hand.

 

JJROBOTS ACADEMY: How does a PID control work?

STABILITY CONTROL BLOCK:

 This CONTROL BLOCK keeps in consideration the current robot´s tilt angle (this value comes from the IMU sensor) and the desired TILT ANGLE (this value comes from the previous SPEED CONTROL BLOCK output) and makes the robot acts in consequence.

If we apply this idea to the BALANCING THE BROOM example, the P value will make you (who are keeping the broom vertical using your hand) reacts faster or slowly to the broom lack of verticality. It is like when you have a very “energetic” day and can fast react to anything (KP value: high). Or the opposite: You have been playing football with your friends 2 hours and can not move a leg due to tiredness (KP value: low)

The D parameter: (defined as KD in the Arduino code). This is the…value that will make the robot foresees the future! In the same way you will notice when the broom is tilting too much (and will fall for sure in a very near future), the B-robot knows, thanks to the D (derivative parameter), that if it is not capable to move fast, it will fall too. The higher this value, the more the robot will over-react to the tilt.

All of this theory is fine, but the best way to understand how it really works is to watch it in real time.

The jjRobots control APP has a “PID setup” window (see the image below to know how to get there) that will allow you to modify , on the fly ,the PID parameters of the B-robot EVO (and its behaviour consequently). If you move the slicer to the very top you will add a +100% of the value already defined in the Arduino CODE, to the very botton, -100% (that means, the value will be ZERO)

Example:

From the B-robot´s Arduino CODE:

 #define KP 0.32 
 #define KD 0.050 
 #define KP_THROTTLE 0.075 
 #define KI_THROTTLE 0.1 

If you move the P-Stability slicer to the top, you will be applying a 0.32 + 100% of 0.32 to the control -> P-Speed will be 0.64!
real time parameters HQQ

Below: the mapping of the four bars for the STABILITY CONTROL and SPEED CONTROL

PID Brobot

 

TIP: if you reboot your B-robot or the control APP the default parameters (defined by the Arduino code) will be restored  

 

 

If you act over the P-stability and D-stability values and reduce both to ZERO the robot will just fall. Dead. You have just let it without any kind of balance control. If you do the same with the Speed control parameters the robot will misbehave and will fall eventually but not immediately.

There is always a compromise when you are working with robots. They do not calibrate themselves. That is the job of any robot designer/technician. The robots are tools, they can be impressive/huge or extremely powerful but there is always someone/a team behind making them to do what they are intended for. Adapting the B-robot to carry (properly) a can makes you a robot technician, redesigning the original purpose of this robot. How about creating a huge b-robot to carry you? 😉