• 沒有找到結果。

Adding physics to the kiki simulation

在文檔中 Webots User Guide (頁 55-58)

4.3.1 Overview

The current model we defined for the kiki robot doesn’t include any physics modelling, as we didn’t specified any mass for example. 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. Finally, simulations run faster without physics.

56 CHAPTER 4. TUTORIAL: MODELING AND SIMULATING YOUR ROBOT

Figure 4.15: The kiki robot with a camera

However, as soon as things get more complex, you will need to introduce some physics in 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 turn out to be necessary. Finally, if you want to model a robot architecture different from the plain differential wheels model, like a omni-directional robot, a legged robot, a swimming robot or a flying robot, then you need to setup many physics parameter.

This section introduces a simple physics simulation to the kiki world allowing the robot to play with a ball. More complex physics simulations can be implemented with Webots, involving different locomotion schemes based on theCustomRobotand Servonodes, allowing to build complex wheeled and legged robots. Other possibilities include flying and swimming robots where hydrodynamics models are needed. These features won’t be addressed in this tutorial.

Instead, it is recommanded that you study the existing examples of legged and flying robots included within the Webots distribution, and refer to the documentation of the CustomRobot andServonodes. Do not hesitate to contact us if you need some support implementing complex physics in your simulation.

4.3. ADDING PHYSICS TO THEKIKI SIMULATION 57

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 thePointLight nodes. Turn that Transform into aSolid node using theTransform button (representing a lightning).

Now, it is possible to define a boundingObject for the floor. Create an IndexedFaceSet node as bounding object. In this node, create a Coordinate node for the coord field. This node should define the following point list: [ 1 0 1 ] [ 1 0 0 ] [ 0 0 0 ] [ 0 0 1 ]. The coordIndex should contain the 0, 1, 2 and 3 values. This defines a square corresponding to the ElevationGridof the floor. The bounding object we just defined will prevent the robot from falling down through the floor as a result of the gravity.

4.3.3 Adding physics to the kiki robot

The kiki robot already has a bounding object defined. However, since it will be moving, it also needs physics parameters that will be defined in itsphysicsfield as aPhysicsnode. Create such a node and set itsdensityto 100. The density is expressed is kilogram per cubic meter.

Leave the mass to -1, as it is ignored when the density is specified. If ever you wanted to use the mass instead of the density, set the density to -1 and set the mass to a positive value. The mass is expressed in kilograms. However, for the rest of this tutorial, it is recommanded to follow the guide and set the density as requested, leaving the mass to -1.

Now 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 theboundingObject for each wheel Solid. Then, add a Physics the first wheel, write WHEEL PHYSICS as a DEF name. Set the density to -1, themass to 0.01, the coulombFriction to 0.9 and the forceDependantSlipto 0.1. Use this WHEEL PHYSICS definition to define the physics of the second wheel. Finally, add aJointnode to thejointfield of each wheel. This means that each wheel is connected to the robot body through a joint.

We are now done! Save the world asmy kiki physics.wbt, reload it using the revert button and run the simulation. You will observe that the robot is moving not 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 in the kiki world

Now let’s 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 thesoccer.wbtworld. Double-click on the soccer. This should open the scene tree window and select the BALL solid. Simply copy it from theCopybutton and re-open yourkiki physics.wbtworld. Open the scene tree

58 CHAPTER 4. TUTORIAL: MODELING AND SIMULATING YOUR ROBOT window, select the last object of the scene tree and click on the Paste after. Can you see the soccer ball ? ReadHow do I move an object ?from theHelpmenu and place the ball in front of the robot. Save the world and run the simulation. The kiki robot should be able to kick the ball, making it roll and bounce on the walls.

在文檔中 Webots User Guide (頁 55-58)

相關文件