#19 From Solidworks to Simscape final robot - attempting self-balancing with 6 PIDs
- Aurel

- May 2, 2022
- 4 min read
Updated: May 13, 2022
After importing successfully the assembly to Simscape and applied all current knowledge, in this post is shown my attempt to make the robot achieve full self-balance by actuating all joints.
Firstly I wanted to build a more clean-looking system as the previous one with the robot exploding didn't convince me too much. so I have made it to look similar to the actual build of the robot so when I look at it, I know which part corresponds to which.

However, the system now looks like the robot itself when run in simulation. For now it just falls into itself without any parts flying away or being dramatically unrealistic:
The system now looks just like the robot's structure and is made this way to ease my work when I will deal with more complex parts of the system, such as trying to run multiple PID controllers at once:

When running the simulation I noticed that the wheels move in opposite direction (video slowed down 1/8x speed):
To fix that I will add to either one of the motors a "-1" gain at the output of the PID, that way the values coming out gets multiplied with -1 and reverses the rotation.

While trying to run multiple PIDs I decided to check whether there was a way to make remove variables or placeholders to use without having to wire everything into a complex "spider web". The "GoTo" and "From" are simple blocks which use tags, so if both have the same tag, they share the same signal, where one takes an Input to store in the tag, the "GoTo" (a tag can be anything, from a letter to a word with numbers, etc) then the "From" gives it as an output where is needed. This way the system looks nicer so I wanted also to make areas for the user, myself so I don't have to jump in and out of subsystems:

After adding that gain with -1, the wheels were spinning in the correct verse (video is slow to 1/8x speed):
After the wheels were spinning in the correct sense, I decided to get to Knees' actuators and make them actuate accordingly. So what I did, I attached simple scopes to check the angle of the joints and take the very first value present when the simulation starts, because in solidworks I mated the whole assembly with the individual reference planes and the robot would be simmetrical in the first moment of the simulation and it would be suspended at a height above the ground too.
So I noticed that the Knees were both at the same value but with opposite signs, which is expected since it is a simmetrical assembly:
Right knee initial joint position:

Left knee initial joint position:

One thing which I did different instead of trying to keep dealing with the PIDs and Setpoint, was to make sure that the coefficient of frictions were correct, so I wanted to find the coefficients of fricitions between rubber (wheels) and either wood or cement, as that would be a realistic environment where I would test my prototype if I had one, so meanwhile I found a website (https://pressbooks.bccampus.ca/introductorygeneralphysics1phys1107/chapter/5-1-friction/) that provided with just the right values:
Static coefficient of Fricition = 1.0
Dynamic (or Kinetics how they call it) coefficient of Fricition = 0.7
I then went repeated the same process for the shoulders and provided those values as target setpoints so the robot would aim to stay rigid and based on the outcome of the visual feedback I was getting from the simulation it was a good sign that this was going somewhere (video is 1x speed):
After making the robot stay rigid, it was only a matter of tuning the PIDs of the wheels to make it stabilize as well as selecting a setpoint since the centre of mass is clearly going to make the robot fall on its back due to the weight of the knee motors (video is 1/4x speeD):
After tweaking the values of the PIDs and the Setpoint I was able to see some big results, where the robot would try to self-balance but it was falling towards its back as expected (video is in 1x speed):
Making the robot fall down with style. It is the same video like the one above, but with more simulation time, to see what would the robot will do as it appeared to be accelerating at the end of the previous, and so it was true, and then it falls down not being able to maintain an upright position (those white/black circles represent the centre of mass for each geomtry). Video runs in 1x speed:
The only value I needed to tweak was the setpoint and after a lot of trials and errors, I found my setpoint to be 0.2356194 rad (13.5 deg), but one potentially big issue is that for anything that looked realistic took longer than expected to run the simulation, for example the following video took 15 minutes of compiling to produce a few seconds of simulation from which I could save the video. Video runs in 1x speed:
Top view of the same simulation. Video is 1x speed:
So finally, I have achieved a self-balancing!
Here is the final Output graph with its respective behavior from the scope:

Next I will try to improve the system by making it neater and expanding on the area, work on the report and try to make a video.
On a side note, I am happy that even if the PIDs don't work to make the "autotune" I feel that I have achieved a successfull outcome by manually tuning the values.



Comments