-
Notifications
You must be signed in to change notification settings - Fork 161
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
add graph functions to support wait_for_service #57
Merged
Merged
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
21e5b45
add graph functions to support wait_for_service
wjwwood 38ccb3f
is_ready -> is_available
wjwwood daec609
add function to create rcl_guard_condition from an existing rmw_guard…
wjwwood 43735bf
create graph guard condition in node automatically
wjwwood be755ed
tests for graph API
wjwwood 6402e13
style fixup
wjwwood e49dc0f
remove debug stuff from test_graph
wjwwood f20a7c8
only enable test_graph for OpenSplice
wjwwood f5fabb4
fixup
wjwwood c50e413
add rcl_node_is_valid function
wjwwood f1de713
add tests for new graph API functions
wjwwood 06a11d6
fixup
wjwwood a25ef33
reorder the destruction of node vs waitset
wjwwood 3c0b917
disable missing-field-intializers warning
wjwwood e2d7cd7
use to_string since type changes with OS
wjwwood 1a36942
use more specific gtest assert to avoid warning
wjwwood 631898e
added a secondary check in the test_graph.test_rcl_service_server_is_…
wjwwood 15b8ce6
uncrustify
wjwwood 77d9666
doc fixup
wjwwood 110aa7a
condition pragma on not _WIN32
wjwwood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
// Copyright 2016 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef RCL__GRAPH_H_ | ||
#define RCL__GRAPH_H_ | ||
|
||
#if __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include <rmw/rmw.h> | ||
#include <rmw/types.h> | ||
|
||
#include "rosidl_generator_c/service_type_support.h" | ||
|
||
#include "rcl/macros.h" | ||
#include "rcl/client.h" | ||
#include "rcl/node.h" | ||
#include "rcl/visibility_control.h" | ||
|
||
typedef rmw_topic_names_and_types_t rcl_topic_names_and_types_t; | ||
|
||
/// Return a list of topic names and their types. | ||
/* This function returns a list of topic names in the ROS graph and their types. | ||
* | ||
* The node parameter must not be NULL, and must point to a valid node. | ||
* | ||
* The topic_names_and_types parameter must not be NULL, and must point to an | ||
* already allocated rcl_topic_names_and_types_t struct. | ||
* The topic_names_and_types is the output for this function, and contains | ||
* allocated memory. | ||
* Therefore, it should be passed to rcl_destroy_topic_names_and_types() when | ||
* it is no longer needed. | ||
* Failing to do so will result in leaked memory. | ||
* | ||
* This function does manipulate heap memory. | ||
* This function is not thread-safe. | ||
* This function is lock-free. | ||
* | ||
* \param[in] node the handle to the node being used to query the ROS graph | ||
* \param[out] topic_names_and_types list of topic names and their types | ||
* \return RCL_RET_OK if the query was successful, or | ||
* RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or | ||
* RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_get_topic_names_and_types( | ||
const rcl_node_t * node, | ||
rcl_topic_names_and_types_t * topic_names_and_types); | ||
|
||
/// Destroy a struct which was previously given to rcl_get_topic_names_and_types. | ||
/* The topic_names_and_types parameter must not be NULL, and must point to an | ||
* already allocated rcl_topic_names_and_types_t struct that was previously | ||
* passed to a successful rcl_get_topic_names_and_types() call. | ||
* | ||
* This function does manipulate heap memory. | ||
* This function is not thread-safe. | ||
* This function is lock-free. | ||
* | ||
* \param[inout] topic_names_and_types struct to be destroyed | ||
* \return RCL_RET_OK if successful, or | ||
* RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or | ||
* RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_destroy_topic_names_and_types( | ||
rcl_topic_names_and_types_t * topic_names_and_types); | ||
|
||
/// Return the number of publishers on a given topic. | ||
/* This function returns the number of publishers on a given topic. | ||
* | ||
* The node parameter must not be NULL, and must point to a valid node. | ||
* | ||
* The topic_name parameter must not be NULL, and must not be an empty string. | ||
* It should also follow the topic name rules. | ||
* \TODO(wjwwood): link to the topic name rules. | ||
* | ||
* The count parameter must not be NULL, and must point to a valid bool. | ||
* The count parameter is the output for this function and will be set. | ||
* | ||
* This function may manipulate heap memory. | ||
* This function is not thread-safe. | ||
* This function is lock-free. | ||
* | ||
* \param[in] node the handle to the node being used to query the ROS graph | ||
* \param[in] topic_name the name of the topic in question | ||
* \param[out] count number of publishers on the given topic | ||
* \return RCL_RET_OK if the query was successful, or | ||
* RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or | ||
* RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_count_publishers( | ||
const rcl_node_t * node, | ||
const char * topic_name, | ||
size_t * count); | ||
|
||
/// Return the number of subscriptions on a given topic. | ||
/* This function returns the number of subscriptions on a given topic. | ||
* | ||
* The node parameter must not be NULL, and must point to a valid node. | ||
* | ||
* The topic_name parameter must not be NULL, and must not be an empty string. | ||
* It should also follow the topic name rules. | ||
* \TODO(wjwwood): link to the topic name rules. | ||
* | ||
* The count parameter must not be NULL, and must point to a valid bool. | ||
* The count parameter is the output for this function and will be set. | ||
* | ||
* This function may manipulate heap memory. | ||
* This function is not thread-safe. | ||
* This function is lock-free. | ||
* | ||
* \param[in] node the handle to the node being used to query the ROS graph | ||
* \param[in] topic_name the name of the topic in question | ||
* \param[out] count number of subscriptions on the given topic | ||
* \return RCL_RET_OK if the query was successful, or | ||
* RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or | ||
* RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_count_subscribers( | ||
const rcl_node_t * node, | ||
const char * topic_name, | ||
size_t * count); | ||
|
||
/// Check if a service server is available for the given service client. | ||
/* This function will return true for is_available if there is a service server | ||
* available for the given client. | ||
* | ||
* The node parameter must not be NULL, and must point to a valid node. | ||
* | ||
* The client parameter must not be NULL, and must point to a valid client. | ||
* | ||
* The given client and node must match, i.e. the client must have been created | ||
* using the given node. | ||
* | ||
* The is_available parameter must not be NULL, and must point a bool variable. | ||
* The result of the check will be stored in the is_available parameter. | ||
* | ||
* This function does manipulate heap memory. | ||
* This function is not thread-safe. | ||
* This function is lock-free. | ||
* | ||
* \param[in] node the handle to the node being used to query the ROS graph | ||
* \param[in] client the handle to the service client being queried | ||
* \param[out] is_available set to true if there is a service server available, else false | ||
* \return RCL_RET_OK if the check was made successfully (regardless of the service readiness), or | ||
* RCL_RET_INVALID_ARGUMENT if any arguments are invalid, or | ||
* RCL_RET_ERROR if an unspecified error occurs. | ||
*/ | ||
RCL_PUBLIC | ||
RCL_WARN_UNUSED | ||
rcl_ret_t | ||
rcl_service_server_is_available( | ||
const rcl_node_t * node, | ||
const rcl_client_t * client, | ||
bool * is_available); | ||
|
||
#if __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // RCL__GRAPH_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2016 Open Source Robotics Foundation, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#if __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#include "rcl/graph.h" | ||
|
||
#include "./common.h" | ||
|
||
rcl_ret_t | ||
rcl_get_topic_names_and_types( | ||
const rcl_node_t * node, | ||
rcl_topic_names_and_types_t * topic_names_and_types) | ||
{ | ||
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(topic_names_and_types, RCL_RET_INVALID_ARGUMENT); | ||
return rmw_get_topic_names_and_types( | ||
rcl_node_get_rmw_handle(node), | ||
topic_names_and_types | ||
); | ||
} | ||
|
||
rcl_ret_t | ||
rcl_destroy_topic_names_and_types( | ||
rcl_topic_names_and_types_t * topic_names_and_types) | ||
{ | ||
RCL_CHECK_ARGUMENT_FOR_NULL(topic_names_and_types, RCL_RET_INVALID_ARGUMENT); | ||
return rmw_destroy_topic_names_and_types(topic_names_and_types); | ||
} | ||
|
||
rcl_ret_t | ||
rcl_count_publishers( | ||
const rcl_node_t * node, | ||
const char * topic_name, | ||
size_t * count) | ||
{ | ||
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(topic_name, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(count, RCL_RET_INVALID_ARGUMENT); | ||
return rmw_count_publishers(rcl_node_get_rmw_handle(node), topic_name, count); | ||
} | ||
|
||
rcl_ret_t | ||
rcl_count_subscribers( | ||
const rcl_node_t * node, | ||
const char * topic_name, | ||
size_t * count) | ||
{ | ||
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(topic_name, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(count, RCL_RET_INVALID_ARGUMENT); | ||
return rmw_count_subscribers(rcl_node_get_rmw_handle(node), topic_name, count); | ||
} | ||
|
||
rcl_ret_t | ||
rcl_service_server_is_available( | ||
const rcl_node_t * node, | ||
const rcl_client_t * client, | ||
bool * is_available) | ||
{ | ||
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(client, RCL_RET_INVALID_ARGUMENT); | ||
RCL_CHECK_ARGUMENT_FOR_NULL(is_available, RCL_RET_INVALID_ARGUMENT); | ||
return rmw_service_server_is_available( | ||
rcl_node_get_rmw_handle(node), | ||
rcl_client_get_rmw_handle(client), | ||
is_available | ||
); | ||
} | ||
|
||
#if __cplusplus | ||
} | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anytime change -> anytime a change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks: 77d9666