Guy on Simulink

Simulink & Model-Based Design

Models Inspired by Real Life 20

Posted by Seth Popinchalk,

Often models are the predecessor to a real-life device; however, sometimes a device inspires the model. In the 1980s, there was a group known as the Leg Lab at CMU who researched running robots.  In 1986 the Leg Lab moved to MIT.  Some of their robots are now on display at the MIT Museum, and they still inspire wonder in visitors today.  One of those robots is a 3-D One-Legged Hopper which inspired my colleague, Guy Rouleau.

I saw this robot at the MIT Museum last winter and after discussing with few colleagues at The MathWorks we decided that it would be cool to have a Simulink model of this robot.

Read on to learn about how Guy constructed and controlled this one-legged hopper (download from the file exchange).

2-D hopping robot animation

Simulation and Control of a One-Legged Hopping Robot

By Guy Rouleau

Robot modeler, Guy Rouleau

Here is the description of a one-legged hopping robot Simulink model I completed recently. I will explain how I prepared and implemented this simulation.


Before modeling any system in Simulink, it is always good to have a plan. To begin I always like to draw a simple representation of the system I want to model. In this picture we see two bodies (let’s call them body and leg) connected together at the hip. The robot has two actuated degrees of freedom (DoF) in his configuration space, the angle between the body and the leg, and the length of the leg. These 2 DoF will be used to control the 3 DoF motion of the body in space (height, distance and angle). 

Hopping robot diagram

Now that the robot is described, it is time to think about how to control it. The robot control can be divided into three independent controllers:

  1. Attitude Control - The length of the leg is controlled by a pneumatic actuator. This actuator behaves like a spring. It gives a smooth
    landing and injects force to keep the robot bouncing.
  2. Velocity Control – As when a person walks, the leg is brought in front of the body while it is in the air. While the leg touches the ground, then the body is brought in front.
  3. Orientation Control - During the stance, the leg is in contact with the ground. A torque is applied at the hip to control the angle of the body.

The following picture shows the three controllers graphically:

The Three hopping robot controllers

Now I have a good idea of what to implement, it is time to have fun and play with Simulink. For this model, SimMechanics is the most appropriate Blockset to
model the robot.


When I begin a SimMechanics model for a moving robot, I like fixing the position of the body in space. By doing so, I can verify if the configuration of the
actuators behaves as expected. This SimMechanics model looks like this:

SimMechanics model of a hopping robot

Using this model I can test different inputs and see the resulting motion at the tip of the leg. Once I am satisfied with this motion, I can think about the interaction with the ground.

My new goal is now to see the robot falling from a certain initial eight, bouncing a few times and fall. To model the ground, I use the Bouncing Ball demo provided with SimMechanics. After grouping components within subsystems, the model now looks like the following picture.

Once the contact forces and robot motion are validated, it is time to implement the control architecture.

Typically, when I implement a controller I like to divide the model in the following subsystems:

Sensor modeling

This subsystem extracts and processes the information from the SimMechanics model to generate signals that could be provided by real sensors. For the hopping robot, I will measure the following:

  • Angle between leg and body
  • Angle of the body relative to the ground
  • An on/off contact sensor.

Motion Analysis

Based on the sensors, the information necessary for the controllers is computed. The contact switch is used to compute the duration of the flight and stance period. These durations, along with the hip and body angles can be used to estimate the robot velocity and displacement.


With all the necessary information available, it is time to generate the actuator signals for the 3 control modes.

  • Attitude
    – The same amount of force is injected by the pneumatic actuator at each jump. This generates jumps of constant eight and duration. The amount of force injected can be adjusted to obtain the desired jump eight, but for now, it will be kept constant.
  • Velocity – This is the most complex controller in this robot. First, we look at the displacement during the previous jump. While in
    flight, the tip of the leg is positioned in front of the robot body to prepare a motion similar to the previous jump. Also during flight, the leg
    tip position is modified depending if the robot must accelerate or decelerate. Landing with the leg farther in front of the body will
    accelerate the robot, while a leg tip closer to the body will decelerate it. A simple trajectory generation is also implemented to move the leg
    smoothly during the flight.
  • Orientation – In this phase, a hip torque is computed to keep the angle of the body with the ground close to zero. Combined with the
    Velocity controller, the Orientation controller pushes the robot in the right direction.

After implementing the 3 controllers, it is time to visualize what the resulting motion looks like.

Animation of a 3-D Hopping robot VR scene

The description above contains the main steps I followed to create the hopping robot simulation. For more details, I suggest visiting the MATLAB Central file Exchange to download the Simulink model of this one-legged hopping robot.

When looking at the model, you will see that I omitted many details to make a short story. But the main process I use to create most of Simulink models is described here.

Have you ever built a robot?  What do you think about this model?  Please leave a comment here.

20 CommentsOldest to Newest

João Henriques replied on : 1 of 20

