ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • webot tutorial 01 (mac)
    카테고리 없음 2020. 2. 17. 21:49

    https://www.cyberbotics.com/doc/guide/tutorial-1-your-first-simulation-in-webots?tab-language=python

     

    Webots: tutorial-1-your-first-simulatio

     

    www.cyberbotics.com

     

    Tutorial 1: Your First Simulation in Webots (30 Minutes)

     

    이 첫 번째 튜토리얼의 목적은 사용자 인터페이스와 Webots의 기본 개념을 익히는 것입니다. 바닥과 벽이있는 경기장, 상자 몇 개, 전자 퍽 로봇 및 로봇을 움직일 수있는 컨트롤러 프로그램과 같은 간단한 환경이 포함 된 첫 번째 시뮬레이션을 작성합니다.

     

    Index

    1. Start Webots

    2. Create a New World 

    3. Add an e-puck Robot 

    4. Create a New Controller 

    5. Extend the Controller to Speed Control 

    6. Conclusion 

     

    1. Start Webots 

     

    Hands-on #1

    Start Webots by double-clicking on its icon (or invoking it from a command line in a Terminal). If you are running Webots for the first time on this computer, you may be prompted to select a graphical theme. You may also be invited to follow the Webots guided tour, go ahead and close the guided tour.

     

    아이콘을 두 번 클릭하거나 터미널의 명령 줄에서 호출하여 Webots를 시작하십시오. 이 컴퓨터에서 Webots를 처음 실행하는 경우 그래픽 테마를 선택하라는 메시지가 표시 될 수 있습니다. (자유롭게 선택) 또한 Webots 가이드 투어를 따르고 가이드 투어를 닫으라는 초대를받을 수도 있습니다.

     

     

     

    2. Create new world

     

    Hands-on #2: Pause the current simulation by clicking on the Pause button of the 3D view (see the user interface description to find out the buttons). The simulation is paused if the virtual time counter on the main toolbar is stopped. Create a new project from the Wizards menu by selecting the New Project Directory... menu item and follow the instructions:

    1. Name the project directory my_first_simulation instead of the proposed my_project.

    2. Name the world file my_first_simulation.wbt instead of the proposed empty.wbt.

    3. Click all the tick boxes, including the "Add a rectangle arena" which is not ticked by default.

    3D보기의 일시 정지 버튼을 클릭하여 현재 시뮬레이션을 일시 정지합니다 (버튼을 찾으려면 사용자 인터페이스 설명 참조). 기본 도구 모음에서 가상 시간 카운터가 중지되면 시뮬레이션이 일시 중지됩니다. [New Project Directory ... ] 메뉴 항목을 선택하여 [Wizaards] 메뉴에서 새 프로젝트를 작성하고 지시 사항을 따르십시오.

    1. 제안 된 my_project 대신 프로젝트 디렉토리 이름을 [my_first_simulation]으로 지정하십시오.
    2. 제안 된 empty.wbt 대신 월드 파일 이름을 [my_first_simulation.wbt]로 지정하십시오.
    3. 기본적으로 선택되어 있지 않은 [Add a rectangle arena]를 포함하여 모든 확인란을 클릭하십시오.

     

    Hands-on #3: Double-click on the RectangleArena node in the scene tree. This should open the node and display its fields.

    1. Select the [floorTileSize] field and set its value to 0.25 0.25 instead of 0.5 0.5. You should see the effect immediately in the 3D view.

    2. Select the wallHeight field and change its value to 0.05 instead of 0.1. The wall of the arena should now be lower.

    장면 트리에서 RectangleArena 노드를 두 번 클릭하십시오. 그러면 노드가 열리고 필드가 표시됩니다.
    1. [floorTileSize] 필드를 선택하고 값을 0.5 0.5 대신 0.25 0.25로 설정하십시오. 3D VIEW에서 즉시 효과를 볼 수 있습니다.
    2. [wallHeight] 필드를 선택하고 값을 0.1 대신 0.05로 변경하십시오. 경기장의 벽은 낮아진 것을 확인할 수 있습니다. 

     

    Hands-on #4: Double-click on the RectangleArena in the scene tree to close it and select it. Click on the Add button (plus sign) at the top of the scene tree. In the open dialog box, choose PROTO nodes (Webots Projects) / objects / factory / containers / WoodenBox (Solid). A big box should appear in the middle of the arena. Double-click on it in the scene tree to open its fields.

    1. Change its size to 0.1 0.1 0.1 instead of 0.6 0.6 0.6.

    2. Change its translation to 0 0.05 0 instead of 0 0.3 0. Alternatively, you may use the green arrow that appears in the 3D view to adjust its translation.y field.

    3. Now shift-click and drag the box in the 3D view and move it in some corner of the arena.

    4. Select the box and press Ctrl-C, Ctrl-V (Windows, Linux) or Cmd-C, Cmd-V (macOS) to copy and paste it. Shift-click and drag the new box to move it at some different location. Create a third box this way.

    5. Move the boxes, so that no box is at the center of the arena. You may also use the green rotation arrows to rotate the boxes along the vertical axis. This can be done also by shift-click and drag with the right mouse button. Alternatively, you can change the angle of the rotation field of the WoodenBox nodes in the scene tree.

    6. Once you are satisfied with the result, save the world using the save button.

    실습 # 4 : 장면 트리에서 [RectangleArena]를 두 번 클릭하여 닫고 선택합니다.
    장면 트리 상단에있는 [+}를 클릭하십시오.
    열린 대화 상자에서 [PROTO nodes (Webots Projects) / objects / factory / containers / WoodenBox (Solid)를 선택합니다. 경기장 한가운데 큰 상자가 나타납니다. 장면 트리에서 해당 필드를 두 번 클릭하여 필드를 엽니다.
    1. Size >  [0.6 0.6 0.6] 대신 [0.1 0.1 0.1]로 변경하십시오.
    2.translation > [ 0 0.3 0] 대신 [0 0.05 0]으로 변경하십시오. 또는 3D보기에 나타나는 녹색 화살표를 사용하여 [translation.y] 필드를 조정할 수 있습니다.
    3. 이제 3D보기에서 상자를 Shift- 클릭하고 드래그하여 경기장의 일부 모서리로 이동하십시오.
    4. 상자를 선택하고 Ctrl-C, Ctrl-V (Windows, Linux) 또는 Cmd-C, Cmd-V (macOS)를 눌러 복사하여 붙여 넣습니다. 새 상자를 Shift 키를 누른 상태에서 드래그하여 다른 위치로 이동하십시오. 이 방법으로 세 번째 상자를 만듭니다.
    5. 경기장 중앙에 상자가 없도록 상자를 이동하십시오. 녹색 회전 화살표를 사용하여 상자를 세로 축을 따라 [rotation] 할 수도 있습니다. 마우스 오른쪽 버튼으로 Shift 키를 누른 상태에서 드래그하여 수행 할 수도 있습니다. 또는 장면 트리에서 WoodenBox 노드의 회전 필드 각도를 변경할 수 있습니다. 6. 결과에 만족하면 저장 버튼을 사용하여 [world]을 구하십시오.

    3. Add an e-puck Robot

     

    The e-puck is a small robot having differential wheels, 10 LEDs, and several sensors including 8 DistanceSensors and a Camera. In this tutorial we are only interested in using its wheels. We will learn how to use other capabilities in the next tutorials.

    Now, we are going to add an e-puck model to the world. Make sure that the simulation is paused and that the virtual time elapsed is 0. If this is not the case, reset the simulation with the Reset button (rewind).

    When a Webots world is modified with the intention of being saved, it is fundamental that the simulation is first paused and reloaded to its initial state, i.e. the virtual time counter on the main toolbar should show 0:00:00:000. Otherwise at each save, the position of each 3D object can accumulate errors. Therefore, any modification of the world should be performed in that order: pause, reset, modify and save the simulation.

    We don't need to create the e-puck robot from scratch, we will just have to import a E-pucknode. This node is actually a PROTO node, like the RectangleArena or the WoodenBox we introduced before. Prototyping allows you to create custom objects and to reuse them.

     

    e- 퍽은 차동 휠, 10 개의 LED 및 8 개의 DistanceSensor 및 카메라를 포함한 여러 센서가있는 소형 로봇입니다. 이 튜토리얼에서는 휠 사용에만 관심이 있습니다. 다음 자습서에서 다른 기능을 사용하는 방법을 배웁니다. 이제 우리는 세계에 e- 퍽 모델을 추가 할 것입니다. 시뮬레이션이 일시 정지되고 가상 시간이 0인지 확인하십시오. 그렇지 않은 경우 재설정 버튼 (되감기)으로 시뮬레이션을 재설정하십시오. 저장하려는 의도로 Webots 세계를 수정하는 경우 시뮬레이션이 먼저 일시 정지되고 초기 상태로 다시로드되는 것이 기본입니다. 즉, 기본 도구 모음의 가상 시간 카운터는 0 : 00 : 00 : 000을 표시해야합니다. 그렇지 않으면 각 저장시 각 3D 객체의 위치에 오류가 누적 될 수 있습니다. 따라서 시뮬레이션의 일시 정지, 재설정, 수정 및 저장 순서로 세계 수정을 수행해야합니다. e- 퍽 로봇을 처음부터 새로 만들 필요는 없으며 E- 퍽 노드를 가져 오기만하면됩니다. 이 노드는 실제로 RectangleArena 또는 이전에 소개 한 WoodenBox와 같은 PROTO 노드입니다. 프로토 타이핑을 통해 사용자 정의 객체를 생성하고 재사용 할 수 있습니다. 

    Hands-on #5: Select the last node WoodenBox of the scene tree view. Click on the Add button (plus sign) at the top of the scene tree view. In the dialog box, choose PROTO nodes (Webots Projects) / robots / gctronic / e-puck / E-puck (Robot). An e-puck robot should appear in the middle of the arena. Move and rotate this robot, the same way you did it with the boxes. Save the simulation and press the Run real-time button (right arrow).

    실습 # 5 : 장면 트리 뷰의 마지막 노드 [WoodenBox]를 선택합니다. 장면 트리 뷰 상단에있는 [Add]를 클릭하십시오. 대화 상자에서 PROTO nodes (Webots Projects) / robots / gctronic / e-puck / E- puck (Robot)을 선택하십시오. 경기장 중앙에 e-puck robot이 나타납니다. 상자와 동일한 방식으로이 로봇을 이동 및 회전시킵니다. 시뮬레이션을 저장하고 [Run real-time] 을 누르세요. 

     

    Hands-on #6Apply a force to the robot by pressing [Alt + left-click + drag]. On Linux, you should also press the Ctrl key in addition to Alt + left-click + drag. It is not possible to apply a force to a [WoodenBox] node, because by default, they have no mass and are considered as glued on the floor. To enable physics on the [WoodenBox] nodes, you should set their [mass] field to a certain value (for example 0.2 kg). Once this is done, should be able to apply a force on them as well.

     

    실습 # 6 : Alt + 왼쪽 클릭 + 드래그를 눌러 로봇에 힘을가하십시오. Linux에서는 Alt + 왼쪽 클릭 + 드래그 외에도 Ctrl 키를 눌러야합니다. WoodenBox 노드에 힘을 가하는 것은 불가능합니다. 기본적으로 질량이 없으며 바닥에 붙어있는 것으로 간주되기 때문입니다. WoodenBox 노드에서 물리를 활성화하려면 질량 필드를 특정 값 (예 : 0.2kg)으로 설정해야합니다. 이 작업이 완료되면 그들에게도 힘을 가할 수 있어야합니다.

     

    Hands-on #7: Pause the simulation and revert it. In the Scene Tree view, expand the WorldInfo node (the first node). Set its basicTimeStep field to 16. Then save the simulation.

     

    실습 # 7 : 시뮬레이션을 일시 정지하고 되돌립니다. 장면 트리 뷰에서 [WorldInfo] 노드 (첫 번째 노드)를 확장하십시오. [basicTimeStep] 필드를 16으로 설정 한 다음 시뮬레이션을 저장하십시오.

     

    4. Create a New Controller

    We will now program a simple controller that will just make the robot move forwards.

    A controller is a program that defines the behavior of a robot. Webots controllers can be written in the following programming languages: C, C++, Java, Python, MATLAB, ROS, etc. C, C++ and Java controllers need to be compiled before they can be run as robot controllers. Python and MATLAB controllers are interpreted languages so they will run without being compiled. In this tutorial, we are going to use C as a reference language but all the code snippets are also available in C++, Java, Python and MATLAB. Refer to the language chapter to setup a controller using a different programming language.

    The controller field of a Robot node specifies which controller is currently associated to the robot. Note that the same controller can be used by several robots, but a robot can only use one controller at a time. Each controller is executed in a separate child process usually spawned by Webots. Because they are independent processes, controllers don't share the same address space, and may run on different processor cores.

    Hands-on #8: Create a new C (or any other language) controller called e-puck_go_forward (for C++ and Java call it EPuckGoForward instead) using the Wizards / New Robot Controller... menu. This will create a new e-puck_go_forward (or EPuckGoForward) directory in my_first_simulation/controllers. Select the option offering you to open the source file in the text editor.

    로봇이 앞으로 나아갈 수 있도록 간단한 컨트롤러를 프로그래밍하겠습니다.

    controller :
    컨트롤러는 로봇의 동작을 정의하는 프로그램입니다. Webots 컨트롤러는 C, C ++, Java, Python, MATLAB, ROS 등의 프로그래밍 언어로 작성할 수 있습니다. C, C ++ 및 Java 컨트롤러는 로봇 컨트롤러로 실행되기 전에 컴파일해야합니다. Python 및 MATLAB 컨트롤러는 해석되는 언어이므로 컴파일되지 않고 실행됩니다. 이 자습서에서는 C를 참조 언어로 사용하지만 모든 코드 스 니펫은 C ++, Java, Python 및 MATLAB에서도 사용할 수 있습니다. 다른 프로그래밍 언어를 사용하여 컨트롤러를 설정하려면 언어 장을 참조하십시오.
    [robot] 노드의 [controller] 필드는 현재 로봇에 연결된 컨트롤러를 지정합니다. 여러 로봇에서 동일한 컨트롤러를 사용할 수 있지만 로봇은 한 번에 하나의 컨트롤러만 사용할 수 있습니다. 각 컨트롤러는 일반적으로 Webots가 생성하는 별도의 자식 프로세스에서 실행됩니다. 이들은 독립적인 프로세스이므로 컨트롤러는 동일한 주소 공간을 공유하지 않으며 다른 프로세서 코어에서 실행될 수 있습니다.

    실습 # 8 : [Wizards / New Robot Controller ... ]메뉴를 사용하여 [e-puck_go_forward (C ++ 및 Java의 경우 대신 EPuckGoForward라고 함)]라는 새 C (또는 다른 언어) 컨트롤러를 만듭니다. 그러면 [my_first_simulation / controllers]에 새로운 e-puck_go_forward (또는 EPuckGoForward) 디렉토리가 생성됩니다. 텍스트 편집기에서 소스 파일을 열 수있는 옵션을 선택하십시오.

    We will now associate new e-puck_go_forward (or EPuckGoForward) controller to the E-puck node.
    이제 새로운 e-puck_go_forward (또는 EPuckGoForward) 컨트롤러를 E-puck 노드에 연결합니다.

    Hands on #9: In the scene tree view, select the controller field of the E-puck node, then use the field editor at the bottom of the Scene Tree view: press the Select...button and then select e-puck_go_forward in the list. Once the controller is associated with the robot, save the world. Modify the program by getting the motor devices (leftMotor = robot.getMotor('left wheel motor')), and by applying a motor command (leftMotor.setPosition(10.0)):

     

     

     

     

    실습 # 9 : 장면 트리보기에서 E- 퍽 노드의 컨트롤러 필드를 선택한 다음 장면 트리보기의 맨 아래에있는 필드 편집기를 사용하십시오. 선택 ... 버튼을 누른 다음 e-puck_go_forward를 선택하십시오. 목록. 컨트롤러가 로봇과 연결되면 세상을 구하십시오. 모터 장치 (leftMotor = robot.getMotor ( '왼쪽 휠 모터'))를 가져오고 모터 명령 (leftMotor.setPosition (10.0))을 적용하여 프로그램을 수정하십시오.

     

    실습 # 9 : 장면 트리보기에서 [E-puck] 노드의 [controller] 필드를 선택한 다음, 장면 트리보기의 맨 아래에있는 필드 편집기를 사용하십시오. [Select ...] 버튼을 누른 다음 [e-puck_go_forward]를 선택하십시오. 목록. 컨트롤러가 로봇과 연결되면 세상을 구하십시오. 모터 장치 (leftMotor = robot.getMotor ( 'left wheel motor'))를 가져오고 모터 명령 (leftMotor.setPosition (10.0))을 적용하여 프로그램을 수정하십시오.

     

    5. Extend the Controller to Speed Control

    The wheels of differential wheels robots are often controlled in velocity and not in position like we did in the previous example. In order to control the motors of the wheels in speed you need to set the target position to the infinity and to set the desired speed:

    차동 휠 로봇의 휠은 종종 앞의 예에서와 같이 속도로 제어되며 위치가 아닙니다. 바퀴의 모터를 속도로 제어하려면 목표 위치를 무한대로 설정하고 원하는 속도를 설정해야합니다.

     

    The robot will now move (the wheels will rotate at a speed of 1 radian per second) and never stop. If nothing happens, don't forget to compile your code by selecting the Build / Buildmenu item or click on the gear icon above the code area. Compilation errors are displayed in red in the console. If there are any, fix them and retry to compile. Then, reload the world.

     

    로봇은 이제 움직이며 (휠은 초당 1 라디안의 속도로 회전합니다) 절대 멈추지 않습니다. 아무 것도 발생하지 않으면 Build / Build 메뉴 항목을 선택하거나 코드 영역 위의 톱니 바퀴 아이콘을 클릭하여 코드를 컴파일하는 것을 잊지 마십시오. 콘솔에서 컴파일 오류가 빨간색으로 표시됩니다. 있으면 수정하고 다시 컴파일하십시오. 그런 다음 다시 하십시오. 

     

     

    6. Conclusion

     

    We hope you enjoyed creating your first Webots simulation. You have been able to set up a world, add a robot and program it. The important thing is that you learned the fundamental concepts summarized below:

    • A world is made up of nodes organized in a tree structure.

    • A world is saved in a .wbt file stored in a Webots project.

    • The project also contains the robot controller programs which define the behavior of the robots.

    • Controllers may be written in C or other languages.

    • C, C++ and Java controllers have to be explicitly compiled before they can be executed.

    • Controllers are associated with robots via the controller fields of the Robot node

    첫 Webots 시뮬레이션 제작을 즐기 셨기를 바랍니다. World를 설정하고 로봇을 추가하고 프로그래밍 할 수 있었습니다.

    중요한 것은 아래 요약 된 기본 개념을 배웠다는 것입니다.

     

    -World > 트리 구조로 구성된 노드로 구성됩니다.
    -World > 는 Webots 프로젝트에 저장된 .wbt 파일에 저장됩니다.
    -World > 이 프로젝트에는 로봇의 동작을 정의하는 [robot controller program]로봇 컨트롤러 프로그램도 포함되어 있습니다.
    -C, C ++ 및 Java 컨트롤러는 실행하기 전에 명시 적으로 컴파일해야합니다.
    -controller > 로봇 노드의 컨트롤러 필드를 통해 로봇과 연결됩니다.

    애드센스 -
Designed by Tistory.