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 Devicesubclass. For example, if a robot contains a DistanceSensor node whose namefield is "ds1", the function getDistanceSensorwill return a reference to a DistanceSensor object. If the specified device is not found, the function returns NULLin C++, nullin Java or thenonein 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.

转载于:https://www.cnblogs.com/johnpher/p/3411652.html

Notes on how to use Webots, especially how to make a robot fly in the air相关推荐

  1. Webots简单自学笔记(随时更新)

    Webots 2019a 中文 保存!保存!随手保存!!别的不重要,随手保存是王道!!! 一.Scene tree:场景树 (一)WorldInfo:世界信息 参考手册(F4)(reference.p ...

  2. 机器人模拟器webots初学者入门教程

    Webots GUI由四个主要窗口组成: 显示并允许您与3D模拟进行交互的3D window(3D窗口) 表示当前世界的层次结构的Scene tree(场景树) 允许您编辑源代码的Text edito ...

  3. Webots 舵轮底盘小教程

    前言: 自从webots2019开源后,我也决定去学习这个机器人仿真软件,总体来说非常令人满意.同僚刘福强和我是我们这片率先去自学这个仿真软件的.过程中,有许多艰辛.这个软件的教程在网络上只有这里说的 ...

  4. Webots R2022b 发布

    这个功能不错webots.cloud 但是,如果网络不畅通: 个把小时也不会有任何进展-- 文档如果网络不畅,也打开困难-- Webots参考手册 R2022b Webots R2022 更改日志 版 ...

  5. 自学习Webots教程,未完待续...

    Webots教程(根据官网改编) Start Webots Create a New World Add an e-puck Robot Create a New Controller 将控制器扩展到 ...

  6. 30分钟上手你的第一个Webots模拟程序

    文章目的:使您熟悉用户界面和Webots的基本概念.您将创建第一个包含简单环境的模拟:一个有地板和墙壁的竞技场,几个盒子,一个Epuck机器人以及一个使机器人运动的控制器程序. 前提:已经安装Webo ...

  7. adobe air 工程师_了解Adobe AIR,第I部分:构建Note存储应用

    adobe air 工程师 The Adobe Integrated Runtime (AIR) platform changes the game for web developers, takin ...

  8. Webots ROS

    Webots仿真用ROS来控制,有意义吗? 对于简单的控制,感觉没必要,部署直接把webots里的c/c++代码拷贝到机载控制器上就可以. 对于较为复杂的算法和程序,比如用到多个进程或者多个线程进行处 ...

  9. 【 Notes 】ML ALGORITHMS of TOA - Based Positioning

    这篇博文和NLS方法博文行文思路类似:[ Notes ]NLS ALGORITHMS of TOA - Based Positioning ML方法是NLS方法的一个推广版本,具体接着看: Assum ...

最新文章

  1. 依图科技终止上市审核:冲击科创板「AI第一股」失败
  2. 利用 Chrome 开发者工具自带的 Memory 工具分析 Node.js 应用的内存分配情况
  3. 云原生人物志|Pulsar翟佳:社区的信任最重要
  4. Python中IOBase详解
  5. wampserver服务器无法启动(图标颜色不对)
  6. 国际国家代号mysql_最全的各国 语言(文化)代码与国家地区对照表(国际通用标准形式)...
  7. 《图论及其应用》学习笔记(图和简单图)
  8. Windows 在Windows中关闭/最小化窗口的几种快捷方法
  9. C语言多多搬果子思路,看图写话《小刺猬搬果子》
  10. Python基础刷题,期末不挂科~~~(已完结)
  11. 【Volume X has invalid topology for mapped brick meshing】
  12. 也说类别Category
  13. iPhoneX 适配
  14. 迅雷大乱,突现“两个迅雷”
  15. 开学送给她的礼物(Python实现)
  16. 大学十年__献给计算机专业的所有学子
  17. NTP网络授时服务器在电视播出系统中的应用
  18. 苹果自带测试卡路里的软件,‎App Store 上的“h-Tracker:卡路里计算器”
  19. TCP/IP知识总结面试题之Socket服务
  20. 爬取豆瓣排行榜电影数据

热门文章

  1. 将C#Lambda表达式转换为通用过滤器描述符和HTTP查询字符串
  2. 为什么没有看到webcontent_王者荣耀之战坦路玩家心理:队友为什么不支援!我想要和射手换线...
  3. 简易 Vue 构建--篇二
  4. 怎么使用php连接mysql_如何使用PHP连接MySQL
  5. 试用到期_各大化妆品品牌试用装广告
  6. jmeter的java测试框架_性能测试学习之路 (四)jmeter 脚本开发实战(JDBC JMS 接口脚本 轻量级接口自动化测试框架)...
  7. idea连接svn_搭建本地虚拟(centos)svn服务器
  8. vue-quill-editor 获取无法获取光标位置
  9. 服务器系统分区 是啥,服务器系统盘分区
  10. c语言设计阶段作业答案,C语言程序设计阶段考试练习题(答案)