Webots step
You will program the robot to go forwards until an obstacle is detected by the front distance sensors, and then to turn towards the obstacle-free direction. We would like to program a very simple collision avoidance behavior. %figure "UML state machine of a simple feedback loop" The string labels corresponds to the distance sensor names."
![webots step webots step](https://pic1.zhimg.com/v2-76fcb1292d8676926562ca8114fd8d50_r.jpg)
The red lines represent the directions of the infrared distance sensors. The green arrow indicates the front of the robot.
#WEBOTS STEP MANUAL#
The documentation on the API functions can be found in Reference Manual together with the description of each node. The controller API is the programming interface that gives you access to the simulated sensors and actuators of the robot.įor example, including the webots/distance_sensor.h file allows to use the wb_distance_sensor_* functions and with these functions you can query the values of the DistanceSensor nodes. While 4096 means that a big amount of light is measured (an obstacle is close) and 0 means that no light is measured (no obstacle). The values returned by the distance sensors are scaled between (piecewise linearly to the distance). We will explain later how these nodes are defined.įor now, simply note that a DistanceSensor node can be accessed through the related module of the Webots API (through the webots/distance_sensor.h include file). These nodes are referenced by their name fields (from ps0 to ps7). The distance sensors are modeled by 8 DistanceSensor nodes in the hierarchy of the robot. The way that the distance sensors are distributed around the turret and the e-puck direction are depicted in this figure. In order to create the collision avoidance algorithm, we need to read the values of its 8 infra-red distance sensors located around its turret, and we need to actuate its two wheels. from the Wizards menu Then, choose your programming language and the file name.Ĭontroller programming requires some information related to the e-puck model.
#WEBOTS STEP HOW TO#
%spoiler " Reminder: How to create a new controller?" Modify the controller field of the E-puck node in order to associate it to the new controller. Hands on #1: Save the previous world as collision_avoidance.wbt.Ĭreate a new C (or any other language) controller called e-puck_avoid_collision (for C++ and Java call it EPuckAvoidCollision instead) using the wizard. Some rudimentary programming knowledge is required to tackle this chapter (any C tutorial should be a sufficient introduction).Īt the end of the chapter, links to further robotics algorithms are given. The study of robotics algorithms is beyond the goals of this tutorial and so it won't be addressed here. This tutorial only addresses the correct usage of Webots functions. This tutorial will introduce you to the basics of robot programming in Webots.Īt the end of this chapter, you should understand what is the link between the scene tree nodes and the controller API, how the robot controller has to be initialized and cleaned up, how to initialize the robot devices, how to get the sensor values, how to command the actuators, and how to program a simple feedback loop.
![webots step webots step](https://img-blog.csdnimg.cn/20210219191624928.png)
![webots step webots step](https://img-blog.csdnimg.cn/20200417142944380.png)
We will design a simple controller that avoids the obstacles created in the previous tutorials. Now we start to tackle the topics related to programming robot controllers. Tutorial 4: More about Controllers (30 Minutes)