Skip to main content
Jump to: navigation, search

Difference between revisions of "Papyrus/customizations/robotics/ros2examples"

(Created page with "= Test Models = Papyrus for Robotics contains two test models, a publish-subscribe example and a client/server example == Code generation == In the Papyrus model explorer o...")
(No difference)

Revision as of 15:02, 24 March 2020

Test Models

Papyrus for Robotics contains two test models, a publish-subscribe example and a client/server example

Code generation

In the Papyrus model explorer of the publishSubscribe project, select the PeriodicPublisher component, right click on it and select the Robotics->Generate ROS2 code submenu. Select OK to make the reference library model files writable. The first time, you will be ask twice (for publishSubscribe and simple) the C++ Project type you want to generate. Select the Empty project with the appropriate toolchain (e.g. MinGW GCC). The ROS2 code is generated in your Papyrus project location (src-gen subfolder). You may do the same operations for the clientserver project.

Compilation in a linux-based environment with ROS2 environment

There are two options to compile the generated code. One option is to launch the build from Eclipse, i.e. select a project and invoke build via the top-level or context menu.

An alternative is to open a shell and change into the workspace directory. Launch the colcon command 'colcon build' with the option "up-to" to build only some packages and/or to pass the --symlink-install

option.

Execution of publisher/subscriber in a linux-based environment with ROS2 environment

In a terminal, in the examples directory, run 'source install/setup.sh' Launch 'ros2 launch publishsubscribe launch.subscriber.py' in this terminal In another terminal, in the examples directory, run 'source install/setup.sh' Launch 'ros2 launch publishsubscribe launch.publisher.py' in this terminal Each result is logged in your ~/.ros/log/filenames_given_as_output_of_the_scripts/launch.log files The list of node names is given by the 'ros2 node list' command (e.g. /publisher). THe information on a nodename node can be displayed with the 'ros2 node info nodename' command. In a third terminal, configure and activate the publisher and subscriber nodes. For this:

  • execute the 'ros2 lifecycle set subscriber configure' command
  • execute the 'ros2 lifecycle set subscriber activate' command (the node is now executed)
  • execute the 'ros2 lifecycle set publisher configure' command
  • execute the 'ros2 lifecycle set publisher activate' command (the node is now executed)

The node can be shutdown via the command 'ros2 lifecycle set subscriber shutdown'. The associated process can be stopped via the CTRL+C key in the given terminal.

Execution of client/server in a linux-based environment with ROS2 environment

Launch 'ros2 launch clientserver launch.client.py' in the first terminal Launch 'ros2 launch clientserver launch.server.py' in the other terminal

Each result is logged in your ~/.ros/log/filenames_given_as_output_of_the_scripts/launch.log files In the third terminal, configure and activate the client and server nodes. For this:

  • execute the 'ros2 lifecycle set server configure' command
  • execute the 'ros2 lifecycle set server activate' command (the node is now able to be executed)
  • execute the 'ros2 lifecycle set client configure' command
  • execute the 'ros2 lifecycle set client activate' command (the node is now executed)

The node can be shutdown via the command 'ros2 lifecycle set subscriber shutdown'. The associated process can be stopped via the CTRL+C key in the given terminal.

Back to the top