Wheeled Biped Pt 1: Balance Simulation
I’ve officially finished all the work for my Masters degree and now I have some time to work on my hobbies before I start my job. I’ve been working on quite a few secret projects with YoYoFactory, as well as silly robots (maybe a swerve drive?) but I also decided to pick up on a long term project I’ve wanted to do for a while, building a wheeled bipedal robot!
After seeing the video of ETH Zurich’s wheeled bipedal robot, Ascento, a few years ago, I was really excited to build one for myself some day.
A wheeled bipedal robot is pretty interesting because it doesn’t require many actuators (4 in the case of Ascento), and it has many benefits of wheeled and legged robots. It can be quite maneuverable with its wheels, and it can also jump/walk over obstacles because of its legs. Plus it looks pretty cool because of its ability to balance.
I had some spare motors lying around and first I wanted to get a sense for what sort of actuators I would need. I started with the wheel actuators and decided to try to use some PropDrive 4248 (650kv) that I had leftover from Battlebots. The problem was I wasn’t entirely sure how much torque I would need for the wheels (some 3-7/8” Banebots wheels I also had lying around). My intuition was that I didn’t need much torque for balancing (hence the small size) but I also wanted to be able to jump up stairs which might require harsh acceleration and deceleration due to their small length to height ratio.
With these thoughts, it seemed like a good plan to make a simulator. I also hadn’t designed a balancing controller in a while (almost 3 years since I last did one for a lab in class) so the simulator would give me an opportunity to test out controllers. Plus with the quarantine in place, all my hobbies were limited to the digital realm for the time being.
I tossed a PropDrive, a Mini Cheetah actuator and a Banebots wheel in a Solidworks assembly to see what lengths looked right and to get a sense of masses and inertias. The estimates I got from this were based on intuition, but I knew I could make the simulator flexible enough that I could modify it as I progressed with the CAD model. I wanted to make the simulator so I could use it as a feedback tool to inform the CAD model, then use the CAD model to estimate the physical parameters and refine the simulator.
For the simulator I wanted to start by simulating a simple balancing robot. One with an actuated wheel and a passive body. Conveniently I had to write out the equations of motion for a Mobile Inverted Pendulum (MIP) in one of my previous classes and so I had them already. I used the Lagrange Equations and the energy method to derive them. I also found a research paper which had done the same method and I decided to use their angle conventions because they had already drawn nice figures.
I flipped one of my angles and matched my equations of motion to theirs
For completeness, I screenshot their figures and eom and put them here.
From there I used ODE45 to simulate the pendulum robot in Matlab, first starting off with no control torque, and watching the pendulum dangle. For the simulation I used the full dynamics (non-linearized). My states were wheel angle (phi), body angle (theta), and their first derivatives.
Then I linearized the dynamics, put the system in state space form, and used LQR to find my optimal gains. Q and R are arbitrary but as I fine tune my parameter models (mass, length, inertia, etc), I can change the Q and R to find optimal gains for the real hardware I will make some day. For now I’ll just tune them to make the simulator work well with its given parameter estimates.
At this point, I was able to make a visualizer and see everything that was happening in Matlab. However, due to the nature of ODE45 and the way I implemented control, I was doing torque control at whatever rate ODE45 was time stepping (it is dynamically changing). I tried to come up with a simple method of making torque a new state and keeping track of previous torque commands to make torque update at a fixed frequency, but decided it’d be easy enough to make my own solver.
So instead I made a fixed time ode solver and because of the way I wrote it, I could utilize previous torques without having to hack torque into a state. I ran both solvers simultaneously to look for major discrepancies but they looked pretty similar. The fixed time solver ran dynamics at 10 khz and torque control at 1 khz. I was pretty proud of the visualizer because I kind of forgot how powerful Matlab plotting was.
Because there wasn’t a major difference in the two solvers results and the fixed time integration had the more accurate torque control timing, I stopped using ODE45 and focused on the fixed timing simulation. I also added a nice torque plotter so I could see what torque was being applied while visualizing the robot.
In the simulation, the robot starts off with a forward velocity (in this case 1/4 max speed given its gear ratio), and it tries to hold its position while remaining balanced and obeying its torque/speed limits. The vertical line is drawn at a distance that represents the edge of a single step, because I want to make sure my robot can stop on a standard step (11 in long) after jumping with some forward velocity. From the first few simulations I found that I would likely need more torque than initially expected. I had hoped to make a 6:1 planetary gearbox out of leftover thesis gears, and then get some additional belt reduction from the motor to the wheel but the 18:1 or so I estimated I could get was borderline not enough. Luckily a Battlebot builder was selling some really cheap 16:1 P60s which mate directly to a PropDrive so I bought them and decided to use them. The simulation above utilizes this 16:1 reduction plus a 3:1 belt reduction.
Now that I’m happy with the balancing simulator (LQR works quite well) next steps include simulating jumping so I can get a good estimate for how much forward velocity I’ll have on landing, working on the CAD model now that I know what sort of reduction I’ll need, and refining this simulator. I’ll try to keep up the motivation and the blog posts! Once I start my job I’ll have access to a full machine shop again and can actually build the robot.