Embedded Motion Control 2013/Installation: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
 
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This manual describes how to the install the necessary and sufficient software to start programming the Jazz robot.
This manual describes how to the install the necessary and sufficient software to start programming the Pico robot.


== Ubuntu ==
== Ubuntu ==


Go to [http://ubuntu.com The official Ubuntu site] and download and install '''Ubuntu 12.04''', which is the latest '''Long Term Support''' release. Make sure that you download the appropriate architecture i.e., 32- or 64-bit. Of course you can also bring your notebook to the ICT servicedesk and ask them to install Ubuntu. If you want to keep using Windows next to Ubuntu the most easy way is to have a dual-boot system, i.e., during startup you can choose to boot either Ubuntu or Windows.
Download Ubuntu 12.04 using these direct links: [http://releases.ubuntu.com/12.04/ubuntu-12.04.4-desktop-i386.iso 32-bit] or [http://releases.ubuntu.com/12.04/ubuntu-12.04.4-desktop-amd64.iso 64-bit]. Then go to [http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows this page] and follow the instructions to create a bootable USB stick. Reboot your computer with the newly created USB stick, and install Ubuntu. If you want to keep using Windows next to Ubuntu the most easy way is to have a dual-boot system, i.e., during startup you can choose to boot either Ubuntu or Windows. Of course you can also bring your notebook to the ICT servicedesk and ask them to install Ubuntu (but mention that you need version 12.04, '''not 14.04''').


=== Ubuntu Terminal ===
=== Ubuntu Terminal ===


Most of your interaction with Ubuntu will be done through the terminal, the number-one way of interacting with Ubuntu using your keyboard. A terminal can be started as follows: ''Application -> Accessories -> Terminal'', or by pressing ''ctrl-alt-t''. It might be a good idea to drag the terminal icon in the menu to the Ubuntu panel, as you will be using it a lot.
Most of your interaction with Ubuntu will be done through the terminal, the number-one way of interacting with Ubuntu using your keyboard. A terminal can be started as follows: ''Application -> Accessories -> Terminal'', or by pressing ''ctrl-alt-t''. It might be a good idea to drag the terminal icon in the menu to the Ubuntu panel, as you will be using it a lot. [[ubuntu terminals | Read more]]
 
Although the terminal commands may seem somewhat puzzling at first, you'll soon find out that the terminal is a nifty tool and allows for faster and more powerful access to all of Ubuntu's possibilities than the graphical interface and mouse. If you don't know your way around the terminal, have a look at [https://help.ubuntu.com/community/UsingTheTerminal this page].
 
A convenient tool to avoid having a large amount of terminals is Terminator, so you can have multiple terminals in one window. To make Terminator start up with some screen setup:
* 1. Open “Terminator”
* 2. Make the set-up to be saved: some split ups
** a. Right click
** b. Choose “split horizontally” or “split vertically”
** c. Continue the previous step, until you are happy
* 3. Right click
* 4. Choose “preferences”
* 5. Pick tab “layout”
* 6. Click "add"
* 7. Enter a name  (= <your chosen name>)
* 8. Press "enter"
* 9. Click "close"
* 10. Right click the button to open “Terminator”
* 11. Choose “properties”
* 12. Enter in “command” : “terminator -l <your chosen name>”
* 13. Click close
* 14. To test: open “Terminator”


== ROS ==
== ROS ==


In this project we will use the '''Robotic Operating System''' (ROS) which aids the testing and development of robot software. ROS provides a nice open-source framework for dealing with the communication between and management of different modules, and comes with a large amount of software that can be used out of the box, including device drivers, libraries, low- and high-level software, visualizers and more. More information about ROS and its goals can be found [http://www.ros.org/wiki/ROS/Introduction here]. The ROS tutorial can be found [http://www.ros.org/wiki/ROS/Tutorials here].  
In this project we will use the '''Robotic Operating System''' (ROS) which aids the testing and development of robot software. ROS provides a nice open-source framework for dealing with the communication between and management of different modules, and comes with a large amount of software that can be used out of the box, including device drivers, libraries, low- and high-level software, visualizers and more. More information about ROS and its goals can be found [http://www.ros.org/wiki/ROS/Introduction here].  


To install ROS Fuerte under Ubuntu 12.04, do the following:
We will be using ROS Groovy. Install ROS Groovy using the installation instructions on the [http://wiki.ros.org/groovy/Installation/Ubuntu ROS wiki]. After the installation, you should do the ROS tutorials. The ROS tutorial can be found [http://www.ros.org/wiki/ROS/Tutorials here]. In some of the tutorials you can choose between catkin and rosbuild (for example in [http://wiki.ros.org/ROS/Tutorials/CreatingPackage this tutorial]. Make sure you select rosbuild (above the content text box).


# Add the ROS Debian source to your ''sources.list'' such that Ubuntu knows where to download ROS from. Open a terminal (''Applications -> Accessories -> Terminal'') and enter:  
Before you continue, make sure you understand the basic ROS concepts, such as:
<pre>sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu precise main" > /etc/apt/sources.list.d/ros-latest.list'</pre>
* package
# To be able to connect with the server, you need to add its public key to your keys: <pre>wget http://packages.ros.org/ros.key -O - | sudo apt-key add -</pre>
* node
# Make sure you have re-indexed the ROS.org server such that you get the latest changes:<pre>sudo apt-get update</pre>
* topic
# Then, install a ROS desktop:<pre>sudo apt-get install ros-fuerte-desktop</pre>
* subscriber
<!-- # <pre>echo "source /opt/ros/electric/setup.bash" >> ~/.bashrc</pre><pre>. ~/.bashrc</pre> -->
* publisher
* message
* callback function
* ...


If you ran into problems, be sure to check the [http://www.ros.org/wiki/fuerte/Installation/Ubuntu installation guide on the ROS website].
In addition it is important to know the concept of the ROS_PACKAGE_PATH. ROS_PACKAGE_PATH is a variable which informs ROS on the location of your packages. ROS will only be able to find packages which are located in a folder which is part of your package path! To print the value of the ROS_PACKAGE_PATH variable, you can simply type:
<pre>
echo $ROS_PACKAGE_PATH
</pre>
in a terminal.


== SVN ==
== SVN ==
In this project, an [http://svnbook.red-bean.com/en/1.7/svn.intro.whatis.html SVN] will be used for sharing and versioning the software within your group. Every group has its own space on the SVN, and an account which has only permissions for that particular part.
In this project, an SVN will be used for sharing and versioning the software within your group. Every group has its own space on the SVN, and an account which has only permissions for that particular part. Make sure you read the following [[SVN instruction]] carefully! Not reading them might cost you a lot of time in the end!
 
<!--
'''The EMC SVN is not yet available. You will be informed once the SVN is ready for check-out.''' However, you may already create a directory in which you can check-out the SVN once it is available. To do that, type the following command in a terminal:<pre>mkdir ~/ros</pre>
-->
 
To set up the directory to where the code is checked out from the SVN, open a terminal and do the following:
 
# First, create a directory in your home directory in which you will put all ROS-related code, files and data: <pre>mkdir ~/ros</pre>
# Then, go to that folder <pre> cd ~/ros</pre> and check out your group folder from the SVN. For example, for group 1:<pre>svn co https://roboticssrv.wtb.tue.nl/svn/emc/2013/groups/emc01</pre> You will be prompted for your account name and password.
# Furthermore, check out the general folder, which contains the robot simulator:<pre>svn co https://roboticssrv.wtb.tue.nl/svn/emc/2013/general</pre>
 
You now have the latest version of all the code that is available on your computer. If you make any changes or improvements, you can save these changes on your disk without interacting with the SVN.
 
Once you are done with your work, or if you want to save intermediate results on the SVN, you can commit your changes by going to the folder where you have made the changes and then typing:
<pre> svn ci -m 'a description of the changes you made' file_I_want_to_commit.cpp</pre>
Please note that this will only upload the changes of files that are already on the SVN. If you want to add new files to the SVN you first have to add them by typing:
<pre>svn add file_I_want_to_add.cpp</pre>
You can add a folder recursively (with all files included in the folder) by typing:
<pre>svn add folder_I_want_to_add</pre>
Note that after adding you still have to commit your changes in order to store them on the SVN. You can delete files on the same way by typing delete rather then add.


'''Note''': make sure you do not add auto-generated files, such as executables, to your SVN.


== Environment Set-up ==
== Environment Set-up ==
Line 78: Line 43:
Append the following text to the end of the file:
Append the following text to the end of the file:


<pre>source /opt/ros/fuerte/setup.bash</pre>
<pre>source /opt/ros/groovy/setup.bash</pre>


This will set-up all ROS-related scripts etc. every time you open a terminal. Furthermore, ROS needs to known where your software is located. Therefore, also add the following command to ''~/.bashrc'':
This will set-up all ROS-related scripts etc. every time you open a terminal. Furthermore, ROS needs to known where your software is located. Therefore, also add the following command to ''~/.bashrc'':


<pre>export ROS_PACKAGE_PATH=~/ros:$ROS_PACKAGE_PATH</pre>
<pre>export ROS_PACKAGE_PATH=~/ros/emc:$ROS_PACKAGE_PATH</pre>


That's it. Next time you open a terminal, ''.bashrc'' is executed, which will in turn execute the script and set the path specified above. Since the script only runs when a new terminal is opened, the changes are not active in your current terminal. If you want to see it working directly without starting a new terminal, explicitly source ''.bashrc'' from the terminal:
That's it. Next time you open a terminal, ''.bashrc'' is executed, which will in turn execute the script and set the path specified. This command tells ROS to look in the emc/ros folder whenever it is looking for your code. Since the script only runs when a new terminal is opened, the changes are not active in your current terminal. If you want to see it working directly without starting a new terminal, explicitly source ''.bashrc'' from the terminal:


<pre>source ~/.bashrc</pre>
<pre>source ~/.bashrc</pre>


To see whether it worked, try one of commands that are now at your disposal. For example, change your directory to the '''roscpp''' package:
This command forces the terminal to reload all variables without restarting the terminal. To see whether it worked, try one of commands that are now at your disposal. For example, change your directory to the '''roscpp''' package:


<pre>roscd roscpp</pre>
<pre>roscd roscpp</pre>


== Integrated Development Environments ==
== Integrated Development Environments ==
To keep the code in your packages clear and manageable, it is advised to use an ''Integrated Development Environment'' (IDE) to edit your C++ code. Two editors that are commonly used are Qt Creator and Eclipse.  
To keep the code in your packages clear and manageable, it is advised to use an ''Integrated Development Environment'' (IDE) to edit your C++ code. Two editors that are commonly used are Qt Creator and Eclipse. Both of these editors have the advantage of understanding you code up to some extend. This means they can be used to, e.g., autocomplete names of variables and functions or get compilation error message in a nice way. We recommand using Qt or Eclipse. Continue [[ide | here]].
 
=== Qt Creator ===
==== Installation ====
 
# Download Qt Creator for Linux: [http://download.qt-project.org/archive/qtcreator/2.5/qt-creator-linux-x86-opensource-2.5.2.bin  32-bit] or [http://download.qt-project.org/archive/qtcreator/2.5/qt-creator-linux-x86_64-opensource-2.5.2.bin 64-bit] (Visit the website [http://qt-project.org/ here]). Best is to go to the website and get the most current version. '''Don't use the software centrum to get Qt, then all this will not work properly'''
# Open a terminal, ''cd'' to the folder where you downloaded the file (probably ''~/Downloads'')
# Make the file executable: <pre>chmod +x <INSTALL_FILE></pre>
# Run the installation: <pre>./<INSTALL_FILE></pre>
# Make sure Qt Creator launches with the ROS environment available:
## Open the launcher properties (right-click Applications -> Edit Menus -> Programming -> Qt Creator -> Properties
## In the 'Command' field, add ''bash -i -c '' in front of the existing command.
 
Now you can correctly launch Qt Creator from the menu.
 
==== Use with ROS ====
 
===== Creating a ROS package =====
 
To create a ROS package, follow the usual steps, ''i.e.'', use the ''roscreate-pkg'' command.
 
===== Open an existing ROS package =====
 
# Make sure your package is in the ROS_PACKAGE_PATH
# Start Qt Creator
# File -> Open File or Project
# Navigate to and open the '''CMakeLists.txt''' file of your package
# Change the build directory into ''<YOUR_PACKAGE_DIR>/build'' (that is: a '''/''' instead of a '''-'''). Click 'Next'.
# Click 'Run CMake'. This will automatically look for and include dependencies in the '''manifest.xml''' file, see which ''.cpp'' files you use, etc, based on your CMakeLists.txt.
# Click 'Finish'
 
Now you are ready to start developing your code. Pressing ''Ctrl-b'' will build the active project. If you change the '''manifest.xml''' or '''CMakeLists.txt''' file, you only have to run CMake again (''Build -> Run CMake'').
 
===== Show header files in the 'Projects View' =====
 
Qt Creator only shows your ''.cpp'' files in the 'Project View', which can be a bit of a nuisance. To also show your header files, perform the following trick:
 
# Open ''CMakeLists.txt''
# Add the following line before ''rosbuild_add_executable'': <pre>file(GLOB_RECURSE HEADER_FILES include/*.h)</pre>This looks for all ''.h'' files in the ''include'' folder of your package, and stores them in the variable ''HEADER_FILES''.
# Add ''${HEADER_FILES}'' to your ''rosbuid_add_executable'' list. For example:<pre>rosbuild_add_executable(my_program src/program.cpp ${HEADER_FILES})</pre>
# Within Qt Creator, run CMake (''Build -> Run CMake'')
 
You should now be able to see all ''.h'' files in the ''include'' folder of your package.
 
===== Troubleshoot =====
 
====== CMake Error ======
 
If you try to open your project in Qt Creator and you get the following message when running CMake:
 
<pre>
CMake Error: The current CMakeCache.txt directory <YOUR_PACKAGE>/build/CMakeCache.txt is different
than the directory <OTHER_DIR>/build where CMakeCache.txt was created. This may result in binaries
being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
</pre>
 
you have probably moved your package without cleaning it (''make clean''). This means the absolute paths that where generated during building do not make sense anymore. To solve this, do the following:
 
* Clean your project, ''i.e.'', run ''make clean''
* Make sure there is no ''CmakeLists.txt.user'' in your package (it is auto-generated by Qt Creator)
* Try to open your project again
 


=== Eclipse ===
== Gazebo ==
Eclipse is an IDE widely used for Java, C, C++ and many more languages. This section explains how it can be configured to be easily used with ROS packages.


To install Eclipse, do the following:
We will use the robot simulator [[http://gazebosim.org/ Gazebo]] to simulate the PICO robot and its environment. This includes simulation of the physics and sensors of the robot. To install Gazebo:


# Go to the [http://www.eclipse.org/downloads Eclipse download site]
# Open a terminal (''ctrl-alt-t'')
# Find '''Eclipse IDE for C/C++ Developers''' and select the appropriate version on the right (32-Bit or 64-Bit Linux).
# Setup your computer to accept software from packages.osrfoundation.org:<pre>sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu precise main" > /etc/apt/sources.list.d/gazebo-latest.list'</pre>
# Extract Eclipse into a folder of your choice
# Retrieve and install the keys for the Gazebo repositories:<pre>wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -</pre>
# You can create a launcher to Eclipse to your panel by alt + right clicking the panel, choosing 'Add to panel' and selecting 'Custom Application Launcher'. Then browse to the Eclipse executable, and enter a name. If you want you can add the Eclipse icon by clicking the image on the left and browsing to the icon in the Eclipse folder.
# Update apt-get and install Gazebo.<pre>sudo apt-get update</pre><pre>sudo apt-get install gazebo</pre>
# Initialize.<pre>gzserver</pre> Wait until you get a message like ''Publicized address: ...''.  


You can try if your Gazebo installation was successfull by either executing a gazebo client on a seperate terminal:


Now, to make sure your package can be viewed properly in Eclipse, do the following:
<pre>gzclient</pre>


# Create a custom package in your ~/ros directory with optional dependencies: <pre>cd ~/ros</pre><pre>roscreate-pkg <package-name> [dependencies...]</pre>
Or by running the program alone:
# Enter in a terminal: <pre>roscd <package name></pre><pre>make eclipse-project</pre>
# Open Eclipse
#* You will be prompted to select a path for the workspace. The default (''/home/YOUR_NAME/workspace'') is fine here. This folder will not contain the software (that is stored in ''~/ros''), but simply pointers to the software and some administration files for Eclipse.
# Go to “file” → “Import”
# Click “General”
# Then “Existing Projects into Workspace”
# Click “next”
# Browse for the package


All environment settings should be set automatically. You can build the package using '''ctrl-b'''. Note that you have to remake the eclipse-project in your package every time you change the manifest or if you switch to a new version of ROS. If you're having trouble or want to know more about the possibilities of using eclipse with ROS, check the [http://www.ros.org/wiki/IDEs ROS wiki].
<pre>gazebo</pre>

Latest revision as of 19:10, 23 April 2014

This manual describes how to the install the necessary and sufficient software to start programming the Pico robot.

Ubuntu

Download Ubuntu 12.04 using these direct links: 32-bit or 64-bit. Then go to this page and follow the instructions to create a bootable USB stick. Reboot your computer with the newly created USB stick, and install Ubuntu. If you want to keep using Windows next to Ubuntu the most easy way is to have a dual-boot system, i.e., during startup you can choose to boot either Ubuntu or Windows. Of course you can also bring your notebook to the ICT servicedesk and ask them to install Ubuntu (but mention that you need version 12.04, not 14.04).

Ubuntu Terminal

Most of your interaction with Ubuntu will be done through the terminal, the number-one way of interacting with Ubuntu using your keyboard. A terminal can be started as follows: Application -> Accessories -> Terminal, or by pressing ctrl-alt-t. It might be a good idea to drag the terminal icon in the menu to the Ubuntu panel, as you will be using it a lot. Read more

ROS

In this project we will use the Robotic Operating System (ROS) which aids the testing and development of robot software. ROS provides a nice open-source framework for dealing with the communication between and management of different modules, and comes with a large amount of software that can be used out of the box, including device drivers, libraries, low- and high-level software, visualizers and more. More information about ROS and its goals can be found here.

We will be using ROS Groovy. Install ROS Groovy using the installation instructions on the ROS wiki. After the installation, you should do the ROS tutorials. The ROS tutorial can be found here. In some of the tutorials you can choose between catkin and rosbuild (for example in this tutorial. Make sure you select rosbuild (above the content text box).

Before you continue, make sure you understand the basic ROS concepts, such as:

  • package
  • node
  • topic
  • subscriber
  • publisher
  • message
  • callback function
  • ...

In addition it is important to know the concept of the ROS_PACKAGE_PATH. ROS_PACKAGE_PATH is a variable which informs ROS on the location of your packages. ROS will only be able to find packages which are located in a folder which is part of your package path! To print the value of the ROS_PACKAGE_PATH variable, you can simply type:

echo $ROS_PACKAGE_PATH

in a terminal.

SVN

In this project, an SVN will be used for sharing and versioning the software within your group. Every group has its own space on the SVN, and an account which has only permissions for that particular part. Make sure you read the following SVN instruction carefully! Not reading them might cost you a lot of time in the end!


Environment Set-up

So far we've installed ROS and created a local copy of the SVN. However, before you can start working, you need to do some additional set-ups to make sure Ubuntu knows where to find all ROS-related packages, scripts, etc. More specifically, every time you start up a terminal, the correct environment variables need to be set. The file .bashrc in your home directory is your friend: it's a script which runs every time a a new terminal is opened. We basically need to add some lines to this file, so open the file with a text editor:

gedit ~/.bashrc

Append the following text to the end of the file:

source /opt/ros/groovy/setup.bash

This will set-up all ROS-related scripts etc. every time you open a terminal. Furthermore, ROS needs to known where your software is located. Therefore, also add the following command to ~/.bashrc:

export ROS_PACKAGE_PATH=~/ros/emc:$ROS_PACKAGE_PATH

That's it. Next time you open a terminal, .bashrc is executed, which will in turn execute the script and set the path specified. This command tells ROS to look in the emc/ros folder whenever it is looking for your code. Since the script only runs when a new terminal is opened, the changes are not active in your current terminal. If you want to see it working directly without starting a new terminal, explicitly source .bashrc from the terminal:

source ~/.bashrc

This command forces the terminal to reload all variables without restarting the terminal. To see whether it worked, try one of commands that are now at your disposal. For example, change your directory to the roscpp package:

roscd roscpp

Integrated Development Environments

To keep the code in your packages clear and manageable, it is advised to use an Integrated Development Environment (IDE) to edit your C++ code. Two editors that are commonly used are Qt Creator and Eclipse. Both of these editors have the advantage of understanding you code up to some extend. This means they can be used to, e.g., autocomplete names of variables and functions or get compilation error message in a nice way. We recommand using Qt or Eclipse. Continue here.

Gazebo

We will use the robot simulator [Gazebo] to simulate the PICO robot and its environment. This includes simulation of the physics and sensors of the robot. To install Gazebo:

  1. Open a terminal (ctrl-alt-t)
  2. Setup your computer to accept software from packages.osrfoundation.org:
    sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu precise main" > /etc/apt/sources.list.d/gazebo-latest.list'
  3. Retrieve and install the keys for the Gazebo repositories:
    wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
  4. Update apt-get and install Gazebo.
    sudo apt-get update
    sudo apt-get install gazebo
  5. Initialize.
    gzserver
    Wait until you get a message like Publicized address: ....

You can try if your Gazebo installation was successfull by either executing a gazebo client on a seperate terminal:

gzclient

Or by running the program alone:

gazebo