From 251a5df6bdc8d8d13ec163ab8d7a4439a01626d1 Mon Sep 17 00:00:00 2001 From: William Woodall Date: Fri, 20 Feb 2015 16:09:02 -0800 Subject: [PATCH] initial commit of rcl interface --- LICENSE | 2 +- rcl/CMakeLists.txt | 16 +++++ rcl/include/rcl/rcl.h | 145 ++++++++++++++++++++++++++++++++++++++++ rcl/include/rcl/types.h | 59 ++++++++++++++++ rcl/package.xml | 17 +++++ 5 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 rcl/CMakeLists.txt create mode 100644 rcl/include/rcl/rcl.h create mode 100644 rcl/include/rcl/types.h create mode 100644 rcl/package.xml diff --git a/LICENSE b/LICENSE index e06d208..0289b8d 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ Apache License same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright 2014 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. diff --git a/rcl/CMakeLists.txt b/rcl/CMakeLists.txt new file mode 100644 index 0000000..3cf5fa5 --- /dev/null +++ b/rcl/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.8.3) + +project(rcl) + +find_package(ament_cmake REQUIRED) + +ament_export_dependencies(ros_middleware_interface) + +ament_export_include_directories(include) + +ament_package() + +install( + DIRECTORY include/ + DESTINATION include +) diff --git a/rcl/include/rcl/rcl.h b/rcl/include/rcl/rcl.h new file mode 100644 index 0000000..28a7f3c --- /dev/null +++ b/rcl/include/rcl/rcl.h @@ -0,0 +1,145 @@ +/* Copyright 2014 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_RCL_RCL_H_ +#define RCL_RCL_RCL_H_ + +#include // For bool +#include // For size_t + +// For rosidl_message_type_support_t +#include + +#include "types.h" // For rcl_*_t types + +/// Global initialization for rcl; should be called once per process. +rcl_ret_t +rcl_init(int argc, char **argv); + +/// Creates a rcl_node_t; used to implement a ROS Node. +rcl_node_t * +rcl_create_node(const char * name); + +/// Destroys a rcl_node_t. +rcl_ret_t +rcl_destroy_node(rcl_node_t * node); + +/// Creates a rcl_publisher_t; used to implement a ROS Publisher. +rcl_publisher_t * +rcl_create_publisher(const rcl_node_t * node, + const rosidl_message_type_support_t * type_support, + const char * topic_name, + size_t queue_size); + +/// Destroys a rcl_publisher_t. +rcl_ret_t +rcl_destroy_publisher(rcl_publisher_t * publisher); + +/// Publishes a ROS message to a ROS Topic using a rcl_publisher_t. +rcl_ret_t +rcl_publish(const rcl_publisher_t * publisher, const void * ros_message); + +/// Creates a rcl_subscription_t; used to implement a ROS Subscription. +rcl_subscription_t * +rcl_create_subscription(const rcl_node_t * node, + const rosidl_message_type_support_t * type_support, + const char * topic_name, + size_t queue_size); + +/// Destroys a rcl_subscription_t. +rcl_ret_t +rcl_destroy_subscription(rcl_subscription_t * subscription); + +/// Takes a ROS message from a given rcl_subscription_t if one is available. +rcl_ret_t +rcl_take(const rcl_subscription_t * subscriber, void * ros_message); + +/// Creates a rcl_guard_condition_t; is used by the implementation to +/// asynchronously interrupt rmw_wait. +rcl_guard_condition_t * +rcl_create_guard_condition(); + +/// Destroys a rcl_guard_condition_t. +rcl_ret_t +rcl_destroy_guard_condition(rcl_guard_condition_t * guard_condition); + +/// Triggers the condition, which will interrupt rmw_wait asynchronously. +rcl_ret_t +rcl_trigger_guard_condition(const rcl_guard_condition_t * guard_condition); + +/// Creates a rcl_callback_group_t, which provides hints about how to execute +/// groups of callbacks to an executor. +rcl_callback_group_t * +rcl_create_callback_group(rcl_node_t * node); + +/// Destroys a rcl_callback_group_t. +rcl_ret_t +rcl_destroy_callback_group(rcl_callback_group_t * callback_group); + +/// Creates a rcl_subscription_info_t, which associates rcl_subscription_t's +/// to a callback group. +rcl_subscription_info_t * +rcl_create_subscription_info(rcl_subscription_t * const subscription, + rcl_callback_group_t * const callback_group); + +/// Destroys a rcl_subscription_info_t. +rcl_ret_t +rcl_destroy_subscription_info(rcl_subscription_info_t * subscription_info); + +/// Creates a rcl_timer_info_t, which associates a ROS Timer's guard condition +/// with a callback group. +rcl_timer_info_t * +rcl_create_timer_info(rcl_guard_condition_t * const guard_condition, + rcl_callback_group_t * const callback_group); + +/// Destroys a rcl_timer_info_t. +rcl_ret_t +rcl_destroy_timer_info(rcl_timer_info_t * timer_info); + +/// Creates a rcl_executor_helper_t, which is a collection of callable items. +rcl_executor_helper_t * +rcl_create_executor_helper(); + +/// Destroys a rcl_executor_helper_t. +rcl_ret_t +rcl_destroy_executor_helper(rcl_executor_helper_t * executor_helper); + +/// Add a rcl_subscription_info_t to the collection of callable items. +rcl_ret_t +rcl_add_subscription_info(rcl_executor_helper_t * executor_helper, + rcl_subscription_info_t * subscription_info); + +/// Removes a rcl_subscription_t from the collection of callable items. +rcl_ret_t +rcl_remove_subscription_info(rcl_executor_helper_t * executor_helper, + rcl_subscription_info_t * subscription_info); + +/// Add a rcl_timer_info_t to the collection of callable items. +rcl_ret_t +rcl_add_timer_info(rcl_executor_helper_t * executor_helper, + rcl_timer_info_t * timer_info); + +/// Removes a rcl_subscription_t from the collection of callable items. +rcl_ret_t +rcl_remove_timer_info(rcl_executor_helper_t * executor_helper, + rcl_timer_info_t * timer_info); + +/// Finds the next ready to be called item if one exists; optionally blocking. +rcl_ret_t +rcl_get_next_any_executable(rcl_executor_helper_t * executor_helper, + rcl_any_executable_t * any_executable, + bool non_blocking); + +#endif /* RCL_RCL_RCL_H_ */ diff --git a/rcl/include/rcl/types.h b/rcl/include/rcl/types.h new file mode 100644 index 0000000..c1144d7 --- /dev/null +++ b/rcl/include/rcl/types.h @@ -0,0 +1,59 @@ +/* Copyright 2014 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_RCL_TYPES_H_ +#define RCL_RCL_TYPES_H_ + +#include + +typedef rmw_ret_t rcl_ret_t; +#define RCL_RET_OK RMW_RET_OK + +typedef rmw_node_t rcl_node_t; +typedef rmw_publisher_t rcl_publisher_t; +typedef rmw_subscription_t rcl_subscription_t; +typedef rmw_guard_condition_t rcl_guard_condition_t; +typedef rmw_subscriptions_t rcl_subscriptions_t; +typedef rmw_guard_conditions_t rcl_guard_conditions_t; + +typedef struct rcl_callback_group_t +{ + rcl_node_t * * node; +} rcl_callback_group_t; + +typedef struct rcl_subscription_info_t +{ + rcl_subscription_t * * subscription; + rcl_callback_group_t * * callback_group; +} rcl_subscription_info_t; + +typedef struct rcl_timer_info_t +{ + rcl_guard_condition_t * * guard_condition; + rcl_callback_group_t * * callback_group; +} rcl_timer_info_t; + +typedef struct rcl_executor_helper_t +{ + // TODO: fill with something +} rcl_executor_helper_t; + +typedef struct rcl_any_executable_t +{ + rcl_subscription_info_t * * subscription_info; + rcl_timer_info_t * * timer_info; +} rcl_any_executable_t; + +#endif /* RCL_RCL_TYPES_H_ */ diff --git a/rcl/package.xml b/rcl/package.xml new file mode 100644 index 0000000..df82573 --- /dev/null +++ b/rcl/package.xml @@ -0,0 +1,17 @@ + + + rcl + 0.0.0 + The ROS client library common implementation. + This package contains an API which builds on the ROS middleware API and is optionally built upon by the other ROS client libraries. + + William Woodall + Apache License 2.0 + + ament_cmake + + ros_middleware_interface + + ros_middleware_interface + +