Difference between revisions of "V-REP Introduction"

From Mech
Jump to navigationJump to search
(Update: Add more scenes and rewrite the introductions.)
Line 22: Line 22:
Once V-REP is open you will want to run one of the scenes below. To run either of them, you first run V-REP, then you click <code>File->Open scene...</code> and open one of the ttt files that are linked below. Then click either the ''Play'' button from the top toolbar or click <code>Simulation->Start simulation</code> and a GUI should pop up. Clicking the ''Stop'' button or <code>Simulation->Stop simulation</code> will close the GUI and stop the simulation.
Once V-REP is open you will want to run one of the scenes below. To run either of them, you first run V-REP, then you click <code>File->Open scene...</code> and open one of the ttt files that are linked below. Then click either the ''Play'' button from the top toolbar or click <code>Simulation->Start simulation</code> and a GUI should pop up. Clicking the ''Stop'' button or <code>Simulation->Stop simulation</code> will close the GUI and stop the simulation.


The scenes below are implemented similarly. They both feature a simulation of a kinematically-controlled, non-respondable [https://www.universal-robots.com/products/ur5-robot/ UR5 robot] from [https://www.universal-robots.com/ Universal Robots]. ''Kinematically controlled'' means that all dynamics (inertias, torques, friction, etc.) of the system are neglected. We can specify a set of joint angles and the simulation is capable of instantaneously "teleporting" the robot to be at the new set of joint angles. ''Non-respondable'' means that the links of the robot are not capable of interacting with the world or each other through collisions. In other words, we can put the robot in configurations that result in self-collisions, but the simulation will ignore the collisions. The physical UR5 robot features 6 joints each with 720 degrees of rotation, and this simulated robot has the same joints and limits. The model of the UR5 in each of the scenes was created by importing a URDF from the ROS-Industrial [https://github.com/ros-industrial/universal_robot/tree/indigo-devel/ur_description/urdf ur5_description package].
The scenes below are implemented similarly. Except Scene 7, all the other scenes feature a simulation of a kinematically-controlled, non-respondable robot. ''Kinematically controlled'' means that all dynamics (inertias, torques, friction, etc.) of the system are neglected. We can specify a set of joint angles and the simulation is capable of instantaneously "teleporting" the robot to be at the new set of joint angles. ''Non-respondable'' means that the links of the robot are not capable of interacting with the world or each other through collisions. In other words, we can put the robot in configurations that result in self-collisions, but the simulation will ignore the collisions. Scene 7 is a partly dynamically-controlled simulation of a respondable [http://www.youbot-store.com/ youBot] from [https://www.kuka.com/en-us KUKA]. All revolute joints of the robots in the simulation scenes have no joint limits.


In each scene, there is a single Lua script called a [http://www.coppeliarobotics.com/helpFiles/en/childScripts.htm Non-threaded child script]. When the scene is first run, there is a function that is called that sets up the GUI and creates variables that are going to be needed later on in the simulation. Then during every step of the simulation the [http://www.coppeliarobotics.com/helpFiles/en/mainScript.htm main script], which is part of every V-REP scene, runs an "actuation" function from the child script. This actuation function is responsible for processing all of the changes to the GUI since the last time it was called (buttons clicked, label updates, etc.), and for sending joint commands to the simulated robot. Technically, there is also a "sensing" function in the child script that gets called by the main script, but in each of these demos, the sensing function is empty. The GUIs are both built with V-REP's [http://www.coppeliarobotics.com/helpFiles/en/customUIPlugin.htm Qt-based custom UI framework].
In each scene, there is a single Lua script called a [http://www.coppeliarobotics.com/helpFiles/en/childScripts.htm Non-threaded child script]. When the scene is first run, there is a function that is called that sets up the GUI and creates variables that are going to be needed later on in the simulation. Then during every step of the simulation the [http://www.coppeliarobotics.com/helpFiles/en/mainScript.htm main script], which is part of every V-REP scene, runs an "actuation" function from the child script. This actuation function is responsible for processing all of the changes to the GUI since the last time it was called (buttons clicked, label updates, etc.), and for sending joint commands to the simulated robot. Technically, there is also a "sensing" function in the child script that gets called by the main script, but in each of these scenes, the sensing function is empty. The GUIs are all built with V-REP's [http://www.coppeliarobotics.com/helpFiles/en/customUIPlugin.htm Qt-based custom UI framework].


=== Scene 1: Interactive UR5 ===
=== Scene 1: CSV Animation MTB ===

[[image:MTB-img.png|right|x150px]]

This scene simulates a MTB robot, a virtual RRPR robot. It allows you to specify a csv file containing a trajectory of joint angles, and then animate this trajectory. Each column of the csv file is the joint angle/length through time for one of the joints (in the order of RRPR). In other words, a single row of the csv file represents a complete configuration of the robot at a particular time. The prismatic joint (P) has the joint limit range [0, 0.2]. The assumed time step between rows is equal to the time step that V-REP uses for simulation; the default is 0.05 seconds. The example csv file will show all the joints of MTB robot and you will need to provide a complete path to your csv file.

* Download the ttt scene file [[Media:MTB_csvplayer.ttt|here]].
* Download an example csv file [[Media:MTB_csvplayer.csv|here]].

<br clear=all>

=== Scene 2: Interactive UR5 ===


[[image:ur5-img.png|right|x150px]]
[[image:ur5-img.png|right|x150px]]


In this demo, the GUI features two tabs. One tab lets you drag sliders to modify the joint angles of each joint, and the other tab allows you to specify comma-separated angles for all 6 joints in an editable text box and ask for the <math>SE(3)</math> transformation from the base frame to the end-effector frame. The frames attached to the base and end-effector are persistently displayed (x-axis in red, y-axis in green, z-axis in blue). Note that all angles are specified in radians.
This scene simulates a [https://www.universal-robots.com/products/ur5-robot/ UR5 robot] from [https://www.universal-robots.com/ Universal Robots]. The model of UR5 was created by importing a URDF from the ROS-Industrial [https://github.com/ros-industrial/universal_robot/tree/indigo-devel/ur_description/urdf ur5_description package]. The GUI in this scene features two tabs. One tab lets you drag sliders to modify the joint angles of each joint, and the other tab allows you to specify comma-separated angles for all 6 joints in an editable text box and ask for the SE(3) transformation from the base frame to the end-effector frame. The frames attached to the base and end-effector are persistently displayed (x-axis in red, y-axis in green, z-axis in blue). Note that all angles are specified in radians.


* Download the ttt scene file [[Media:UR5_imported_interactive.ttt|here]].
* Download the ttt scene file [[Media:UR5_imported_interactive.ttt|here]].

<br clear=all>
<br clear=all>


=== Scene 2: CSV Animation UR5 ===
=== Scene 3: CSV Animation UR5 ===


This scene is similar to Scene 1 except it simulates UR5 robot. You can interactively control the configuration of the mobile base and the arm. Each column of the csv file is the joint angle through time for one of the joints (first column is joint 1, last column is joint 6).
This demo allows you to specify a CSV file containing a trajectory of joint angles, and then animate this trajectory. Each column of the CSV file is the joint angle through time for one of the joints (first column is joint 1, last column is joint 6). In other words, a single row of the CSV file represents a complete configuration of the robot at a particular time. The assumed timestep between rows is equal to the timestep that V-REP uses for simulation; the default is 0.05 seconds. Note that will need to provide a complete path to your CSV file. Alternatively, you may be able to provide a relative path, but you'll need to figure out what V-REP uses as its base directory on your OS. On Linux, this directory is the root directory of the V-REP source code. If you figure out this directory, you could also move your CSV files to be in this directory and just reference them by name without specifying the path at all. A typical path on the Mac is something like <code>/Users/kevin/yourdirectoryname/example.csv</code>.


* Download the ttt scene file [[Media:UR5_imported_csvplayer.ttt|here]].
* Download the ttt scene file [[Media:UR5_csvplayer.ttt|here]].
* Download an example csv file [[Media:UR5_example_jointstates.csv|here]].
* Download an example csv file [[Media:UR5_example_jointstates.csv|here]].


=== Scene 3: Interactive youBot ===
=== Scene 4: Interactive youBot ===


[[image:youbot-fig.png|right|x150px]]
[[image:youbot-fig.png|right|x150px]]


The KUKA youBot is a mobile manipulator consisting of a mecanum-wheel omnidirectional base and a 5R robot arm. This scene is similar to the UR5 interactive scene. You can interactively control the configuration of the mobile base and the arm.
This scene simulates a youBot from KUKA. The KUKA youBot is a mobile manipulator consisting of a mecanum-wheel omnidirectional base and a 5R robot arm. The use of this scene is similar to Scene 2, by which you can interactively control the configuration of the mobile base and the arm.


* Download the ttt scene file [[Media:YouBot_interactive.ttt|here]].
* Download the ttt scene file [[Media:YouBot_interactive.ttt|here]].

<!--
* Download the ttt scene file with no joint limits for the arm [[Media:YouBot_pose_interactive_no_joint_limits.ttt|here]].
* Download the ttt scene file with joint limits for the arm [[Media:YouBot_interactive.ttt|here]].
-->
<br clear=all>
<br clear=all>


=== Scene 4: CSV Animation youBot ===
=== Scene 5: CSV Animation youBot ===


[[image:youbot-top-view.png|right|x150px]]
[[image:youbot-top-view.png|right|x150px]]


This scene is similar to the UR5 animation scene, except now the csv file consists of 12 configuration variables per row: 3 for the mobile base (ordered as x, y, phi), 5 for the arm (joints 1 to 5), and 4 for the wheels (ordered as you see in the figure on the right). If you don't want to show the wheels moving, or if you have not correctly solved the kinematics relating the wheel motions to the mobile base motion, you can just set all 4 wheels angles to zero.
This scene is similar to Scene 1 and 3, except now it simulates youBot and the csv file consists of 12 or 13 configuration variables per row: 3 for the mobile base (ordered as phi, x, y), 5 for the arm (joints 1 to 5), and 4 for the wheels (ordered as you see in the figure on the right). The last variable is optional, which is for controlling the state of the gripper as the end-effector. The gripper is open by default but you can set the last variable as 0 for open and 1 for close the gripper.
* Download the ttt scene file [[Media:YouBot_csv_with_wheels.ttt|here]].
* Download the ttt scene file [[Media:youBot_csvplayer.ttt|here]].
* Download an example csv file [[Media:YouBot.csv|here]].
* Download an example csv file [[Media:YouBot.csv|here]].

<!--
<br clear=all>
* Download the ttt scene file [[Media:YouBot_csv.ttt|here]].

* Download an example csv file [[Media:YouBot_csv.txt|here]].
=== Scene 6: CSV Motion Planning Kilobot ===
-->

[[image:kilobot-img.png|right|x150px]]

This scene simulates a [https://www.kilobotics.com/ Kilobot]. It allows you to visualize a weighted undirected graph with some obstacles and a planar path for Kilobot to follow. The origin of the world frame is at (0,0) and the graph as well as the obstacles and Kilobot should be limited into a square of -0.5 <= x <= 0.5 and -0.5 <= y <= 0.5. The input of the GUI is a path of a folder including the following 4 specifically named csv files.

obstacles.csv: This file specifies the locations and diameters of all cylinder obstacles. Each row represents the x, y value of one cylinder obstacle and its diameter in order.

nodes.csv: This file specifies the ID numbers, locations of nodes and estimated actual cost-to-go from their locations to the goal. Each row represents the ID number, x, y value of one node and its estimated actual cost-to-go in order. The ID number should be continuous integers beginning with 1. Note that you will need to kick out any node blocked by obstacles.

edges.csv: This file specifies the locations of all edges in the graph and their costs (weights). Each row represents two ID numbers of nodes which one edge is connecting and the edge's cost in order.
Note that you will nee to kick out any edge blocked by obstacles.

path.csv: This file specifies the nodes in the path with their ID numbers in order. In other words, there is only one row of numbers in this file, with the first number for the start node ID and the last number for the goal node ID.
The scene will show all the obstacles, nodes, edges and one path from the start node to the goal node. The nodes, edges and path are marked in blue, yellow and green respectively. The goal node is marked in red. The Kilobot will move from the start node to the goal node following the path in a constant velocity.

* Download the ttt scene file [[Media:planar_graph.ttt|here]].
* Download an example folder for csv files [[Media:planar_graph.zip|here]]. You will need to extract it first.

<br clear=all>

=== Scene 7: CSV Mobile Manipulation youBot ===

[[image:youbot-capstone.png|right|x150px]]

This scene is similar to Scene 5, except now the youBot is expected to accomplish a pick-and-place motion. There is a cube on the ground for youBot to pick and a frame representing the final end-effector configuration after placing the cube. The input and use of this scene is the same as Scene 5. The other differences with Scene 5 are that the whole robot is now respondable, meaning that the links of the robot are now capable of interacting with the world or each other through collisions. The gripper of the youBot and the cube are even dynamically modelled to simulate the practical pick-and-place motion.
* Download the ttt scene file [[Media:youBot_capstone.ttt|here]].
* Download an example csv file [[Media:youBot_capstone.csv|here]].

<br clear=all>
<br clear=all>



Revision as of 02:02, 20 March 2018

V-REP Introduction

On V-REP's homepage the program is described as

  ...the Swiss army knife among robot simulators: you won't find a simulator with more functions, features, or more elaborate APIs.

V-REP's strength comes from several features:

  1. V-REP provides a unified framework combining many powerful internal and external libraries that are often useful for robotics simulations. This includes dynamic simulation engines, forward/inverse kinematics tools, collision detection libraries, vision sensor simulations, path planning, GUI development tools, and built-in models of many common robots.
  2. V-REP is highly extensible. V-REP developers provide an API that allows one to write custom plugins that add new features. You can embed Lua scripts directly into a simulation scene that, for example, process simulated sensor data, run control algorithms, implement user interfaces, or even send data to a physical robot. They also provide a remote API that allows one to develop standalone applications in many programming languages that are able to pass data in and out of a running V-REP simulation.
  3. V-REP is cross-platform, mostly open-source, and provides a free educational license.

The purpose of this page is not to teach you how to use V-REP. Rather it is to describe demonstration scenes that have been developed to help visualize robot arm kinematics. If you are interested in learning more about V-REP, check out the Useful Resources section below.

Demonstration V-REP Scenes

To run either of the scenes below, the first step will be to download V-REP for your operating system. You should download the latest Non-limited EDUCATIONAL version. Next you will have to install V-REP. On Windows, you simply have an EXE that installs V-REP. On a Mac, you first need to unzip the download. The directory that is produced by unzipping the download contains a vrep.app directory that should allow you start V-REP through normal mechanisms, e.g., Finder/Spotlight/Launchpad. On Linux, you will need to extract the compressed tar archive (e.g., using a command like tar xvf V-REP_PRO_EDU_V3_3_2_64_Linux.tar.gz). Then you need to change directories into the V-REP source directory and run the vrep.sh shell script.

Once V-REP is open you will want to run one of the scenes below. To run either of them, you first run V-REP, then you click File->Open scene... and open one of the ttt files that are linked below. Then click either the Play button from the top toolbar or click Simulation->Start simulation and a GUI should pop up. Clicking the Stop button or Simulation->Stop simulation will close the GUI and stop the simulation.

The scenes below are implemented similarly. Except Scene 7, all the other scenes feature a simulation of a kinematically-controlled, non-respondable robot. Kinematically controlled means that all dynamics (inertias, torques, friction, etc.) of the system are neglected. We can specify a set of joint angles and the simulation is capable of instantaneously "teleporting" the robot to be at the new set of joint angles. Non-respondable means that the links of the robot are not capable of interacting with the world or each other through collisions. In other words, we can put the robot in configurations that result in self-collisions, but the simulation will ignore the collisions. Scene 7 is a partly dynamically-controlled simulation of a respondable youBot from KUKA. All revolute joints of the robots in the simulation scenes have no joint limits.

In each scene, there is a single Lua script called a Non-threaded child script. When the scene is first run, there is a function that is called that sets up the GUI and creates variables that are going to be needed later on in the simulation. Then during every step of the simulation the main script, which is part of every V-REP scene, runs an "actuation" function from the child script. This actuation function is responsible for processing all of the changes to the GUI since the last time it was called (buttons clicked, label updates, etc.), and for sending joint commands to the simulated robot. Technically, there is also a "sensing" function in the child script that gets called by the main script, but in each of these scenes, the sensing function is empty. The GUIs are all built with V-REP's Qt-based custom UI framework.

Scene 1: CSV Animation MTB

MTB-img.png

This scene simulates a MTB robot, a virtual RRPR robot. It allows you to specify a csv file containing a trajectory of joint angles, and then animate this trajectory. Each column of the csv file is the joint angle/length through time for one of the joints (in the order of RRPR). In other words, a single row of the csv file represents a complete configuration of the robot at a particular time. The prismatic joint (P) has the joint limit range [0, 0.2]. The assumed time step between rows is equal to the time step that V-REP uses for simulation; the default is 0.05 seconds. The example csv file will show all the joints of MTB robot and you will need to provide a complete path to your csv file.

  • Download the ttt scene file here.
  • Download an example csv file here.


Scene 2: Interactive UR5

Ur5-img.png

This scene simulates a UR5 robot from Universal Robots. The model of UR5 was created by importing a URDF from the ROS-Industrial ur5_description package. The GUI in this scene features two tabs. One tab lets you drag sliders to modify the joint angles of each joint, and the other tab allows you to specify comma-separated angles for all 6 joints in an editable text box and ask for the SE(3) transformation from the base frame to the end-effector frame. The frames attached to the base and end-effector are persistently displayed (x-axis in red, y-axis in green, z-axis in blue). Note that all angles are specified in radians.

  • Download the ttt scene file here.


Scene 3: CSV Animation UR5

This scene is similar to Scene 1 except it simulates UR5 robot. You can interactively control the configuration of the mobile base and the arm. Each column of the csv file is the joint angle through time for one of the joints (first column is joint 1, last column is joint 6).

  • Download the ttt scene file here.
  • Download an example csv file here.

Scene 4: Interactive youBot

Youbot-fig.png

This scene simulates a youBot from KUKA. The KUKA youBot is a mobile manipulator consisting of a mecanum-wheel omnidirectional base and a 5R robot arm. The use of this scene is similar to Scene 2, by which you can interactively control the configuration of the mobile base and the arm.

  • Download the ttt scene file here.


Scene 5: CSV Animation youBot

Youbot-top-view.png

This scene is similar to Scene 1 and 3, except now it simulates youBot and the csv file consists of 12 or 13 configuration variables per row: 3 for the mobile base (ordered as phi, x, y), 5 for the arm (joints 1 to 5), and 4 for the wheels (ordered as you see in the figure on the right). The last variable is optional, which is for controlling the state of the gripper as the end-effector. The gripper is open by default but you can set the last variable as 0 for open and 1 for close the gripper.

  • Download the ttt scene file here.
  • Download an example csv file here.


Scene 6: CSV Motion Planning Kilobot

Kilobot-img.png

This scene simulates a Kilobot. It allows you to visualize a weighted undirected graph with some obstacles and a planar path for Kilobot to follow. The origin of the world frame is at (0,0) and the graph as well as the obstacles and Kilobot should be limited into a square of -0.5 <= x <= 0.5 and -0.5 <= y <= 0.5. The input of the GUI is a path of a folder including the following 4 specifically named csv files.

obstacles.csv: This file specifies the locations and diameters of all cylinder obstacles. Each row represents the x, y value of one cylinder obstacle and its diameter in order.

nodes.csv: This file specifies the ID numbers, locations of nodes and estimated actual cost-to-go from their locations to the goal. Each row represents the ID number, x, y value of one node and its estimated actual cost-to-go in order. The ID number should be continuous integers beginning with 1. Note that you will need to kick out any node blocked by obstacles.

edges.csv: This file specifies the locations of all edges in the graph and their costs (weights). Each row represents two ID numbers of nodes which one edge is connecting and the edge's cost in order. Note that you will nee to kick out any edge blocked by obstacles.

path.csv: This file specifies the nodes in the path with their ID numbers in order. In other words, there is only one row of numbers in this file, with the first number for the start node ID and the last number for the goal node ID. The scene will show all the obstacles, nodes, edges and one path from the start node to the goal node. The nodes, edges and path are marked in blue, yellow and green respectively. The goal node is marked in red. The Kilobot will move from the start node to the goal node following the path in a constant velocity.

  • Download the ttt scene file here.
  • Download an example folder for csv files here. You will need to extract it first.


Scene 7: CSV Mobile Manipulation youBot

Youbot-capstone.png

This scene is similar to Scene 5, except now the youBot is expected to accomplish a pick-and-place motion. There is a cube on the ground for youBot to pick and a frame representing the final end-effector configuration after placing the cube. The input and use of this scene is the same as Scene 5. The other differences with Scene 5 are that the whole robot is now respondable, meaning that the links of the robot are now capable of interacting with the world or each other through collisions. The gripper of the youBot and the cube are even dynamically modelled to simulate the practical pick-and-place motion.

  • Download the ttt scene file here.
  • Download an example csv file here.


Switching Between Scenes

Press the Stop button to stop the simulation of the current scene, then choose File>Open scene.... You can also use File>Open recent scene to switch to a scene you previously loaded. Then you press the Play button to run the scene. Alternatively, stop the simulation and then press the Scenes button in the top toolbar to see which scenes are currently open and select one to be in the foreground. The scene selector toolbar button may also be used to switch between opened scenes. Read more here.

Recording a Movie

V-REP comes with a video recorder. Go to Tools>Video recorder. You may need to stop the current scene to be able to configure the video recorder. You can find more information on recording V-REP movies here: http://www.coppeliarobotics.com/helpFiles/en/aviRecorder.htm.

A simpler option may be to just use your computer's screen recording software. On the Mac, you can use Quicktime. On Linux, you can use SimpleScreenRecorder or recordMyDesktop. On Windows, you can use Screen Recorder. Or you may have your own solution.

Exploring Other Scenes

You are encouraged to explore some of the (quite impressive) scenes that come pre-loaded with V-REP. You can find these scenes in the scenes directory under the V-REP directory. Running and studying these can be a great way to learn more about the V-REP capabilities and to understand how to put together more complex scenes.

Useful Resources