본문 바로가기
AI/python or ros_Webot

Webots Tutorial 1 - Your First Simulation in Webots

by 몽돌리스트 2020. 2. 17.
반응형


이제 환경을 구축해본다.

 

 

how to import what we need ( add(+) buttom -> add node ) + how to chage the size
we can change the location and rotation angle.

리셋 버튼을 누르면, 기존에 저장되었을 때의 initial state로 돌아가기 때문에

항상 명심하자. Pause -> Reset -> Modify and save the simulation -> re-start simulation

 

 

자세히 보면, 불러온 E-puck의 경우에 

기본적인 default controller가 있기 때문에 시뮬레이션을 실행하면 돌아가게 된다.

또한, 왼쪽 상단에 보이는 검은색 화면은 e-puck이 가지고 카메라의 화면이다. ( 이는 추후에 controller를 실질적으로 적용했을 때, 돌아간다. )

 

 

 

로봇에는 힘을 줄 수 있지만, Wooden box 에는 줄 수 없다.

중량을 설정해주지도 않았기 때문이다.

 


 

 

언어에 대한 정보는 다음을 참고하자.

https://cyberbotics.com/doc/guide/using-python

 

컨트롤러 만들기

 

 

컨트롤러 설정하기

 

하고나서 코드 복붙하기

1. 일정 거리만큼 앞으로 나가기

from controller import Robot, Motor

TIME_STEP = 64

# create the Robot instance.
robot = Robot()

# get the motor devices
leftMotor = robot.getMotor('left wheel motor')
rightMotor = robot.getMotor('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

 

2. 일정 속도만큼 앞으로 나가기

 

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.getMotor('left wheel motor')
rightMotor = robot.getMotor('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

 

 

반응형

댓글