How to create a new project
Wizard - New project directory
Scene Tree
Scene tree is a representation of the current world
How to create a controller
Wizards - New Robot Controller
How to link a controller with a robot
Scene tree - “Robot” - Controller - Choose
Sensors and Actuators in Robot(class):
#include <webots/Robot.hpp>
Accelerometer *Robot::getAccelerometer(const std::string &name);
Camera *Robot::getCamera(const std::string &name);
Compass *Robot::getCompass(const std::string &name);
Connector *Robot::getConnector(const std::string &name);
Display *Robot::getDisplay(const std::string &name);
DistanceSensor *Robot::getDistanceSensor(const std::string &name);
Emitter *Robot::getEmitter(const std::string &name);
GPS *Robot::getGPS(const std::string &name);
Gyro *Robot::getGyro(const std::string &name);
InertialUnit *Robot::getInertialUnit(const std::string &name);
LightSensor *Robot::getLightSensor(const std::string &name);
Motor *Robot::getMotor(const std::string &name);
Pen *Robot::getPen(const std::string &name);
PositionSensor *Robot::getPositionSensor(const std::string &name);
Receiver *Robot::getReceiver(const std::string &name);
Servo *Robot::getServo(const std::string &name);
TouchSensor *Robot::getTouchSensor(const std::string &name);
DESCRIPTION
These functions return a reference to an object corresponding to a specified name. Depending on the called function, this object can be an instance of a Device subclass. For example, if a robot contains a
DistanceSensor node whose name field is "ds1", the function getDistanceSensor will return a reference to a
DistanceSensor object. If the specified device is not found, the function returns NULL in C++, null in Java or thenone in Python.
DARwIn-OP model
The DARwIn-OP model contains principally:
- the 20 DOF
- LEDs
- accelerometer
- gyro
- camera
- realistic physics
There is no emitter or receiver in this model, so if we want to use emitter and receiver, we have to use other robots or define robots our own.
Supervisor
Supervisor is a special kind of robot. They can call functions of other robots and can also take a screen shot or a video of the simulation, restart or terminate the simulation, etc. It can read or modify the value of every fields in the Scene Tree, e.g. read or change the position of robots, the colors of objects, or switch on or off the light sources, and do many other useful things.
How to make a robot hover in the air
The key idea here is to give the robot some force to overcome gravity.
Give the robot a name:
Scene Tree - Aircraft - DEF: AIRCRAFT
2. Give the robot a initial position:
Scene tree - “aircraft robot” - translation - 0, 0.5, 0.5
3. Create a physics plugin:
Wizard - New Physics Plugin
4. After that, we will get a physics file in C or C++
5. In the physics file:
Define a dBodyID which will refer to the aircraft:
static dBodyID body1;
6. In the function void webots_physics_init(dWorldID world, dSpaceID space, dJointGroupID contactJointGroup) of the physics file, initialize body1:
body1 = dWebotsGetBodyFromDEF("AIRCRAFT");
7. In the function void webots_physics_step() of the physics file, add the force which would overcome gravity:
if(body1) dBodyAddForce(body1, 0, 9.81, 0);
8. Add the physics plugin into the project:
Scene tree - WorldInfo - physics - Select - “my-physics”.
How to output to console
Include the file stdio.h and use printf(“hello\n”).
The tricky thing here is that the command in printf must end up with a ‘\n’. Else it will not be output.
How to make a robot move in the air
The basic idea is to make the robot communicate with the physics plugin with radio and add force in the physics plugin to help it move.
Add an emitter in the robot to communicate with physics plugin:
Scene tree - “robot” - child - add emitter
2. Set Emitter range to -1, channel to 0, baudRate to -1. This is because the physics can only receive radio in channel 0.
3. Send the signal where you want the robot move with function wb_emitter_send.
4. In the physics plugin, receive the signal sent by the robot with function dWebotsReceive.
5. Use the function dBodyAddForce to give force to the robot and make it move.
PS.
If we only want the robot to move for several steps, we should remove the force given before by adding the opposite force.
If we want to make the robot move with keyboard instructions, we should enable keyboard in the robot controller and listen to the keyboard.
If we want to use one robot to send instruction to another robot to make it move, we can just sent radio signal in channel 0 with the designed data format.
- ASP.NET Core 1.1.0 Release Notes
ASP.NET Core 1.1.0 Release Notes We are pleased to announce the release of ASP.NET Core 1.1.0! Antif ...
- Android Weekly Notes Issue #237
Android Weekly Issue #237 December 25th, 2016 Android Weekly Issue #237 这是本年的最后一篇issue, 感谢大家. 本期内容包括 ...
- Android Weekly Notes Issue #230
Android Weekly Notes Issue #230 November 6th, 2016 Android Weekly Issue #230. Android Weekly笔记, 本期内容 ...
- Android Weekly Notes Issue #229
Android Weekly Issue #229 October 30th, 2016 Android Weekly Issue #229 Android Weekly笔记, 本期内容包括: 性能库 ...
- Android Weekly Notes Issue #227
Android Weekly Issue #227 October 16th, 2016 Android Weekly Issue #227. 本期内容包括: Google的Mobile Vision ...
- Android Weekly Notes Issue #221
Android Weekly Issue #221 September 4th, 2016 Android Weekly Issue #221 ARTICLES & TUTORIALS And ...
- Android Weekly Notes Issue #219
Android Weekly Issue #219 August 21st, 2016 Android Weekly Issue #219 ARTICLES & TUTORIALS Andro ...
- MAGIC XPA最新版本Magic xpa 2.4c Release Notes
New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Ta ...
- Magic xpa 2.5发布 Magic xpa 2.5 Release Notes
Magic xpa 2.5發佈 Magic xpa 2.5 Release Notes Magic xpa 2.5 Release NotesNew Features, Feature Enhance ...
随机推荐
- [f]动态判断js加载完成
在正常的加载过程中,js文件的加载是同步的,也就是说在js加载的过程中,浏览器会阻塞接下来的内容的解析.这时候,动态加载便显得尤为重要了,由于它是异步加载,因此,它可以在后台自动下载,并不会妨碍其它内 ...
- 产品中 configure/cross compile的一个bug
在mac机上, 为iPhone版本编译产品. 运行./configure报错如下: configure:22793: error: cannot run test program while cros ...
- OpenSessionInViewFilter 的配置及作用
spring为我们解决hibernate的Session的关闭与开启问题. Hibernate 允许对关联对象.属性进行延迟加载,但是必须保证延迟加载的操作限于同一个 Hibernate Sessio ...
- IPD模式下开展敏捷开发的一些问题汇总
1. 我们现在普遍用的是老系统情况下,什么时候把软件和硬件在敏捷项目里面集成? 答:有两种场景:第一种场景是把软件分几个迭代,最后把软件和硬件一起集成:第二种场景是更好的一种场景,每几个迭代 ...
- js 操作map对象
转自:http://smallvq123.javaeye.com/blog/823923 /* * Map对象,实现Map功能 * * * size() 获取Map元素个数 * isEmpty() 判 ...
- URAL 1915 Titan Ruins: Reconstruction of Bygones(思路)
搞这个题差不多是从比赛开始到结束. 从自信慢慢的看题一直到wrong到死. 这个题目可以说成是思路题,以为我们只要明白一点,这道题就成了纯暴力的水题, 那就是当操作数不足栈中数字数目的时候,我们就没有 ...
- MySQL 外键异常分析
外键约束异常现象 如下测例中,没有违反引用约束的插入失败. create database `a-b`; use `a-b`; SET FOREIGN_KEY_CHECKS=0; create tab ...
- SQL语句汇总(二)——数据修改、数据查询
首先创建一张表如下,创建表的方法在上篇介绍过了,这里就不再赘述. 添加新数据: INSERT INTO <表名> (<列名列表>) VALUES (<值列表>) ...
- ASP.NET MVC学习之模型绑定(2)
3.手工调用模型绑定 很多情况下我们都是通过形参的方式接收来自http流中的数据,这看似是完美的,但是缺少了很多过程中的控制,所以我们就需要使用手工的方式进行绑定.下面我们通过一个例子来说明,首先打开 ...
- 轻松实现ajax登录时让浏览器保存密码
将登录页面由form提交改为ajax提交,发现一个副作用——登录时浏览器不会提示是否保存密码,这样每次登录都要输入用户名/密码. html代码如下: <script> $(function ...