Git Product home page Git Product logo

ros2-workshop's Introduction

ROS2 workshop

This is the repository prepared for NTU MAE robotics club ROS workshop

ROS2 Installation

It is highly recommended to install ROS/ROS2 on Ubuntu 20.04 Instead of Windows.

ROS2 Foxy Installation Instructions (For Windows)

Installing prerequisites

Before you start, make sure your windows C drive has enough disk space (20 - 50 GB at least)! A lot of software and dependencies will be installed

Chocolatey (package manager):

  • Open your windows powershell, and run with administrator
  • Execute the following command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  • If you don't see any errors, you are ready to use Chocolatey! Type choco or choco -? now, or see Getting Started for usage instructions.
  • Reference: https://chocolatey.org/install

Python

  • Open command prompt, and execute:
choco install -y python --version 3.8.3

ROS 2 expects the python installation to be available in directory C:\python38. Double check that it is installed there. If it is not, recommend to unisntall python and reinstall in the desired folder.

Install Visual C++ Redistributables

choco install -y vcredist2013 vcredist140

Install OpenSSL

  • Download the Win64 OpenSSL v1.1.1L OpenSSL installer from: https://slproweb.com/products/Win32OpenSSL.html (Scroll to the bottom of the page and download Win64 OpenSSL v1.1.1L. Don’t download the Win32 or Light versions.)
  • Run the installer with default parameters, as the following commands assume you used the default installation directory.
  • Execute following command in the terminal, sets an environment variable that persists over sessions
setx -m OPENSSL_CONF "C:\Program Files\OpenSSL-Win64\bin\openssl.cfg"
  • append the OpenSSL-Win64 bin folder to your PATH:

clicking the Windows icon, typing “Environment Variables”, then clicking on “Edit the system environment variables”. In the resulting dialog, click “Environment Variables”, then click “Path” on the bottom pane, finally click “Edit” and add the path below: C:\Program Files\OpenSSL-Win64\bin

Install Visual Studio (Around 8 GB)

  • Since it takes a lot of space, maybe you can skip this step. If it causes any problems, then can go back and install it (I haven't test it yet, you can tell me if it works without visual studio)
  • Download visual studio 2019 community version
  • Make sure that the Visual C++ features are installed.
  • Make sure that no C++ CMake tools are installed by unselecting them in the list of components to be installed.
  • select the Desktop development with C++ workflow during the install.

Install OpenCV

Install dependencies

  • cmake:
choco install -y cmake
  • append the CMake bin folder C:\Program Files\CMake\bin to your PATH.

  • Download packages from: https://github.com/ros2/choco-packages/releases/tag/2020-02-24 which are: asio.1.12.1.nupkg

    bullet.2.89.0.nupkg

    cunit.2.1.3.nupkg

    eigen-3.3.4.nupkg

    tinyxml-usestl.2.6.2.nupkg

    tinyxml2.6.0.0.nupkg

    log4cxx.0.10.0.nupkg

Once these packages are downloaded, open an administrative shell and execute the following command:

choco install -y -s <PATH\TO\DOWNLOADS> asio cunit eigen tinyxml-usestl tinyxml2 log4cxx bullet
  • install some python dependencies for command-line tools:
python -m pip install -U catkin_pkg cryptography empy ifcfg lark-parser lxml netifaces numpy opencv-python pyparsing pyyaml setuptools rosdistro

Don't worry if you encountered any problems here.

  • RQt dependencies
python -m pip install -U pydot PyQt5
  • To run rqt_graph, you’ll need Graphviz.
choco install graphviz
  • Install developer tools
pip install -U vcstool

test it by run vcs

  • Install colcon, curl
pip install -U colcon-common-extensions
choco install -y curl

possible error here:

ERROR: resampy 0.2.2 requires scipy>=0.13, which is not installed.
ERROR: pooch 1.5.2 requires requests, which is not installed.
ERROR: librosa 0.8.1 requires decorator>=3.0.0, which is not installed.
ERROR: librosa 0.8.1 requires joblib>=0.14, which is not installed.
ERROR: librosa 0.8.1 requires scikit-learn!=0.19.0,>=0.14.0, which is not installed.
ERROR: librosa 0.8.1 requires scipy>=1.0.0, which is not installed.

Don't worry about it, just proceed to next

  • Install dependencies
python -m pip install -U setuptools pip

pip install -U catkin_pkg cryptography EmPy ifcfg lark-parser lxml numpy pyparsing pyyaml

pip install -U pytest pytest-mock coverage mock

choco install -y cppcheck

pip install -U flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes mypy==0.761 pep8 pydocstyle
set Qt5_DIR=C:\Qt\5.15.0\msvc2019_64

only required if you are building rviz, but it comes with our default set of sources, so if you don’t know, then assume you are building it.

We recommend you install it to the default location of C:\Qt, but if you choose somewhere else, make sure to update the paths below accordingly. When selecting components to install, the only thing you absolutely need for Foxy and later is the appropriate MSVC 64-bit component under the Qt -> Qt 5.15.0 tree. We’re using 5.15.0 as of the writing of this document and that’s what we recommend since that’s all we test on Windows, but later version will probably work too.

Get the ROS2 Source code

  • First setup a development folder, for example C:\dev\ros2_foxy:
md \dev\ros2_foxy\src
cd \dev\ros2_foxy
  • Get the ros2.repos file which defines the repositories to clone from:
# CMD
curl -sk https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos -o ros2.repos

# PowerShell
curl https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos -o ros2.repos

Powershell means you are using powershell. Default is using command line (terminal)

  • use vcs to import the repositories listed in the ros2.repos file:
# CMD
vcs import src < ros2.repos

# PowerShell
vcs import --input ros2.repos src

Build the ROS2 source code on windows

  • Open Visual Studio Command Prompt: search x64 Native Tools Command Prompt for VS 2019, as Administrator
  • To build the \dev\ros2_foxy folder tree:
colcon build --merge-install

Environment setup

Start a command shell and source the ROS 2 setup file to set up the workspace:

call C:\dev\ros2_foxy\install\local_setup.bat

It is normal that the previous command, if nothing else went wrong, outputs “The system cannot find the path specified.” exactly once.

Test and run

Note that the first time you run any executable you will have to allow access to the network through a Windows Firewall popup (this is optional)

colcon test --merge-install

Note: --merge-install should only be used if it was also used in the build step.

Then you can get a summary by:

colcon test-result

Running some examples for testing

To run the examples, first open a clean new cmd.exe and set up the workspace by sourcing the local_setup.bat file. Then, run a C++ talker: (navigate to your workspace first)

call install\local_setup.bat
ros2 run demo_nodes_cpp talker

In a separate shell you can do the same, but instead run a Python listener:

call install\local_setup.bat
ros2 run demo_nodes_py listener

ros2-workshop's People

Contributors

davidlequnchen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.