This is immensely cool, I’m off to open this model and learn from it! Thank you for sharing wisdom :)

amie replied on : 2 of 20

i would like to ask how u can simulate that robot with running. i have done for my biped robot but it cant move. any idea for that.. hope u can help for that problem.

Xavier replied on : 3 of 20


I am working on a 4-wheeled robot which could avoid obstacles using an ultrasonic sensor. I would like to test my algorithm using a SimMechanics/Vrbuild model. I have some experience using matlab so I figure out how to model my robot under simmechanics and vrbuild and animate them. But two problems remain :

First, I can’t figure out how to link the robot to the floor, wether using a planar joint between the body and the floor or some joints between the wheels and the floor.
Any idea of how to do it correctly?

Secondly, I have several ways to retrieve the position and orientation of my robot and the position of the obstacles and I could work with that. But I would like to simulate the ultrasonic sensor which, while sweeping the area in front of the robot, output the distance from the robot to any surface that the beam encounter.
I wanted to use the proximity sensor on vrbuild but I didn’t manage to retrieve the information from the sensor. Do you any advice on the use of this sensor?
Do you know if it is possible to simulate my sensor in an other way?

Any help would be much appreciated. If you need more information feel free to email me.

Thank you for taking some time to read me.


Xavier Wiedmer

Guy Rouleau replied on : 4 of 20

Hi Xavier, this is an interesting project.

1. The implementation of the robot-floor interaction depends on the goal of your simulation. In general I recommend choosing the simplest implementation that gives you the accuracy you need. If you only care about the kinematics of the robot, a planar joint is a good solution. It is simple and should simulate fast. At the other end of the spectrum, if the dynamic of the wheel-floor interaction is important, you can go in details. Sense velocity and position of each wheel and compute the resulting force/torque to apply back to each wheel. The configuration of your wheels also can influence your choice. An holonomic configuration is easy to model with just a planar joint, while a car-like configuration requires more constraints.

2. I never used the Proximity Sensor of the V-Realm Builder, so I cannot comment on that. In SimMechanics there are multiple ways to use joints to model non-contact sensors, like a laser for example. I just published an example of this type of implementation (The link should be available tomorrow, April 21st):

However, usually ultrasonic sensors detect obstacles in a sort of cone shaped zone. For that I don’t see any ready-to-use solution. I would start by measuring the coordinates of the relevant CS. Then I would compute the limits of the zone covered by the ultrasonic sensors and see if any of the target CS are inside. This type of computation might be easier to implement in a script than using blocks, so I think I would use the MATLAB Function block (previously Embedded MATLAB Function block).


Mahdi Nezami replied on : 5 of 20

Hi,thanks for your attempt.I need the details of the simulink regarding one legged hopping robot as more as possible and as soon as possible, because your project is excellent. Bests.

fady replied on : 6 of 20

*Thank you for your explanation.
* I am very new to simulink, and i have downloaded the model you offered. however, how I can run it to see it works?

Seth Popinchalk replied on : 7 of 20

@Mahdi Nezami – I just confirmed that the link still works. Start by downloading the file from the File Exchange.

@fady – In MATLAB, cd to the directory with the model, then type the model name. Then, from the Simulink interface, press the triangular play button, or from the Simulation menu, click Start. Good luck!

Asiya replied on : 8 of 20


Thank you for the useful model.
I have done the walking robot using the bouncing ball example provided by Matlab/Simulink Help and it is working fine. This by appling 4 contact point in each leg (plate-like).
However, I did apply the friction but the bushing joint is causing a restriction for my model.
For example, if I did attach the Bushing joint to the body center of mass only, the rolling motion will be restricted and the robot will looks like swinging on air and it’ll not move forward!!
But If I did attach it on one foot and connect it to ground block, it will stick with ground in the double suuport phase and the other leg will swing and vise versa if I did attach the bushing joint to boot foots.

So can you help me??


Guy Rouleau replied on : 9 of 20

@Asiya, your application looks very interesting!

Unfortunately I think I am missing a few things to be able to help you.

The Bushing joint alone should not cause any restriction, because it allows 6dof motion. Do you connect actuators to it? do you have other explanations on why it causes restriction?

In general, I recommend using the Six-DoF joint instead of the Bushing, because it does not suffer from Gimbal lock.

I hope this helps.


Asiya replied on : 10 of 20

Thanks for your reply..
Actually, I did try both (6-dof & bushing joints) but I’m still facing the same restriction in one leg.
I’m not using an actuator to the joint because I did notice that the joint actuator will impose the output to zero if no input is connected to it. (I did overcome this problem in of my models by using 2-enabled-system with the same model and states, just to ensure that the actuators moves freely before applying control to it :D ).
Ok, Let me describe my mode: the robot has 2 DOF in the hip, 1 DOF in the knee, and 2 DOF in the Ankle.
I did create a special function to generate the rolling angles and another one to generate the pitching motion.

