Hi! I recently started making a robot with a friend and here I thought it would be fun to document our adventure. We are not finished by any means but I think writing this would be a good practice.
Phase 1: Backstory
To start, our goal is to make a walking robot. I always wanted to make one because back when I was in Junior high, I attempted to make one like below
The legs are meant to go on either side. This was inspired by a Japanese book I had here
but the main problem with this was that
- I couldn’t figure out a good algorithm for walking.
- The motors, particularly the ones at the ankles, weren’t able to give enough torque to rotate properly.
So overall it was a big failure. This whole venture cost me like 100–200 dollars which was quite a big loss for me at the time so I gave up on robots for a while.
Phase 2: Idea
I’ve gotten into university. I’ve been studying AI for a while doing coops so I figured why not try out making robots again. A friend I met through AI also had a similar idea so we decided to work together on it. Our final plan is to make something like below
But just the lower half.
Phase 3: Making a plan
Our final objective was to make a robot that can walk and we don’t have other specifications. But we thought it’ll be good to first make a cad and simulate which is a good use of reinforcement learning. For this, we decided to make the cads in freecad since that was free and for the simulation, we were thinking of using Simulink. The reason I was thinking of using Simulink for robot simulation was that I knew there was a reinforcement learning library/plugin for it as well as a way to import cads as I read from the book here.
We first got some mg996r servo motors but then I remembered the problem with my last robot where we didn’t have enough torque. So, I did a rough calculation below to see the maximum amount of torque we need.
First, we have 12 servo motors. I assumed that each servo motor was at 60 g(while mg996r servos are 48g or so) and that the longest width of each motor is roughly 54mm. And from the picture above I assumed that roughly 4 servo motor width is the length of the leg. So 20 cm in length.
So, assuming all the servos are supported by one servo where all the servos are at the max length of 20cm, we get
which is a bit more torque than mg996r servos had which is roughly1Nm. So we got 20kgfcm and 30kgfcm servos which have roughly 2Nm and 3Nm so they should be more than enough torque.
Phase 4: Cad Design
We decided to use a similar design to my first design like this
Where we can just combine these pieces for all the servo motors like below:
We made the cads of the servo motors, frames, nuts, and screws in freecad. Here are the images of them. I used this excellent tutorial for learning how to do this
Now, I was thinking of importing directly into Simulink.
Here was our first mistake: we weren’t able to directly import the 3d models from freecad to Simulink. Well, technically we can but when we want to connect objects like the above with joints and rotation, we couldn’t find an easy way to do it.
When we want to import into Simulink we need to use the smimport function if we want to have the objects connected(assembled). We can make an assembly using freecad but this won’t work for Simulink. The reason freecad assemblies won’t work for Simulink is that Simulink requires an XML file that is exported from
Autodesk Inventor®, PTC®, and SolidWorks® CAD models into XML files
Here’s our second mistake: we thought fusion 360 can be used for this too. While we couldn’t figure out how to do assemblies in fusion 360, we moved each frame and servo motors to relative positions just to see if they fit together.
Of course, they didn’t fit together so we needed to fix it but we ended up with an assembly(just from a relative position) like this
for just the left leg. As you can see, it was heavily influenced by the robot in the idea phase. Of course, there were a few problems here but it was a start. However, we still need to use Autodesk Inventor if we want to make a simulation with Simulink.
Phase 5: Autodesk Inventor
We were now making an assembly in Autodesk Inventor Pro 2023 trial. I didn’t know how to do this but I followed this tutorial. The main idea for assembly is that when we combine parts, we want to constrain the degrees of freedom of each part. For example, the servo motor handle must rotate in the same way as the servo frames and the handle’s face must stick(through nuts and screws) to the surface of the servo frame. That’s the idea and we got the legs like this
The first mistake here: we used the .obj file we exported from freecad. There was a problem here. The units for freecad were mm but when I export to .obj and import into Inventor, the units are assumed to be inches or something like that so the model becomes way too large. The solution here was basically to use any other format than obj to export. Like step format is the best one. Another method is to make all the pieces in Autodesk Inventor but we were too lazy to learn how to do that since we already learned it in freecad.
The second mistake was that I didn’t use reference models. The problem with this was that every time I found I made a mistake in the cad, Inventor just remembers the old model. So the only way for me to fix that mistake is to fix the mistake in freecad, export it, and restart the robot building in Inventor from scratch. So every mistake discovered restarts the entire assembly from the beginning. I learned the solution by asking here and basically, it is to export in the step format and use the reference model when importing. Then every time I update the cad it’ll update in Inventor.
The problem with this approach is that I can’t assign materials but that’s a minor issue. It just meant that we couldn’t say the frames were aluminum or plastic. I need to confirm later, but it may lead to difficulty in exporting too.
Another thing I did that led to a mistake later was I used assembly models within each other. For example, in the last leg, I had 3 assembly files: The top part with 2 servos. A left leg, and the right leg.
Now, here was our final mistake: we couldn’t export the XML from Autodesk Inventor. This was because the plugin to export doesn’t support Autodesk Inventor version 2023. The supported version was 2021.
The easiest way we knew how to get everything in 2021 ways to make the robot from scratch in version 2021 again which we did.
Phase 6: Matlab export
Now we have successfully made the full model in Autodesk 2021 Profession like below
We installed the plugin and exported it to the XML too.
Now to import to Matlab we just do smimport by going to the directory of the XML file. One slight mistake we did here was trying to import the XML from a different directory. What this does is Matlab can’t find the 3d files. So it’ll just give an empty simulation.
Once we do it properly, it looks like this when we start the simulation
This is the top.
One problem here is that this script ignores all the joints that are not in the base iam(Inventor Assembly) file. So, essentially, this is the same in the simulation for the fusion 360 where all the files are just placed relative to each other except for the nuts connecting the top servo motor iam files with the bottom one. So, let’s say we rotated a servo motor. In inventor, we have servo motor able to rotate the servo motor handle and thus all the parts it can rotate. But in this simulation, we need to make ourselves the joint and rotate it and only the handle will rotate with nothing attached to it.
We found that the solution here is to not use multiple assembly files within each other and just make everything from the base. We tested it here with one servo motor
and it rotated with the pieces attached correctly. We are currently stopped here. I’m planning to test with two motors next but essentially build the entire cad assembly without importing iam files like before. Will make an update once more interesting things happen.
Phase 7: Making frames(At the same time as MatLab simulation)
Aside from that we 3d printed our first frame using a 3d printer we found at our university. It looks like this now
There were a few issues here
- The little strings were quite a bit of an issue but my friend hypothesized that while 3d printing, it dropping down causes the strings to form. So, printing on the side should fix this problem
- 3d printing this one frame took 1 hour. Since we have roughly 20 frames, printing all of them will take at least an entire day or two.
- I’m not confident if the plastic is durable enough for all the pieces. We can make the frames thicker(currently 3mm) perhaps but I think the best idea is to use aluminum for the parts the places that require durable pieces. However, one problem with this idea is that there’s no good way I can think of where we can judge which parts need to be durable.
- I’ll need to check this but the size/dimensions of the frame may not be accurate to the frame. But I’ll double-check this.
Overall, I’m still undecided if I want to continue with the 3d printer but we are looking forward to having a physical body in front of us. This is the whole reason we are making a robot. The feeling of actually making something that moves and walks is incomparable, for me, to just having a website working or an AI model doing what I want.
Our robot adventure has many hiccups and in the future will have even more hiccups but we are having fun which is what matters.
P.S. I might make an article about my diffusion model adventures since that’s quite fun too but we’ll see