Difference between revisions of "Ros"

From ArchWiki
Jump to: navigation, search
m (Ros 2: Moved comment where it belongs)
 
(81 intermediate revisions by 26 users not shown)
Line 1: Line 1:
Originally from the [http://www.ros.org/wiki/cturtle/Installation/Arch ROS wiki].
+
[[Category:Mathematics and science]]
 +
[[ja:Ros]]
 
[http://www.ros.org ROS] is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management.
 
[http://www.ros.org ROS] is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management.
  
== Setup ==
+
== Installation Instructions ==
  
pacman -S python2 cmake wget python-yaml python2-distribute
+
=== Lunar ===
  
== Rosinstall ==
+
ROS Lunar is available in AUR packages and seems to be working quite nicely. The {{AUR|ros-lunar-desktop-full}} is complete and seems to have everything functional.
  
The following lines will download the ROS source code using the rosinstall tool, and bootstrap the installation. The installation downloads all ROS stacks in subdirectories inside the ~/ros directory, one subdirectory for each stack in the rosinstall file.
+
=== Kinetic ===
  
First install rosinstall:
+
Kinetic packages on the AUR are a work in progress. There are [https://github.com/bchretien/arch-ros-stacks/issues/57#issuecomment-228612399 some issues regarding opencv3] that have not been fully resolved yet (installing {{AUR|ros-kinetic-opencv3}} works, but is somewhat inefficient since it rebuilds opencv3). Currently, installing a metapackage such as {{AUR|ros-kinetic-ros-core}} or {{AUR|ros-kinetic-robot}} should bring in all required dependencies (see [https://paste.xinu.at/YXIz/] for the correct order, or use an [[AUR_helpers#Comparison_table|AUR helper]] that fully resolves dependency trees).
  
sudo easy_install-2.7 -U rosinstall
+
Packages are being added on an as-needed basis. Please send package requests to <aur AT seangreenslade DOT com>, and post any issues with the current packages in their respective AUR comments section.
  
Then use rosinstall to download your preferred C-Turtle variant:
+
=== Configure the build tool ===
  
ROS-only: Includes basic ROS and tutorials.
+
== catkin_make ==
  
rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=cturtle&variant=ros_only&overlay=no"
+
Note that catkin uses python2, and therefore catkin_make may fail unless it is explicitly pointed to the python2 install. To do so, add the following alias to your .bashrc (or equivalent):
  
Base Install: ROS plus robot-generic stacks (e.g. navigation, visualization)
+
alias catkin_make="catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so"
  
rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=cturtle&variant=base&overlay=no"
+
== catkin build ==
  
PR2 Install: ROS plus PR2-specific stacks, including PR2 simulator.
+
For configuring the systems using the {{ic|catkin build}} environment, one have to configure the catkin workspace as usual and issue a
  
  rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=cturtle&variant=pr2&overlay=no"
+
  catkin config -DPYTHON_EXECUTABLE\=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so"
  
PR2 All Install: ROS plus PR2 and bleeding edge research/experimental stacks.
+
Afterwards, use {{ic|catkin build}} as normal. Please remember to reconfigure your catkin whenever you delete the configuration files (i.e. the {{ic|catkin_ws}} directory)
  
rosinstall ~/ros "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=cturtle&variant=pr2all&overlay=no"
+
== Rebuild when shared libraries are updated ==
  
NOTE: the instructions above download all stacks inside the ~/ros folder. If you prefer a different location, simply change the ~/ros in the commands above.
+
When you update a library that ROS depends on (e.g. Boost), all packages that link to it must be rebuilt. Most AUR helpers will not detect this situation. The following script will generate a list of all packages that are linked to missing so files:
  
==Environment Setup==
+
https://seangreenslade.com/h/snippets/ros-find-outofdate.py
  
You'll now need to update your environment. You can do this by typing:
+
(Note that the script requires {{pkg|pyalpm}} to be installed.)
  
source ~/ros/setup.bash
+
== Ros 2 ==
 +
{{Warning|Work in progress}}
  
It's convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched, which you can do with the command below:
+
Build instructions are available at https://github.com/ros2/ros2/wiki/Linux-Development-Setup. First fetch the sources (requires {{AUR|python-vcstool}}):
  
  echo "source ~/ros/setup.bash" >> ~/.bashrc
+
  $ mkdir -p ~/ros2_ws/src
  . ~/.bashrc
+
$ cd ~/ros2_ws
 +
  $ wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
 +
$ vcs-import src < ros2.repos
  
For Zsh users, change the last line of ~/ros/setup.zsh to
+
Presently some fixes are required:
  
  source $ROS_ROOT/tools/rosbash/roszsh
+
  $ cd ~/ros2_ws/src/ros2/rviz/
 +
$ git remote add racko https://github.com/racko/rviz.git
 +
$ git fetch racko added_cmake_project_type fix_fallthrough fix_wrong_yaml_cpp
 +
$ git cherry-pick racko/added_cmake_project_type racko/fix_fallthrough racko/fix_wrong_yaml_cpp
  
before running source ~/ros/setup.zsh Similarly, have the setup script called at the start of each new shell session with
+
Now you can build the workspace:
  
  echo "source ~/ros/setup.zsh" >> ~/.zshrc
+
  $ cd ~/ros2_ws
. ~/.zshrc
+
$ src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install
  
== Tutorials==
+
This build may fail due to missing dependencies and you need to figure out which package you need to install by yourself (for now).
  
Now, to test your installation, please proceed to the [http://www.ros.org/wiki/ROS/Tutorials ROS Tutorials].
+
Read https://github.com/ros2/ros1_bridge/blob/master/README.md#build-the-bridge-from-source regarding Ros 1 / Ros 2 interoperability.
 +
 
 +
=== Usage Examples ===
 +
 
 +
First source the workspace:
 +
 
 +
$ . ~/ros2_ws/install/local_setup.bash
 +
 
 +
Functionality comparable to {{ic|roscore}}, {{ic|rosnode}}, {{ic|rostopic}}, {{ic|rosmsg}}, {{ic|rospack}}, {{ic|rosrun}} and {{ic|rosservice}} is available via {{ic|ros2}}:
 +
 
 +
$ ros2 -h
 +
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ...
 +
 +
ros2 is an extensible command-line tool for ROS 2.
 +
 +
optional arguments:
 +
  -h, --help            show this help message and exit
 +
 +
Commands:
 +
  daemon    Various daemon related sub-commands
 +
  msg      Various msg related sub-commands
 +
  node      Various node related sub-commands
 +
  pkg      Various package related sub-commands
 +
  run      Run a package specific executable
 +
  security  Various security related sub-commands
 +
  service  Various service related sub-commands
 +
  srv      Various srv related sub-commands
 +
  topic    Various topic related sub-commands
 +
 +
  Call `ros2 <command> -h` for more detailed usage.
 +
 
 +
A typical "Hello World" example starts with running a publisher node:
 +
 
 +
$ ros2 topic pub /chatter 'std_msgs/String' "data: 'Hello World'"
 +
 
 +
Then, in another terminal, you can run a subscriber (Don't forget to source the workspace in every new terminal):
 +
 
 +
$ ros2 topic echo /chatter
 +
 
 +
List existing nodes:
 +
 
 +
$ ros2 node list
 +
publisher_std_msgs_String
 +
 
 +
List topics:
 +
 
 +
$ ros2 topic list
 +
/chatter
 +
 
 +
Ros 2's version of rviz is
 +
 
 +
$ rviz2

Latest revision as of 14:00, 15 December 2017

ROS is an open-source, meta-operating system for your robot. It provides the services you would expect from an operating system, including hardware abstraction, low-level device control, implementation of commonly-used functionality, message-passing between processes, and package management.

Installation Instructions

Lunar

ROS Lunar is available in AUR packages and seems to be working quite nicely. The ros-lunar-desktop-fullAUR is complete and seems to have everything functional.

Kinetic

Kinetic packages on the AUR are a work in progress. There are some issues regarding opencv3 that have not been fully resolved yet (installing ros-kinetic-opencv3AUR works, but is somewhat inefficient since it rebuilds opencv3). Currently, installing a metapackage such as ros-kinetic-ros-coreAUR or ros-kinetic-robotAUR should bring in all required dependencies (see [1] for the correct order, or use an AUR helper that fully resolves dependency trees).

Packages are being added on an as-needed basis. Please send package requests to <aur AT seangreenslade DOT com>, and post any issues with the current packages in their respective AUR comments section.

Configure the build tool

catkin_make

Note that catkin uses python2, and therefore catkin_make may fail unless it is explicitly pointed to the python2 install. To do so, add the following alias to your .bashrc (or equivalent):

alias catkin_make="catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so"

catkin build

For configuring the systems using the catkin build environment, one have to configure the catkin workspace as usual and issue a

catkin config -DPYTHON_EXECUTABLE\=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so"

Afterwards, use catkin build as normal. Please remember to reconfigure your catkin whenever you delete the configuration files (i.e. the catkin_ws directory)

Rebuild when shared libraries are updated

When you update a library that ROS depends on (e.g. Boost), all packages that link to it must be rebuilt. Most AUR helpers will not detect this situation. The following script will generate a list of all packages that are linked to missing so files:

https://seangreenslade.com/h/snippets/ros-find-outofdate.py

(Note that the script requires pyalpm to be installed.)

Ros 2

Warning: Work in progress

Build instructions are available at https://github.com/ros2/ros2/wiki/Linux-Development-Setup. First fetch the sources (requires python-vcstoolAUR):

$ mkdir -p ~/ros2_ws/src
$ cd ~/ros2_ws
$ wget https://raw.githubusercontent.com/ros2/ros2/release-latest/ros2.repos
$ vcs-import src < ros2.repos

Presently some fixes are required:

$ cd ~/ros2_ws/src/ros2/rviz/
$ git remote add racko https://github.com/racko/rviz.git
$ git fetch racko added_cmake_project_type fix_fallthrough fix_wrong_yaml_cpp
$ git cherry-pick racko/added_cmake_project_type racko/fix_fallthrough racko/fix_wrong_yaml_cpp

Now you can build the workspace:

$ cd ~/ros2_ws
$ src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install

This build may fail due to missing dependencies and you need to figure out which package you need to install by yourself (for now).

Read https://github.com/ros2/ros1_bridge/blob/master/README.md#build-the-bridge-from-source regarding Ros 1 / Ros 2 interoperability.

Usage Examples

First source the workspace:

$ . ~/ros2_ws/install/local_setup.bash

Functionality comparable to roscore, rosnode, rostopic, rosmsg, rospack, rosrun and rosservice is available via ros2:

$ ros2 -h
usage: ros2 [-h] Call `ros2 <command> -h` for more detailed usage. ... 

ros2 is an extensible command-line tool for ROS 2.

optional arguments:
  -h, --help            show this help message and exit

Commands:
  daemon    Various daemon related sub-commands
  msg       Various msg related sub-commands
  node      Various node related sub-commands
  pkg       Various package related sub-commands
  run       Run a package specific executable
  security  Various security related sub-commands
  service   Various service related sub-commands
  srv       Various srv related sub-commands
  topic     Various topic related sub-commands

  Call `ros2 <command> -h` for more detailed usage.

A typical "Hello World" example starts with running a publisher node:

$ ros2 topic pub /chatter 'std_msgs/String' "data: 'Hello World'"

Then, in another terminal, you can run a subscriber (Don't forget to source the workspace in every new terminal):

$ ros2 topic echo /chatter

List existing nodes:

$ ros2 node list
publisher_std_msgs_String

List topics:

$ ros2 topic list
/chatter

Ros 2's version of rviz is

$ rviz2