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 ...
随机推荐
- 一些gem的简要翻译(欢迎提出问题共同讨论)
写这篇文章主要有两方面用途 1.希望给rails同行一定的帮助,翻译水平有限,贴出中英文,翻译有误的地方欢迎指正,非常感谢,转载请标明出处,谢谢. 2.加深作者对gem的理解,有需要更详细了解安装以及 ...
- T4模板之初体验(语法)
一.什么是T4模板 T4是Text Template Transformation Toolkit(文本模板转换工具包)的四个英文首字母的简称.是微软提供的一种代码生成引擎. 在ADO.NET实体数据 ...
- 对于C++窗口编译一闪而过的解决方法 (DEV CPP下)
对于C++窗口编译一闪而过的解决方法 首先来看一个简单的程序(编译环境为 DEV C++.): #include <iostream> int main() { std:: ...
- java反射保存
前言 代码是我师父的,代码是我师父的,代码是我师父的,如有需要拿走的时候请标注 copyright by 山人Wu 记录这篇是为了加深理解,前段时间只是当做工具类来用,才有时间好好看一下,加深理解 ...
- 【原创】-- tftp安装配置及使用
环境:Ubuntu 14.04 OK6410 环境搭建: (1) $ sudo apt-get install tftp tftpd openbsd-inetd 或者安装tftp的增强版本tftp- ...
- 从0开始学Swift笔记整理(二)
这是跟在上一篇博文后续内容: --函数中参数的传递引用 类是引用类型,其他的数据类型如整型.浮点型.布尔型.字符.字符串.元组.集合.枚举和结构体全部是值类型. 有的时候就是要将一个值类型参数以引用方 ...
- 微软BI 之SSIS 系列 - MVP 们也不解的 Scrip Task 脚本任务中的一个 Bug
开篇介绍 前些天自己在整理 SSIS 2012 资料的时候发现了一个功能设计上的疑似Bug,在 Script Task 中是可以给只读列表中的变量赋值.我记得以前在 2008 的版本中为了弄明白这个配 ...
- NABCD竞争性需求分析
1. Need 需求 市面上关于各类记事本,时钟显示程序,图片显示程序,日历程序有很多,但是它们大多是零散的软件,不利于现在高集成的时代,我们所做的就是将各种功能合起来. 2. Approach ...
- [ACM_模拟] ZJUT 1155 爱乐大街的门牌号 (规律 长为n的含k个逆序数的最小字典序)
Description ycc 喜欢古典音乐是一个 ZJUTACM 集训队中大家都知道的事情.为了更方便地聆听音乐,最近 ycc 特意把他的家搬到了爱乐大街(德语Philharmoniker-Stra ...
- 免费好用的web应用托管平台-续
上一篇博客给大家推荐了目前处于免费阶段的PAAS平台,可以托管各种应用,大家反响很不错,说明大家还是很需要和认可这个免费托管各种web应用的京东云擎平台.但是很多用户还是很担心未来可能还是会收费,对于 ...