首页 > 其他分享 >Webots tutorial 1

Webots tutorial 1

时间:2023-02-03 13:12:11浏览次数:61  
标签:rightMotor robot Robot motor Hands Webots tutorial

第二章 Webots官方Tutorial 1


目录


前言

开始学会使用Webots吧!(注意每步都要保存,防止新建的物体消失)

参考链接:https://cyberbotics.com/doc/guide/tutorial-1-your-first-simulation-in-webots?tab-os=windows&tab-language=python


一、Tutorial 1: Your First Simulation in Webots

目标是熟悉 Webots的用户界面和基本概念。
需要我们创建一个简单的环境:一个地板和墙组成的区域、几个箱子、一个机器人和使其移动的控制器程序。

二、创建一个新世界

2.1 Hands-on #2

File / New / New Project Directory



会生成.wbt文件

  • WorldInfo: 包含一些世界参数.
  • Viewpoint: 视角参数.
  • TexturedBackground: 背景
  • TexturedBackgroundLight: 与背景相关的灯光
  • RectangleArena: 当前所示的矩形地板floor

2.2 Hands-on #3

地板及墙的尺寸设置。

2.3 Hands-on #4

添加木箱,设置尺寸size、坐标translation,复制粘贴Ctrl+c\v。

点击+,选择PROTO nodes(Webots Projects)/objects/factory/containers/ WoodenBox (Solid)

三、添加一个e-puck机器人

3.1 Hands-on #5

点击+,选择PROTO nodes(Webots Projects)/robots/gctronic/e-puck/E-puck(Robot)

运行环境,机器人动起来。

3.2 Hands-on #6

alt+鼠标左键 可拖拽机器人。

同理,给箱子设置质量mass后,可以进行拖拽。

3.3 Hands-on #7

设置仿真基准时间步长basicTimeStep

四、创建一个新的控制器

本文采用Python语言

4.1 Hands-on #8

File / New / New Robot Controller

4.2 Hands-on #9

机器人向前运动控制代码:

from controller import Robot, Motor

TIME_STEP = 64

# create the Robot instance.
robot = Robot()

# get the motor devices
leftMotor = robot.getDevice('left wheel motor')
rightMotor = robot.getDevice('right wheel motor')
# set the target position of the motors
leftMotor.setPosition(10.0)
rightMotor.setPosition(10.0)

while robot.step(TIME_STEP) != -1:
   pass

4.3 Hands-on #10

运动速度控制代码:

from controller import Robot, Motor

TIME_STEP = 64

MAX_SPEED = 6.28

# create the Robot instance.
robot = Robot()

# get a handler to the motors and set target position to infinity (speed control)
leftMotor = robot.getDevice('left wheel motor')
rightMotor = robot.getDevice('right wheel motor')
leftMotor.setPosition(float('inf'))
rightMotor.setPosition(float('inf'))

# set up the motor speeds at 10% of the MAX_SPEED.
leftMotor.setVelocity(0.1 * MAX_SPEED)
rightMotor.setVelocity(0.1 * MAX_SPEED)

while robot.step(TIME_STEP) != -1:
   pass

总结

恭喜你完成了教程1,在此你应该初步了解了Webots的基本概念、布局和简单设计。

标签:rightMotor,robot,Robot,motor,Hands,Webots,tutorial
From: https://www.cnblogs.com/YIKeLB/p/17085185.html

相关文章

  • Webots下载安装 + Pycharm联调
    第一章Webots安装目录第一章Webots安装前言一、Webots是什么?二、WebotsR2022b安装1.下载2.安装3.Pycharm作为IDE3.1设置环境变量3.2Webots设置总结前言本系列......
  • Firefly Amazon UK PC control installation tutorial
    FireflyAmazonUKPCcontrolinstallationtutorial1.TurnoffthePCfirewallandanti-virussoftware,itisbesttouninstalltheanti-virussoftware2.Downl......
  • Firefly Amazon PC control installation tutorial
    FireflyAmazonPCcontrolinstallationtutorial1.TurnoffthePCfirewallandanti-virussoftware,itisbesttouninstalltheanti-virussoftware2.Download......
  • Firefly Amazon US PC control installation tutorial
    FireflyAmazonUSPCcontrolinstallationtutorial1.TurnoffthePCfirewallandanti-virussoftware,itisbesttouninstalltheanti-virussoftware2.Downl......
  • Quartz.Net 官方教程 Tutorial 3/3
    Schedule相关属性设置扩展属性方式varhost=Host.CreateDefaultBuilder().ConfigureServices(services=>{services.AddQuartz(opt=>......
  • Abstraction, intuition, and the “monad tutorial fallacy”
    WhileworkingonanarticlefortheMonad.Reader,I’vehadtheopportunitytothinkabouthowpeoplelearnandgainintuitionforabstraction,andtheimplica......
  • cURL Tutorial
    created:2023/1/23 cURLbasicusage curl<url>          DownloadingFileswithcURL       ......
  • Coursera & free video Tutorials All In One
    Coursera&freevideoTutorialsAllInOne免费视频教程https://www.coursera.org/专业证书认证免费旁听https://www.coursera.org/in-progresshttps://ww......
  • Json-Tutorial06 对象解析
    前言MiloYip2016/11/15本文是《从零开始的JSON库教程》的第六个单元解答篇。解答代码位于json-tutorial/tutorial06_answer。1.重构lept_parse_string()这个......
  • Json-Tutorial05 数组解析
    前言本节将要学习的是第一种复合类型的解析:数组。具体的解析规则在Tutorial中已经有了,概括下简单的思想就是遇到[符号之后挨个调用lept_parse_value来解析数组的每一个元......