Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added README.md for image_tools #571

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1fa27c8
:heavy_plus_sign: :book: Added README.md for image_tools ROS2 package…
cardboardcode Jul 26, 2022
3cb7f35
Change dependency from 'rosidl_cmake' to 'rosidl_default_generators' …
jacobperron Aug 8, 2022
8b6dd97
Exit with code 0 if ExternalShutdownException is raised (#581)
jacobperron Aug 8, 2022
0381b27
Added README.md for dummy_map_server (#572)
cardboardcode Aug 18, 2022
46274b6
Remove action_msgs dependency (#580)
jacobperron Aug 23, 2022
a693c57
Add demo for rclpy parameter client (#566)
ihasdapie Aug 29, 2022
d91c0d4
Changelog.
clalancette Sep 13, 2022
97d20b1
0.22.0
clalancette Sep 13, 2022
3185617
fix memory leak (#585)
Sep 27, 2022
b873be2
Install the launch file for lifecycle_py. (#586)
clalancette Sep 27, 2022
fd65651
Demo for pre and post set parameter callback support (#565)
deepanshubansal01 Oct 13, 2022
15b84ab
Changelog.
clalancette Nov 2, 2022
5d86c8a
0.23.0
clalancette Nov 2, 2022
f93181d
Make demo_nodes_cpp_native install stuff only when it builds (#590)
sloretz Nov 11, 2022
9d2d84c
[rolling] Update maintainers - 2022-11-07 (#589)
audrow Nov 15, 2022
7bb5f6e
Add README's for action_tutorials. (#576)
kagibson Dec 7, 2022
c908b8f
Update the demos to C++17. (#594)
clalancette Jan 5, 2023
42143ad
:hammer: Adhered instructional details in image_tools README.md to pr…
cardboardcode Jan 23, 2023
095f6b6
:hammer: Updated based on feedback to correct phrasing.
cardboardcode Jan 23, 2023
b8232d5
:hammer: Updated based on feedback to change phrasing.
cardboardcode Jan 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file was generated by https://github.com/audrow/update-ros2-repos
* @adityapande-1995 @audrow @mjeronimo
21 changes: 21 additions & 0 deletions action_tutorials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ROS2 Action Tutorials

This tutorial demonstrates implementing ROS action servers and action clients.

The action server in this case takes in an integer value between 0 and 45 named *order* and returns the Fibonacci sequence, a sequence with the form:
$$F_0 = 0$$
$$F_1 = 1$$
$$F_{order}=F_{order-1} + F_{order-2}$$

The action server calculates each number in the sequence one at a time and returns a partial sequence as feedback at each iteration.
If the action is cancelled before the entire sequence is calculated, the server stops calculating the sequence and no result is returned.
The action client in this tutorial sends a goal to the action server with an order of 10.
It logs each partial sequence returned as feedback.
Once the action is finished executing, the action client logs the resulting sequence.

## Packages

- [action_tutorials_cpp](./action_tutorials_cpp) implements the described action server and client using the rclcpp library in C++.
- [action_tutorials_py](./action_tutorials_py) implements the described action server and client using the rclpy library in Python.
- [action_tutorials_interfaces](./action_tutorials_interfaces) defines the interface for the Fibonacci action.
This interface takes an *order* as a goal, returns a *partial sequence* as feedback and a *sequence* as a result.
8 changes: 8 additions & 0 deletions action_tutorials/action_tutorials_cpp/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog for package action_tutorials_cpp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.23.0 (2022-11-02)
-------------------

0.22.0 (2022-09-13)
-------------------
* Fix two small bugs in the fibonacci C++ tutorial. (`#564 <https://github.com/ros2/demos/issues/564>`_)
* Contributors: Chris Lalancette

0.21.0 (2022-04-29)
-------------------

Expand Down
5 changes: 3 additions & 2 deletions action_tutorials/action_tutorials_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
67 changes: 67 additions & 0 deletions action_tutorials/action_tutorials_cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Action Server

In the constructor for `FibonacciActionServer`, an action server is created with callbacks that are called when a goal is received, when the goal is cancelled, and when the goal is accepted:

```cpp
this->action_server_ = rclcpp_action::create_server<Fibonacci>(
...
"fibonacci",
std::bind(&FibonacciActionServer::handle_goal, this, _1, _2),
std::bind(&FibonacciActionServer::handle_cancel, this, _1),
std::bind(&FibonacciActionServer::handle_accepted, this, _1));
```

The `handle_goal` callback is called whenever a goal is sent to the action server by an action client.
In the example code, the goal is accepted as long as the order is less than or equal to 46, otherwise it is rejected.
This is to prevent potential [integer overflow](https://en.wikipedia.org/wiki/Integer_overflow):
```cpp
if (goal->order > 46) {
return rclcpp_action::GoalResponse::REJECT;
}
return rclcpp_action::GoalResponse::ACCEPT_AND_EXECUTE;
```

The `handle_cancelled` callback is called whenever an action client requests to cancel the goal being executed.
In this case, the goal cancel request is always accepted.

The `handle_accepted` callback is called following the action server's acceptance of a goal. In this example, a thread is started to execute the goal:
```cpp
std::thread{std::bind(&FibonacciActionServer::execute, this, _1), goal_handle}.detach();
```

The execution thread calculates the Fibonacci sequence up to *order* and publishes partial sequences as feedback as each item is added to the sequence.

A `rclcpp::Rate` object is used to sleep between the calculation of each item in order to represent a long-running task.

When execution is complete, the full sequence is returned to the action client.
If the goal is cancelled during execution, no result is returned, however the caller may have received partial sequences as feedback up until cancelling.

# Action Client

In the constructor for `FibonacciActionClient`, and action client for the `fibonacci` action is created:

```cpp
this->client_ptr_ = rclcpp_action::create_client<Fibonacci>(
...
"fibonacci");
```

A goal of type `Fibonacci` is created with order 10.
The goal is sent asynchronously with callbacks registered for the goal response, the feedback, and the goal result:

```cpp
auto send_goal_options = rclcpp_action::Client<Fibonacci>::SendGoalOptions();
send_goal_options.goal_response_callback =
std::bind(&FibonacciActionClient::goal_response_callback, this, _1);
send_goal_options.feedback_callback =
std::bind(&FibonacciActionClient::feedback_callback, this, _1, _2);
send_goal_options.result_callback =
std::bind(&FibonacciActionClient::result_callback, this, _1);
this->client_ptr_->async_send_goal(goal_msg, send_goal_options);
```

There are three types of callback functions:

- The `goal_response_callback` is called when the action server accepts or rejects the goal.
- The `feedback_callback` is called whenever the action server sends goal execution feedback.
- The `goal_result_callback` is called when the action server is finished executing the goal and returns the result of the goal which is the full or partial Fibonacci sequence.
3 changes: 2 additions & 1 deletion action_tutorials/action_tutorials_cpp/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>action_tutorials_cpp</name>
<version>0.21.0</version>
<version>0.23.0</version>
<description>C++ action tutorial cpp code</description>

<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
<maintainer email="audrow@openrobotics.org">Audrow Nash</maintainer>
<maintainer email="michael.jeronimo@openrobotics.org">Michael Jeronimo</maintainer>

Expand Down
8 changes: 8 additions & 0 deletions action_tutorials/action_tutorials_interfaces/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog for package action_tutorials_interfaces
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.23.0 (2022-11-02)
-------------------

0.22.0 (2022-09-13)
-------------------
* Remove action_msgs dependency (`#580 <https://github.com/ros2/demos/issues/580>`_)
* Contributors: Jacob Perron

0.21.0 (2022-04-29)
-------------------

Expand Down
10 changes: 10 additions & 0 deletions action_tutorials/action_tutorials_interfaces/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Action Tutorials ROS2 Interface

This tutorial defines the Fibonacci action for use with the action tutorials.
There are three parts of the action:

- The goal contains an *order* field which determines the length of the returned Fibonacci sequence.
For example, order 2 should return sequence [0, 1] and order 5 should return sequence [0, 1, 1, 2, 3].
- The feedback consists of a partial sequence that is returned as the Fibonacci sequence is calculated.
For example, for order 5 at some point the partial sequence [0, 1, 1] will be returned.
- The result consists of the complete Fibonacci sequence (ex. [0, 1, 1, 2, ..., 165580141]).
5 changes: 2 additions & 3 deletions action_tutorials/action_tutorials_interfaces/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>action_tutorials_interfaces</name>
<version>0.21.0</version>
<version>0.23.0</version>
<description>Action tutorials action</description>

<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
<maintainer email="audrow@openrobotics.org">Audrow Nash</maintainer>
<maintainer email="michael.jeronimo@openrobotics.org">Michael Jeronimo</maintainer>

Expand All @@ -16,8 +17,6 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>

<depend>action_msgs</depend>

<exec_depend>rosidl_default_runtime</exec_depend>

<test_depend>ament_lint_auto</test_depend>
Expand Down
6 changes: 6 additions & 0 deletions action_tutorials/action_tutorials_py/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog for package action_tutorials_py
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.23.0 (2022-11-02)
-------------------

0.22.0 (2022-09-13)
-------------------

0.21.0 (2022-04-29)
-------------------

Expand Down
51 changes: 51 additions & 0 deletions action_tutorials/action_tutorials_py/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Action Server

In the constructor for `FibonacciActionServer`, an action server is created with a callback that is called when a goal is accepted.
```python
self._action_server = ActionServer(
self,
Fibonacci,
'fibonacci',
self.execute_callback)
```

There are three types of callbacks:

- A `goal_callback` can optionally be added to conditionally accept or reject the goal, however, by default the goal is accepted.
- A `cancel_callback` can also optionally be added to conditionally accept or reject the cancel goal request, however, by default the cancel goal request is accepted.
- The `execute_callback` calculates the Fibonacci sequence up to *order* and publishes partial sequences as feedback as each item is added to the sequence.

The thread sleeps for 1 second between the calculation of each item in order to represent a long-running task.
When execution is complete, the full sequence is returned to the action client.

# Action Client

In the constructor for `FibonacciActionClient`, an action client for the `fibonacci` action is created:

```python
self._action_client = ActionClient(self, Fibonacci, 'fibonacci')
```

A goal of type `Fibonacci` is created with order 10.
The goal is sent asynchronously with callbacks registered for the goal response and the feedback:

```python
self._send_goal_future = self._action_client.send_goal_async(
goal_msg,
feedback_callback=self.feedback_callback)

self._send_goal_future.add_done_callback(self.goal_response_callback)
```

Within the `goal_response_callback`, if the goal is accepted, the goal result is requested asynchronously.
A callback is registered for receiving the result:
```python
self._get_result_future = goal_handle.get_result_async()

self._get_result_future.add_done_callback(self.get_result_callback)
```

There are two types of callbacks:

- The `feedback_callback` logs the partial sequences as they are received.
- The `get_result_callback` logs the full Fibonacci sequence.
3 changes: 2 additions & 1 deletion action_tutorials/action_tutorials_py/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>action_tutorials_py</name>
<version>0.21.0</version>
<version>0.23.0</version>
<description>Python action tutorial code</description>

<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
<maintainer email="audrow@openrobotics.org">Audrow Nash</maintainer>
<maintainer email="michael.jeronimo@openrobotics.org">Michael Jeronimo</maintainer>

Expand Down
6 changes: 3 additions & 3 deletions action_tutorials/action_tutorials_py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name=package_name,
version='0.21.0',
version='0.23.0',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
Expand All @@ -15,8 +15,8 @@
zip_safe=True,
author='Jacob Perron',
author_email='jacob@openrobotics.org',
maintainer='Audrow Nash, Michael Jeronimo',
maintainer_email='audrow@openrobotics.org, michael.jeronimo@openrobotics.org',
maintainer='Aditya Pande, Audrow Nash, Michael Jeronimo',
maintainer_email='aditya.pande@openrobotics.org, audrow@openrobotics.org, michael.jeronimo@openrobotics.org', # noqa: E501
keywords=['ROS'],
classifiers=[
'Intended Audience :: Developers',
Expand Down
8 changes: 8 additions & 0 deletions composition/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
Changelog for package composition
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.23.0 (2022-11-02)
-------------------
* fix memory leak (`#585 <https://github.com/ros2/demos/issues/585>`_)
* Contributors: Chen Lihui

0.22.0 (2022-09-13)
-------------------

0.21.0 (2022-04-29)
-------------------

Expand Down
5 changes: 3 additions & 2 deletions composition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ cmake_minimum_required(VERSION 3.5)

project(composition)

# Default to C++14
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
3 changes: 2 additions & 1 deletion composition/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>composition</name>
<version>0.21.0</version>
<version>0.23.0</version>
<description>Examples for composing multiple nodes in a single process.</description>

<maintainer email="aditya.pande@openrobotics.org">Aditya Pande</maintainer>
<maintainer email="audrow@openrobotics.org">Audrow Nash</maintainer>
<maintainer email="michael.jeronimo@openrobotics.org">Michael Jeronimo</maintainer>

Expand Down
7 changes: 4 additions & 3 deletions composition/src/dlopen_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "class_loader/class_loader.hpp"
Expand All @@ -35,7 +36,7 @@ int main(int argc, char * argv[])
rclcpp::Logger logger = rclcpp::get_logger(DLOPEN_COMPOSITION_LOGGER_NAME);
rclcpp::executors::SingleThreadedExecutor exec;
rclcpp::NodeOptions options;
std::vector<class_loader::ClassLoader *> loaders;
std::vector<std::unique_ptr<class_loader::ClassLoader>> loaders;
std::vector<rclcpp_components::NodeInstanceWrapper> node_wrappers;

std::vector<std::string> libraries;
Expand All @@ -44,7 +45,7 @@ int main(int argc, char * argv[])
}
for (auto library : libraries) {
RCLCPP_INFO(logger, "Load library %s", library.c_str());
auto loader = new class_loader::ClassLoader(library);
auto loader = std::make_unique<class_loader::ClassLoader>(library);
auto classes = loader->getAvailableClasses<rclcpp_components::NodeFactory>();
for (auto clazz : classes) {
RCLCPP_INFO(logger, "Instantiate class %s", clazz.c_str());
Expand All @@ -54,7 +55,7 @@ int main(int argc, char * argv[])
node_wrappers.push_back(wrapper);
exec.add_node(node);
}
loaders.push_back(loader);
loaders.push_back(std::move(loader));
}

exec.spin();
Expand Down
12 changes: 12 additions & 0 deletions demo_nodes_cpp/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Changelog for package demo_nodes_cpp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.23.0 (2022-11-02)
-------------------
* Demo for pre and post set parameter callback support (`#565 <https://github.com/ros2/demos/issues/565>`_)
* local parameter callback support
* Contributors: Deepanshu Bansal

0.22.0 (2022-09-13)
-------------------
* counter starts from 1, not 2. (`#562 <https://github.com/ros2/demos/issues/562>`_)
* add a demo of content filter listener (`#557 <https://github.com/ros2/demos/issues/557>`_)
* Contributors: Chen Lihui, Tomoya Fujita

0.21.0 (2022-04-29)
-------------------

Expand Down
Loading