Webots User Guide

previous page go up next page

Foreword

Thanks

1. Installing Webots

2. Getting Started with Webots

3. Sample Webots Applications

4. Tutorial: Modeling and simulating your robot

5. Programming Controllers and Plugins

6. Using the e-puck robot

     

4.3 Adding physics to the MyBot simulation

4.3.1 Overview

The model we have defined for the MyBot robot does not include any physics modelling, as we did not specify any mass, etc. Instead it is a simple kinematic model which can be used nonetheless for many mobile robotics simulation experiments where inertia and friction can be neglected. For example, it is well suited to simulate light desktop robots like Khepera or Hemisson. Additionally, simulations run faster without physics.

However, as soon as things get more complex, you will need to introduce some physics to your model. For example, if your robot is heavy, you cannot afford to neglect inertia effects on its trajectory. If you want to add moveable objects, like boxes or a ball, physics simulation becomes necessary. Finally, if you want to model a robot architecture significantly different from the plain differential wheels model, like an omni-directional robot, a legged robot, a swimming robot or a flying robot, then you need to setup many physics parameters.

This section introduces a simple physics simulation to the MyBot world allowing the robot to play with a ball. More complex physics simulations can be implemented with Webots, involving for example different locomotion schemes based on the Robot and Servo nodes, allowing you to build complex wheeled and legged robots. Other possibilities include flying and swimming robots where hydrodynamics models are needed. These features will not be addressed in this tutorial. Instead, it is recommanded that you study the existing examples of legged and flying robots included with the Webots distribution, and refer to the documentation of the Robot and Servo nodes. Do not hesitate to contact us if you need some support implementing complex physics in your simulation.

4.3.2 Preparing the floor for a physics simulation

Select the floor node, which should be the first Transform node in the scene tree, just after the PointLight nodes. Turn that Transform into a Solid node using the Transform button.

Now it is possible to define a boundingObject for the floor. Create a Transform node containing a Box as the bounding object. Set the size field for the Box to [ 1 0.02 1 ] and the translation field of the Transform to [ 0.05 -0.01 0.05 ]. The bounding object we just defined will prevent the robot from falling down through the floor due to gravity.

4.3.3 Adding physics to the MyBot robot

The MyBot robot already has a bounding object defined. However, since it will be moving, it also needs physics parameters that will be defined in its physics field as a Physics node. Create such a node and, as it is recommended to use the mass instead of the density, set its density to -1 and its mass to 0.5. The density is expressed in kilograms per cubic meter, and the mass in kilograms. The mass is ignored when the density is specified.

The wheels of the robot also need some physics properties to define the friction with the floor. But first they need a bounding object. Set the defined WHEEL node as the boundingObject for each wheel Solid. Then, add a Physics node to the first wheel, and enter WHEEL_PHYSICS as a DEF name. Finally, set the density to -1, the mass to 0.05, the coulombFriction to 1 and the forceDependantSlip to 0. Use this WHEEL_PHYSICS definition to define the physics of the second wheel.

We are now done! Save the world as my_mybot_physics.wbt, reload it using the revert button and run the simulation. You will observe that the robot is not moving very steadily (especially if you look at what the robot's camera sees). That's physics! Of course you can improve the stability of the movement by adjusting the bounding object of the robot, the speed of the wheels, the friction parameters, etc.

4.3.4 Adding a ball to the MyBot world

Now let us offer a toy to our robot. Instead of creating a ball object from scratch, let's borrow it from another world where such an object already exists. Open the supervisor.wbt world. Double-click on the soccer ball. This should open the scene tree window and select the BALL solid. Simply copy it using the Copy button, then re-open your mybot_physics.wbt world. Open the scene tree window, select the last object of the scene tree and click on Paste after. Can you see the soccer ball ? Read How do I move an object ? from the Help menu and place the ball in front of the robot. Save the world and run the simulation. The MyBot robot should be able to kick the ball, making it roll and bounce off the walls.

previous page go up next page
^ page top ^

  E-mail to webmaster Last updated: Copyright © 2008 Cyberbotics Ltd.