Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:pycram:setup [2021/07/02 09:41] – jdech | tutorials:pycram:setup [2022/02/01 15:57] (current) – [PyCRAM on Ubuntu 20.04 (ROS Noetic)] jdech | ||
---|---|---|---|
Line 8: | Line 8: | ||
All dependencies are available via PyPi | All dependencies are available via PyPi | ||
- | PyCRAM is developed and tested with Python3.8, Ubuntu 20.04 and ROS Melodic. | + | PyCRAM is developed and tested |
===== Installing ROS ===== | ===== Installing ROS ===== | ||
PyCRAM uses ROS for a variety of functionality, | PyCRAM uses ROS for a variety of functionality, | ||
- | For information on how to install ROS please referee to the offical | + | For information on how to install ROS please referee to the official |
- | ===== Dependencies ===== | + | ===== Installing |
- | To install PyCRAM firstly the required packages must be installed. These are: | + | The dependencies you will need are: |
* Pip | * Pip | ||
- | * CRAM/ | + | * vcstool |
- | * pybullet | + | These are available via the Ubuntu apt-repos and can be installed via the terminal: |
- | * Pathlib | + | <code bash> |
- | * numpy | + | sudo apt-get install python3-pip python3-vcstool |
- | * urdfpy | + | </ |
- | * graphviz | + | |
- | * urdf-parser-py | + | |
- | Firstly Pip needs to be installed, | + | ===== PyCRAM |
- | < | + | Before installing PyCRAM you need to setup a ROS workspace into which PyCRAM |
+ | < | ||
+ | mkdir -p ~/ | ||
+ | cd workspace/ | ||
+ | catkin_make | ||
+ | source devel/ | ||
+ | </ | ||
- | PyCRAM uses the the KDL Inverse Kinematic service of CRAM, to use the IK service CRAM needs to be installed. For instructions on how to install CRAM click [[../../installation | here]]. | + | If '' |
+ | <code bash> | ||
+ | source | ||
+ | </code> | ||
+ | Now you can install PyCRAM into your ROS workspace. | ||
- | The rest can be installed using Pip by typing the following command into a terminal: | + | < |
- | < | + | |
- | + | ||
- | ===== PyCRAM ===== | + | |
- | To get PyCRAM simply clone the repository with the following command into your ROS workspace: | + | |
- | < | + | |
cd <Path to your ROS workspace> | cd <Path to your ROS workspace> | ||
cd src/ | cd src/ | ||
- | git clone https://github.com/ | + | vcs import --input |
- | cd pycram/ | + | </ |
+ | |||
+ | The cloning and setting up can take several minutes. After the command finishes you should see a number of repositories in your ROS workspace. | ||
+ | |||
+ | Now the last thing that needs to be done is clone the submodules of the PyCRAM repo, this is done via the following commands: | ||
+ | <code bash> | ||
+ | cd pycram | ||
git submodule init | git submodule init | ||
git submodule update | git submodule update | ||
Line 46: | Line 55: | ||
The cloned repository contains the source code for PyCRAM as well as two short demos which demonstrate how to use it. | The cloned repository contains the source code for PyCRAM as well as two short demos which demonstrate how to use it. | ||
+ | |||
+ | |||
+ | ===== Python Dependencies ===== | ||
+ | To install the Python dependencies Pip is used. To install Pip type the following command into a terminal. | ||
+ | < | ||
+ | sudo apt-get install python3-pip | ||
+ | </ | ||
+ | |||
+ | Now the actual Python packages can be installed, these are summarized in the requirements.txt in the PyCRAM repo. | ||
+ | For this first navigate to your PyCRAM repo. | ||
+ | < | ||
+ | cd < | ||
+ | </ | ||
+ | Then install the Python packages in the requirements.txt file | ||
+ | < | ||
+ | sudo pip install -r requirements.txt | ||
+ | </ | ||
===== Building your ROS workspace ===== | ===== Building your ROS workspace ===== | ||
Line 51: | Line 77: | ||
You can build your ROS workspace with the following commands: | You can build your ROS workspace with the following commands: | ||
- | < | + | < |
cd <Path to your ROS workspace> | cd <Path to your ROS workspace> | ||
catkin_make | catkin_make | ||
source devel/ | source devel/ | ||
</ | </ | ||
+ | |||
+ | ===== PyCRAM on Ubuntu 18.04 (ROS Melodic) ===== | ||
+ | To be able to use PyCRAM on Ubuntu 18.04 you need a few extra steps because ROS melodic doesn' | ||
+ | < | ||
+ | apt-get install python3-pip | ||
+ | </ | ||
+ | Next you need to install the Python dependencies using pip | ||
+ | < | ||
+ | pip3 install rospkg empy numpy | ||
+ | </ | ||
+ | So far you should be able to import rospy in Python and use all features but for PyCRAM to function you also need the ROS tf package which is unfortunately not available in Python 3. To be able to use the tf package we will compile it our self for Python 3. | ||
+ | ==== Build Tf for Python 3 ==== | ||
+ | Firstly you need to clone the geometry and geometry2 repos into your ROS workspace and select the melodic branches. | ||
+ | < | ||
+ | cd ur_ros_ws/ | ||
+ | git clone git@github.com: | ||
+ | cd geometry | ||
+ | git checkout melodic-devel | ||
+ | cd .. | ||
+ | git clone git@github.com: | ||
+ | cd geometry2 | ||
+ | git checkout melodic-devel | ||
+ | </ | ||
+ | Now all you need to do is source ROS and build your workspace using for Python 3. | ||
+ | < | ||
+ | source / | ||
+ | cd ur_ros_ws/ | ||
+ | catkin_make -DPYTHON_EXECUTABLE=/ | ||
+ | </ | ||
+ | This should build the Tf package for Python 3. Now you can source your workspace and use the Tf package. | ||
+ | |||
+ | In order to use ROS and the Python3 Tf package you have to pay attention to a little thing when sourcing ROS. It is not enough to just source your workspace, you need to source the '/ | ||
+ | |||
+ | The easiest way is to add the two sourcing commands to your .bashrc like so. | ||
+ | < | ||
+ | echo " | ||
+ | </ | ||
+ | |||
+ | ==== Build PyKDL for Python 3 ==== | ||
+ | Now you need to build PyKDL as well as kdl_parser_py for Python 3. This is done in two distinctive steps, first build orocos_kdl using cmake outside of your catkin workspace and then building your catkin workspace containing PyKDL and kdl_parser_py for Python 3. | ||
+ | First clone the orocos kinematics dynamicas Repo, outside of your catkin workspace. | ||
+ | < | ||
+ | git clone git@github.com: | ||
+ | </ | ||
+ | Now build the orocos_kdl library, by pasting the following commands in a terminal. | ||
+ | < | ||
+ | cd orocos_kinematics_dynamics/ | ||
+ | mkdir build | ||
+ | cd build | ||
+ | cmake .. | ||
+ | make | ||
+ | sudo make install | ||
+ | </ | ||
+ | |||
+ | Now all you have to do is copy the PyKDL package from the orocos kinematics dynamics folder to your catkin workspace, clone the kdl_parser_py and build. | ||
+ | < | ||
+ | cd orocos_kinematics_dynamics | ||
+ | git submodule update --init | ||
+ | cp python_orocos_kdl path/ | ||
+ | cd <path to yourt catkin workspace>/ | ||
+ | cd ../ | ||
+ | </ | ||
+ | This will copy python orocos kdl into your catkin workspace and clone the submodules contained in the repo. Now we have to clone the kdl_parser_py and build. | ||
+ | < | ||
+ | git clone git@github.com: | ||
+ | cd ../.. | ||
+ | catkin_make -DPYTHON_EXECUTABLE=/ | ||
+ | </ | ||