|
| 1 | +# Adding Robots |
| 2 | + |
| 3 | +If the robot you want is not currently supported, then why not add it in! |
| 4 | +Below is a quick tutorial on how to do this. The tutorial assumes some proficiency with V-REP. |
| 5 | +You may want to take a look at the V-REP [tutorials](http://www.coppeliarobotics.com/helpFiles/en/tutorials.htm). |
| 6 | + |
| 7 | +#### 1. V-REP documentation |
| 8 | + |
| 9 | +First read through the '[building a clean model tutorial](http://www.coppeliarobotics.com/helpFiles/en/buildingAModelTutorial.htm)', |
| 10 | +which will show you how to first import CAD data (OBJ, STL, DXF), Collada, or |
| 11 | +URDF files, and then how to configure the dynamic shapes. |
| 12 | + |
| 13 | +#### 2. Object naming |
| 14 | + |
| 15 | +After step 1, you should now have your model in the V-REP scene. |
| 16 | +Ensure that all of your joints are in Torque/force mode and that both |
| 17 | +the motor and control loop is enabled. Also ensure that the robot root is a 'model'. |
| 18 | +Do this by double clicking the robot root in the scene hierarchy to open |
| 19 | +up the 'Scene Object Properties' dialog, navigate to the 'Common' tab, and |
| 20 | +check 'Object is model base'. |
| 21 | + |
| 22 | +Make sure that each of the scene objects are named appropriately. For example, |
| 23 | +for the UR10 robot, we name the visual objects 'UR10_link1_visible', 'UR10_link2_visible', etc, |
| 24 | +and the joints 'UR10_joint1', 'UR10_joint2', etc. |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +#### 3. Adding child script |
| 29 | + |
| 30 | +On the root node of the robot, create a 'Non-threaded child script'. |
| 31 | +**You do not need to modify the file**. This is needed to ensure that if the |
| 32 | +robot is cloned, then the object names in the clone behave as expected. |
| 33 | + |
| 34 | +#### 4. Collision collections |
| 35 | + |
| 36 | +Now we will make a collision collection. In the toolbar on the left, |
| 37 | +click to open the 'Collections' dialog. Click 'Add new collection' and a new item |
| 38 | +will appear in the 'Collections list'. Rename this (by double clicking on the item) |
| 39 | +to '\<Robot\>_arm' where '\<Robot\>' |
| 40 | +is the name of the arm. For example, for the UR10, this would be 'UR10_arm'. In the scene hierarchy, |
| 41 | +click the root of the robot, and then in the 'Collections' dialog (making sure |
| 42 | +the correct item in the 'Collection list' is selected), click the |
| 43 | +'Tree of selected object' radio button, and then click 'Add'. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +#### 5. Kinematics |
| 49 | + |
| 50 | +##### Dummys |
| 51 | + |
| 52 | +First create 2 Dummy objects, named '\<MYRobot\>_target' and '\<MYRobot\>_tip' (e.g. UR10_target and UR10_tip). |
| 53 | +In the scene hierarchy, the 'target' dummy should be a child of the robot root node, and the tip |
| 54 | +dummy should be a child of the last node in the robot arm. |
| 55 | +Position both the dummies at the tip of the arm, and orient the tip dummy such |
| 56 | +that the z-axis points out from the arm. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +##### Kinematics group |
| 61 | + |
| 62 | +Now we will add a kinematics group (needed for motion planning). In the toolbar on the left, |
| 63 | +click to open the 'Calculation Modules' dialog, and navigate to the 'Kinematics' tab. |
| 64 | +Click 'Add new IK group' and a new item will appear in the list. Rename this |
| 65 | +(by double clicking on item) to '\<Robot\>_ik' where '\<Robot\>' |
| 66 | +is the name of the arm. For example, for the UR10, this would be 'UR10_ik'. |
| 67 | +You should be able to leave the default values. Ensure that 'Explicit handling' is checked. |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +Finally, double click on the 'target' dummy and choose the '\<MYRobot\>_tip' option from the 'Linked dummy' dropdown, |
| 72 | +and choose the 'IK, tip-target' option from the 'Link type' dropdown. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +##### Python Time |
| 77 | + |
| 78 | +Now we are done with the V-REP side of things. If you have been |
| 79 | +keeping to the naming conventions, then there is very little code needed! |
| 80 | + |
| 81 | +Navigate to `pyrep/arms/` and create a new python file called 'my_robot.py', e.g. 'ur10.py'. |
| 82 | +Your file should look something like this: |
| 83 | + |
| 84 | +```python |
| 85 | +from pyrep.robots.arms.arm import Arm |
| 86 | + |
| 87 | +class MyRobot(Arm): |
| 88 | + |
| 89 | + def __init__(self, count: int = 0): |
| 90 | + super().__init__(count, 'MyRobot', num_joints=6) |
| 91 | + |
| 92 | +``` |
| 93 | + |
| 94 | +The string: 'MyRobot', should match exactly the prefix used in the previous steps of the tutorial, e.g. 'UR10'. |
| 95 | + |
| 96 | +##### Tests and finishing up |
| 97 | + |
| 98 | +Adding unit tests for the robot is easy! |
| 99 | + |
| 100 | +Open up the scene `tests/assets/test_scene_robots.ttt` and place your robot in there. This |
| 101 | +scene file contains all of the robot arms that have been brought in to PyRep and is used for testing |
| 102 | +that the robots have been created correctly. |
| 103 | + |
| 104 | +Now simply navigate to `tests/test_arms_and_configuration_paths.py`, |
| 105 | +and add your new robot to the list of `ARMS` (following the convention already in place). |
| 106 | +Run the unit tests before submitting a pull request. |
| 107 | + |
| 108 | +**Please do not submit pull request unless the robot is unit tested.** |
| 109 | + |
| 110 | +If you get stuck at any point, take a look at some of the existing robots in PyRep. |
| 111 | +If you are still stuck, the feel free to raise an issue and ask a question. |
0 commit comments