While motion generation the body should roll side-to-side, and then the legs will be lifted by the pitching function.
At the beginning the left leg is lifted as the body rest on the right leg which supports the body without slipping because of friction.
Then, when the left leg should support the body it slips because the right hip and knee are bended but the foot doesn’t move forward (s locked with the ground).
I hope that my problem is clear now.

By the way, I suggest to introduce a new block to SimMechanics represents the ground contact (reaction forces) in a simple way so that beginners can use it.
Also, I would like to share some of my SimMechanics models in the future :).

moon replied on : 11 of 20


am tring to draw a swinging leg with 2 links and a mass on the tob..
but the system is falling down when appling a force at a certain time???

how i could solve it

Amir replied on : 12 of 20

Thanks for this nice model.
I am trying to model a planar passive hopper which would hop on a slope without a need of any actuation. I believe that my model would be similar to yours, however in my model I have a foot mass, a top mass, a massless bar between to masses (I am not sure if I need this one), a linear spring between to masses and two torsion springs between each mass and the bar. I want to have two contact points at the foot and I want to model the ground as spring-damper system where two types of friction (stick and slide) exist. Do you suggest to make my model based on the bouncing ball model or your presented model? Do you have any hints for me?

Thank you

Guy Rouleau replied on : 13 of 20


It looks like you are on the right track. As you probably noticed, the SimMechanics bouncing ball demo (mech_bouncing_ball.mdl) implements only the contact force perpendicular to the ground. So you will need more.

If you want your robot to move forward (parellel to the ground), you will need to implement contact in this axis too. My model does that, but does not implement stick and slip.

For the stick and slide part, I recommend looking at the documentation for the “Joint Stiction Actuator”. I am not sure if you will be able to use this block directly, but its documentation should give you some ideas.

Fabricio replied on : 14 of 20

Good Afternoon, I’m trying to simulate the motion of a human arm for my final project at the university. I only have to classify 5 motions: forearm’s flexion, extention, pronation, supination and prehension. I’ve already calculated the inertial moments and masses. The inputs comes from a neural network and then I intoduce them into simmechanics in order to provide motion to a virtual reality scene (V-realm Builder). My problem is when I run the simulation, the forearm, hand and fingers separate each other and don’t do the motions in the correct axis. This only happens in VRML. However, in simmechanics’ visualization don’t have any problem with motions, the bodies do the movements in the form and axis and I don’t have any error message. Can you give me please some clue about how can I deal with these in simmechanics and v-realm builder simulation? Thank you in advance for your help.

Guy Rouleau replied on : 15 of 20

@Fabricio: This seems to be a problem with the way your coordinates are defined in VRML. I suggest starting with something simple, just one degree of freedom. This will help you understanding the problem. Once you have it figured for one joint, you should be able to add additional degrees of freedom one at a time and validate them.

Fabricio replied on : 16 of 20

Thank you for you advice.. I did what you said and It worked perfectly…And I had another problem!! As I say before I´m doing the motions´ arm simulation in simulink and I’m calculating the energy and some other parameters that enter to a neural network. My problem is that I have to take 1 value every 50… I do this because I windowed the myoelectric signal every 50 ms. So the energy`s value is 1 every 50 samples. If you could help me I’d appreciate so much!!…. This is the way I do it in matlab… and I want to do it in simulink…. y=u(50:50:3200,2);

rakibul hasan replied on : 17 of 20

Hello Guy,

I am a PhD student working on multi fingered robot hand for grasping. For grasping issue, I need to model a contact between fingertip and stiff simple object with known location and geometry for measuring contact force. This can be done in simulink easily. I am trying to implement in Simmechanics. I already had a look at bouncing ball model. For example, I have 2 dof planar robot hand and a vertical wall model. I defined end link of robot and also defined wall with weld joint. Assume for simplicity that I will get force only in horizontal direction and also defined condition to get contact force.Now, do I need to put an extra degree of freedom between fingertip body and object body? I am stucked at this point. If you have any option, I can send the file, too.

Your help will be appreciated. Thank you.

jone replied on : 18 of 20

Hi Guys
this is very great project and its very useful
I have problem and I need your help
I am trying to simulate contact between two bodies to get contact force component (fx,fy,fz)
is there any way to do that !!!
thank you all

Guy Rouleau replied on : 19 of 20

@Jone: There is no block in Simulink that automatically compute the contact force between two bodies. This can be implemented using basic math blocks as I did in this model. That way you have the flexibility to implement any contact model you desire.

Cakan replied on : 20 of 20

Dear Sir, I am trying to model a bipedial walking with simple bars but I cant give interaction between legs and floos. Can you make a tutorial and simple model about this subject? I showed in simple picture. . Thank you so much..

example :

here is a tutorial but not with files and clear explanation . it seems very complex.

Add A Comment

Your email address will not be published. Required fields are marked *

Preview: hide