#10 Testing current knowledge - From Soliworks to Simscape
- Aurel

- Mar 13, 2022
- 2 min read
Since so far I feel that I managed to understan how Simscape works, I wanted to try and test that the knowledge was actually valid, so I have taken a solidworks model of a basic realistic self-balancing project from last year (which was simulated in NX Siemencs MCD and programmed in LabView).
To do that, I had to install first and foremost the plugin for Solidworks: https://uk.mathworks.com/help/physmod/smlink/ref/linking-and-unlinking-simmechanics-link-software-with-solidworks.html
Then after following through the tutorial and reading documentation, I had to export the assembly from Solidworks, which saves in XML format, and then I followed this tutorial to import in Simscape the XML file: https://uk.mathworks.com/help/physmod/sm/ref/smimport.html
Essentially, what I had to do, is go in the command prompt/terminal of matlab and type " smiport(' <exact path of xml file including name of file itself in .xml> '); " which would open the all the relevant blocks of the Solidworks assembly but in a format acceptable by Simscape, and looked like this:

It looked a bit overwhelming, but at this point I could simply save the file as a normal ".slx" file and reopen it later directly in Simscape (making sure all the files were added to the PATH). After figuring out that most blocks were simply to keep the geomtries together and the appropriate distances and with the appropriate mates, I knew I had to look for the 2 revolute joints of the wheels to apply some basic PID torque to the them, of course apply the spatial contacts between the surfaces which would come into contact with each other and the main objective was to make the wheels rotate, so for that I have tried to isolate everything else to simplify the system. I have only kept visible each step input with their PID controllers and the revolute joints of the respective wheels, everything else was put in a resizable subsystem:

I have given both step inputs 1 second delay, 10 degree initial value, and 45 degree final value, expecting the wheels to turn a little bit at the beginning of the simulation, then after 1 second expecting them to turn a bit more and then stop once they reached that 45 degree setpoint, this was the result of the simulation:
This was the graph resulting from one of the wheels (which I have recorded just to check desired output VS actual output):

In conclusion, this experiment, was to confirm to my own self whether I was on the right track with understanding the Simscape environment but also to see if I can apply my current knowledge to merge a Solidworks model (one of my own, recycled from last year) with everything I learnt so far.
I believe this was quite successfull, and for my next work I will try to learn how to measure actual angle between robot itself and the surrounding environment.



Comments