Giter Club home page Giter Club logo

ros2-code-examples's Introduction

ros2-code-examples

The following tutorials and examples are updated for ROS 2 Dashing Diademata (Released in May 2019).

This repository also contains some Dockerfile for running different ROS2-based environments. You can find them here.

Requirements

Note: you can still use ROS2 Bouncy Bolson, but you will not be able to compile the simple_actions package or to reproduce the examples of simple_navigation, simple_bag, simple_gazebo and simple_rqt.

Building the examples

Source your ROS2 SDK, then create a workspace, add this repository to its sources and build the packages.

$ source <PATH_TO_ROS2_SDK_WS>/install/setup.sh
$ mkdir -p ws/src
$ cd ws/src
$ git clone https://github.com/alsora/ros2-code-examples
$ cd ..
$ colcon build
$ source install/local_setup.sh

For more detailed build instructions look here

Running the examples

For each of the following tests, run the each command in a separate terminal window (remember that the ROS2 SDK has to be sourced in every terminal window!)

Publisher/Subscriber

    $ ros2 run simple_publisher publisher_main
    $ ros2 run simple_subscriber subscriber_main

One process publishes messages and the other subscribes to that topic.

Service/Client

    $ ros2 run simple_service service_main
    $ ros2 run simple_client client_main

One process provides a service and the other requests it.

Running simple_client/timer_main contains an alternative implementation for the ROS2 client node.

Actions Service/Client

    $ ros2 run simple_action service_main
    $ ros2 run simple_action client_main

One process provides an action service and the other requests it. The server node can reject the goal according to the request parameters. The client node can cancel the action if it's taking too much time.

Logger utils

    $ ros2 run simple_logger logger_main

Log some messages and change the verbosity level at runtime.

Multithread systems

    $ ros2 run simple_multithread multithread_main

Run multiple nodes in separate threads from the same process.

Time Synchronization message filters

NOTE This example requires

    $ ros2 run simple_time_sync publisher
    $ ros2 run simple_time_sync time_sync_main

One process publishes messages on multiple topics. Sometimes it publishes only on one topic, sometimes on all with the same timestamp and sometimes on all but with slightly different timestamps. The other process create an approximate and an exact time subscribers.

Parameter servers

    $ ros2 run simple_parameter parameter_server_main
    $ ros2 run simple_parameter parameter_client_main

One process sets its own parameters. The other reads them.

ROS2 Navigation stack

README

Autonomously move a mobile robot in the environment, using a real system or a simulation.

rosbag2

README

Record messages from topic to a file and playback them whenever you want.

rqt2

README

GUI for inspection and interaction of a ROS2 graph.

gazebo

README

ROS2 integration of the 3D simulation and visualization tool Gazebo.

Backward compatibility

README

Allow nodes compiled against different versions of a message interface to communicate.

Secure ROS2

README

Enable security options for your ROS2 system: nodes authentication, messages encryption and access control.

ROS2 CLI (command line interface)

Note that these commands comes from a Python package. So if you have disabled Python support (i.e. when cross-compiling) they will not be available.

  • See a list of available commands

     $ ros2 --help
    
  • Print a list of <package_name> <executable_name>

     $ ros2 pkg executabels
    
  • Run a ROS2 node

     $ ros2 run <package_name> <executable_name>
    
  • List running ROS2 nodes

     $ ros2 node list
    
  • List visible topic names (a topic is visible if at least 1 node is publishing or subscribing to it)

     $ ros2 topic list
    
  • Echo what's published on a topic

     $ ros2 topic echo <topic_name>
    
  • Publish a message to a topic (message_content written as valid YAML)

     $ ros2 topic pub <topic_name> <message_type> <message_content>
    
  • Make a service request (request_content written as valid YAML)

     $ ros2 service call <service_name> <request_message_type> <request_content>
    

ros2-code-examples's People

Contributors

alsora 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.