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

Skeleton parameters async API #26

Merged
merged 1 commit into from
Apr 30, 2015
Merged

Skeleton parameters async API #26

merged 1 commit into from
Apr 30, 2015

Conversation

esteve
Copy link
Member

@esteve esteve commented Apr 28, 2015

@esteve esteve added the in progress Actively being worked on (Kanban column) label Apr 28, 2015
@@ -19,6 +19,7 @@
#include <memory>

#include <rclcpp/node.hpp>
#include <rclcpp/parameter.hpp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file missing from the PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed, sorry!

@tfoote
Copy link
Contributor

tfoote commented Apr 29, 2015

+1

@@ -0,0 +1,225 @@
// Copyright 2014 Open Source Robotics Foundation, Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Year should be 2015.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dirk-thomas
Copy link
Member

Beside the minor comments the API looks good to me.

@esteve
Copy link
Member Author

esteve commented Apr 29, 2015

@dirk-thomas thanks for the feedback!

get_parameters(
std::vector<std::string> names,
std::function<void(
std::shared_future<std::vector<ParameterVariant>>)> callback = nullptr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature left me with some questions, which might just be solved with documentation:

  • Why does the callback receive the future and not just the value?
    • I guess because the future could result in an exception?
  • Is the expectation that the call to future.get() in the user's callback will either raise or return the value without blocking (is the future always ready when the callback is called)?
    • Put another way, can the call to future.get() block in the user's callback?
  • What happens if the user doesn't call .get() on the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the callback receive the future and not just the value?
I guess because the future could result in an exception?

That is correct, get() will either raise a std::future_error exception or return the value.

http://en.cppreference.com/w/cpp/thread/future/get
http://en.cppreference.com/w/cpp/thread/future_error

Is the expectation that the call to future.get() in the user's callback will either raise or return the > value without blocking (is the future always ready when the callback is called)?
Put another way, can the call to future.get() block in the user's callback?

When the callback is fired, the std::future is already ready. In the previous version of the parameters API or in the current code for services (https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/client.hpp#L121), the value for the related std::promise is set before firing the callback.

What happens if the user doesn't call .get() on the future?

The callback function will be fired, but the user won't have access to the result of the operation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That all sounds find to me. Thanks.

The callback function will be fired, but the user won't have access to the result of the operation.

Ok, I was more wondering if the future's (or the value in the future's) lifecycle was dependent on .get() being called, but I guess it doesn't.

I was also just now wondering if an exception could be silently suppressed if the user never calls .get() and if we could do anything about it.

Is there anyway for the code to know if the future was "gotten"? If there is, then you could imagine that the code does something like:

user_callback(future);
if (future.not_gotten() && future.has_exception()) {
  try {
    future.get();
  catch (std::execption & exc) {
    log_error_stream("Unhandled exception in future: " << exc);
  }
}

Another thought is that boost::asio returns the value and the exception as parameters to the callback. It's not clear to me that this a better way to structure the callback signature, but it's worth thinking about as we work on this API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anyway for the code to know if the future was "gotten"? If there is, then you could imagine that the code does something like:

I don't think there is, but I could be wrong.

Another thought is that boost::asio returns the value and the exception as parameters to the callback. It's not clear to me that this a better way to structure the callback signature, but it's worth thinking about as we work on this API.

I think that'd be a good idea.

@wjwwood
Copy link
Member

wjwwood commented Apr 29, 2015

Other than my questions about the callback taking a future, lgtm. Thanks!

@esteve esteve force-pushed the parameters-api-review branch from dc525c6 to 513e283 Compare April 30, 2015 22:19
@wjwwood
Copy link
Member

wjwwood commented Apr 30, 2015

All of my comments which I think should result in a change before merge have been addressed, +1.

@dirk-thomas
Copy link
Member

Please squash before merging.

@esteve esteve force-pushed the parameters-api-review branch from 513e283 to e657a8f Compare April 30, 2015 23:07
esteve added a commit that referenced this pull request Apr 30, 2015
@esteve esteve merged commit f4bcd83 into master Apr 30, 2015
@esteve esteve removed the in progress Actively being worked on (Kanban column) label Apr 30, 2015
@esteve esteve deleted the parameters-api-review branch April 30, 2015 23:08
alsora pushed a commit to alsora/rclcpp that referenced this pull request Oct 21, 2020
nnmm pushed a commit to ApexAI/rclcpp that referenced this pull request Jul 9, 2022
fix style of header include guard
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
* ros2GH-52 Extend db schema to include topic meta data

- Two table db layout (messages and topics)
- Messages table references topics table but without foreign key for
  improved write performance
- Create_topic must be called for every topic prior to storing a
  message of this topic.
- Sqlite_storage caches all known topics
- At least for now the type information is stored as a simple string.

* ros2GH-54 Make first rcl subscription prototype work

* ros2GH-54 find type name from topic

* ros2GH-54 Publish messages from database knowing only topic name and pass topic name by terminal

* ros2GH-54 Refactoring of typesupport helpers

* ros2GH-54 Use c++ typesupport

* ros2GH-54 Use cpp typesupport and rclcpp::Node for publisher

* ros2GH-54 Add raw subscription and use in rosbag_record

* ros2GH-54 Add Rosbag2Node and Rosbag2Publisher classes and use them in Rosbag2::play

* ros2GH-54 Rename Rosbag2Publisher to RawPublisher

* ros2GH-54 Minor refactoring of Rosbag2Node

* ros2GH-54 Extract and test waiting for topic into its own method

* ros2GH-54 Fix read integration tests and linters

* ros2GH-55 Refactor Rosbag2Node::create_raw_publisher()

* ros2GH-54 Add subscription method to rosbag node

* ros2GH-54 Keep subscription alive

* ros2GH-54: Extract subscription to correct class

* ros2GH-55 Change interface of raw_publisher to match subscriber

* ros2GH-54 Add test for rosbag node

* ros2GH-54 Unfriend rclcpp class

* ros2GH-54 Make test more robust

* ros2GH-54 Fix build

* ros2GH-54 Minor cleanup and documentation

* ros2GH-55 Minor refactoring + TODO comment

* ros2GH-54 Change dynamic library folder on Windows

* ros2GH-54 Fix build

* ros2GH-54 Add shutdown to test

* ros2GH-55 Add test helpers methods for usage in multiple tests

* ros2GH-55 Add new method to read all topics and types in BaseReadInterface and use it in Rosbag2::play

* ros2GH-55 Fix gcc and msvc

* ros2GH-54 Rename raw to generic in publisher/subscriber

* ros2GH-55 Check that topic and associated type in bag file are well defined before playing back messages

* ros2GH-54 Prevent unnecessary error message loading storage

* ros2GH-54 Fix memory leak

* ros2GH-54 stabilize node test

* ros2GH-55 Check if database exists when opening storage with READ_ONLY flag

* ros2GH-54 Minor cleanup of subscriber

* ros2GH-54 Wait a small amount of time to let node discover other nodes

* Add logging to false case

* ros2GH-54 Catch exceptions and exit cleanly

* Use rmw_serialized_message_t and rcutils_char_array_t consistently

* ros2GH-4 Refactoring for correctness

- pass a few strings as const reference
- throw error when no topics could be found

* Improve error messages when loading plugins

* alphabetical order

* type_id -> type
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this pull request Aug 5, 2022
* ros2GH-61 Read topic directly from message when playing and allow to play multiple topics

* ros2GH-61 Add test for SqliteStorage and update old ones

* ros2GH-62 Extend function to poll for any number of specified topics

* ros2GH-62 Allow subscription to several topics

* ros2GH-61 Obtain the topic name directly from the database

- Uses a JOIN instead of mapping the topic_id to the name in code

* ros2GH-61 Cache read row in result iterator

This allows repeated dereferencing on same row without quering the
database again.

* ros2GH-62 Change demo-record to allow specifying multiple topics

* ros2GH-62 Add test to write non-string topic + refactoring

* ros2GH-62 Add test for subscription to multiple topics

* ros2GH-62 Cleanup

* ros2GH-62 Simplify test setup

* ros2GH-61 Cleanup

* ros2GH-61 consolidate storage integration test

* ros2GH-62 Consolidate write integration tests

* ros2GH-61 enhance read integration test to check multiple topics

* ros2GH-62 Improve rosbag integration test

* ros2GH-62: Polish rosbag2_rosbag_node_test

* ros2GH-62 Fix cpplint

* ros2GH-62 Fix memory leak in rosbag helper

* ros2GH-62 Cleanup of subscriptions

* ros2GH-62 do not use flaky timers in rosbag2_write_integration_test

* ros2GH-62 Use rmw_serialize_message_t consistently in test helper classes

* ros2GH-73 Use test_msgs in read_integration_test

* ros2GH-26 Cleanup: fix alphabetic orderung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants