mark up all the functions to document
This commit is contained in:
parent
16afde88a1
commit
0a72cd7fcb
11 changed files with 55 additions and 0 deletions
|
@ -36,6 +36,15 @@ namespace rclcpp
|
||||||
namespace executor
|
namespace executor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// Coordinates the order and timing of available communication tasks.
|
||||||
|
/* Executor provides spin functions (including spin_node_once and spin_some).
|
||||||
|
* It coordinates the nodes and callback groups by looking for available work and completing it,
|
||||||
|
* based on the threading or concurrency scheme provided by the subclass implementation.
|
||||||
|
* An example of available work is executing a subscription callback, or a timer callback.
|
||||||
|
* The executor structure allows for a decoupling of the communication graph and the execution
|
||||||
|
* model.
|
||||||
|
* See SingleThreadedExecutor and MultiThreadedExecutor for examples of execution paradigms.
|
||||||
|
*/
|
||||||
class Executor
|
class Executor
|
||||||
{
|
{
|
||||||
friend class memory_strategy::MemoryStrategy;
|
friend class memory_strategy::MemoryStrategy;
|
||||||
|
@ -43,6 +52,8 @@ class Executor
|
||||||
public:
|
public:
|
||||||
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(Executor);
|
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(Executor);
|
||||||
|
|
||||||
|
/// Default constructor.
|
||||||
|
// \param[in] ms The memory strategy to be used with this executor.
|
||||||
explicit Executor(memory_strategy::MemoryStrategy::SharedPtr ms =
|
explicit Executor(memory_strategy::MemoryStrategy::SharedPtr ms =
|
||||||
memory_strategy::create_default_strategy())
|
memory_strategy::create_default_strategy())
|
||||||
: interrupt_guard_condition_(rmw_create_guard_condition()),
|
: interrupt_guard_condition_(rmw_create_guard_condition()),
|
||||||
|
@ -50,8 +61,10 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Default destructor.
|
||||||
virtual ~Executor()
|
virtual ~Executor()
|
||||||
{
|
{
|
||||||
|
// Try to deallocate the interrupt guard condition.
|
||||||
if (interrupt_guard_condition_ != nullptr) {
|
if (interrupt_guard_condition_ != nullptr) {
|
||||||
rmw_ret_t status = rmw_destroy_guard_condition(interrupt_guard_condition_);
|
rmw_ret_t status = rmw_destroy_guard_condition(interrupt_guard_condition_);
|
||||||
if (status != RMW_RET_OK) {
|
if (status != RMW_RET_OK) {
|
||||||
|
@ -61,8 +74,17 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Do work periodically as it becomes available to us. Blocking call, may block indefinitely.
|
||||||
|
// It is up to the implementation of Executor to implement spin.
|
||||||
virtual void spin() = 0;
|
virtual void spin() = 0;
|
||||||
|
|
||||||
|
/// Add a node to the executor.
|
||||||
|
/* An executor can have zero or more nodes which provide work during `spin` functions.
|
||||||
|
* \param[in] node_ptr Shared pointer to the node to be added.
|
||||||
|
* \param[in] notify True to trigger the interrupt guard condition during this function. If
|
||||||
|
* the executor is blocked at the rmw layer while waiting for work and it is notified that a new
|
||||||
|
* node was added, it will wake up.
|
||||||
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
add_node(rclcpp::node::Node::SharedPtr & node_ptr, bool notify = true)
|
add_node(rclcpp::node::Node::SharedPtr & node_ptr, bool notify = true)
|
||||||
{
|
{
|
||||||
|
@ -84,6 +106,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove a node from the executor.
|
||||||
|
/* \param[in] node_ptr Shared pointer to the node to remove.
|
||||||
|
* \param[in] notify True to trigger the interrupt guard condition and wake up the executor.
|
||||||
|
* This is useful if the last node was removed from the executor while the executor was blocked
|
||||||
|
* waiting for work in another thread, because otherwise the executor would never be notified.
|
||||||
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
remove_node(rclcpp::node::Node::SharedPtr & node_ptr, bool notify = true)
|
remove_node(rclcpp::node::Node::SharedPtr & node_ptr, bool notify = true)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +136,11 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a node to executor, complete the next available unit of work, and remove the node.
|
||||||
|
/* \param[in] node Shared pointer to the node to add.
|
||||||
|
* \param[in] timeout How long to wait for work to become available. Negative values cause
|
||||||
|
* spin_node_once to block indefinitely
|
||||||
|
*/
|
||||||
template<typename T = std::milli>
|
template<typename T = std::milli>
|
||||||
void spin_node_once(rclcpp::node::Node::SharedPtr & node,
|
void spin_node_once(rclcpp::node::Node::SharedPtr & node,
|
||||||
std::chrono::duration<int64_t, T> timeout = std::chrono::duration<int64_t, T>(-1))
|
std::chrono::duration<int64_t, T> timeout = std::chrono::duration<int64_t, T>(-1))
|
||||||
|
@ -121,6 +154,7 @@ public:
|
||||||
this->remove_node(node, false);
|
this->remove_node(node, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
void spin_node_some(rclcpp::node::Node::SharedPtr & node)
|
void spin_node_some(rclcpp::node::Node::SharedPtr & node)
|
||||||
{
|
{
|
||||||
this->add_node(node, false);
|
this->add_node(node, false);
|
||||||
|
@ -128,6 +162,7 @@ public:
|
||||||
this->remove_node(node, false);
|
this->remove_node(node, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
virtual void spin_some()
|
virtual void spin_some()
|
||||||
{
|
{
|
||||||
while (AnyExecutable::SharedPtr any_exec =
|
while (AnyExecutable::SharedPtr any_exec =
|
||||||
|
@ -137,6 +172,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
// Support dynamic switching of memory strategy
|
// Support dynamic switching of memory strategy
|
||||||
void
|
void
|
||||||
set_memory_strategy(memory_strategy::MemoryStrategy::SharedPtr memory_strategy)
|
set_memory_strategy(memory_strategy::MemoryStrategy::SharedPtr memory_strategy)
|
||||||
|
@ -149,6 +185,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void
|
void
|
||||||
|
// TODO
|
||||||
execute_any_executable(AnyExecutable::SharedPtr & any_exec)
|
execute_any_executable(AnyExecutable::SharedPtr & any_exec)
|
||||||
{
|
{
|
||||||
if (!any_exec) {
|
if (!any_exec) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace executors
|
||||||
namespace single_threaded_executor
|
namespace single_threaded_executor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
class SingleThreadedExecutor : public executor::Executor
|
class SingleThreadedExecutor : public executor::Executor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Executor;
|
||||||
namespace memory_strategy
|
namespace memory_strategy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
class MemoryStrategy
|
class MemoryStrategy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace rclcpp
|
||||||
namespace message_memory_strategy
|
namespace message_memory_strategy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
template<typename MessageT>
|
template<typename MessageT>
|
||||||
class MessageMemoryStrategy
|
class MessageMemoryStrategy
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,6 +96,7 @@ struct function_traits<ReturnTypeT (ClassT::*)(Args ...) const>
|
||||||
*
|
*
|
||||||
* This is the single point of entry for creating publishers and subscribers.
|
* This is the single point of entry for creating publishers and subscribers.
|
||||||
*/
|
*/
|
||||||
|
// TODO
|
||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
friend class rclcpp::executor::Executor;
|
friend class rclcpp::executor::Executor;
|
||||||
|
@ -103,6 +104,7 @@ class Node
|
||||||
public:
|
public:
|
||||||
RCLCPP_SMART_PTR_DEFINITIONS(Node);
|
RCLCPP_SMART_PTR_DEFINITIONS(Node);
|
||||||
|
|
||||||
|
// TODO: ALL public functions
|
||||||
/* Create a node based on the node name. */
|
/* Create a node based on the node name. */
|
||||||
Node(const std::string & node_name, bool use_intra_process_comms = false);
|
Node(const std::string & node_name, bool use_intra_process_comms = false);
|
||||||
/* Create a node based on the node name and a rclcpp::context::Context. */
|
/* Create a node based on the node name and a rclcpp::context::Context. */
|
||||||
|
|
|
@ -39,10 +39,12 @@ class Node;
|
||||||
namespace publisher
|
namespace publisher
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
class Publisher
|
class Publisher
|
||||||
{
|
{
|
||||||
friend rclcpp::node::Node;
|
friend rclcpp::node::Node;
|
||||||
|
|
||||||
|
// TODO
|
||||||
public:
|
public:
|
||||||
RCLCPP_SMART_PTR_DEFINITIONS(Publisher);
|
RCLCPP_SMART_PTR_DEFINITIONS(Publisher);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace strategies
|
||||||
namespace message_pool_memory_strategy
|
namespace message_pool_memory_strategy
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
template<typename MessageT, size_t Size,
|
template<typename MessageT, size_t Size,
|
||||||
typename std::enable_if<rosidl_generator_traits::has_fixed_size<MessageT>::value>::type * =
|
typename std::enable_if<rosidl_generator_traits::has_fixed_size<MessageT>::value>::type * =
|
||||||
nullptr>
|
nullptr>
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace memory_strategies
|
||||||
|
|
||||||
namespace static_memory_strategy
|
namespace static_memory_strategy
|
||||||
{
|
{
|
||||||
|
// TODO
|
||||||
struct ObjectPoolBounds
|
struct ObjectPoolBounds
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -80,6 +81,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// TODO
|
||||||
class StaticMemoryStrategy : public memory_strategy::MemoryStrategy
|
class StaticMemoryStrategy : public memory_strategy::MemoryStrategy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -49,6 +49,7 @@ class SubscriptionBase
|
||||||
{
|
{
|
||||||
friend class rclcpp::executor::Executor;
|
friend class rclcpp::executor::Executor;
|
||||||
|
|
||||||
|
// TODO
|
||||||
public:
|
public:
|
||||||
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(SubscriptionBase);
|
RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(SubscriptionBase);
|
||||||
|
|
||||||
|
@ -113,11 +114,13 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO
|
||||||
template<typename MessageT>
|
template<typename MessageT>
|
||||||
class Subscription : public SubscriptionBase
|
class Subscription : public SubscriptionBase
|
||||||
{
|
{
|
||||||
friend class rclcpp::node::Node;
|
friend class rclcpp::node::Node;
|
||||||
|
|
||||||
|
// TODO
|
||||||
public:
|
public:
|
||||||
using CallbackType = std::function<void(const std::shared_ptr<MessageT> &)>;
|
using CallbackType = std::function<void(const std::shared_ptr<MessageT> &)>;
|
||||||
RCLCPP_SMART_PTR_DEFINITIONS(Subscription);
|
RCLCPP_SMART_PTR_DEFINITIONS(Subscription);
|
||||||
|
|
|
@ -82,6 +82,7 @@ protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO
|
||||||
template<class Clock = std::chrono::high_resolution_clock>
|
template<class Clock = std::chrono::high_resolution_clock>
|
||||||
class GenericTimer : public TimerBase
|
class GenericTimer : public TimerBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,6 +98,7 @@ RMW_THREAD_LOCAL size_t thread_id = 0;
|
||||||
namespace utilities
|
namespace utilities
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO
|
||||||
void
|
void
|
||||||
init(int argc, char * argv[])
|
init(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
@ -138,12 +139,14 @@ init(int argc, char * argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
bool
|
bool
|
||||||
ok()
|
ok()
|
||||||
{
|
{
|
||||||
return ::g_signal_status == 0;
|
return ::g_signal_status == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
void
|
void
|
||||||
shutdown()
|
shutdown()
|
||||||
{
|
{
|
||||||
|
@ -163,6 +166,7 @@ get_global_sigint_guard_condition()
|
||||||
return ::g_sigint_guard_cond_handle;
|
return ::g_sigint_guard_cond_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
bool
|
bool
|
||||||
sleep_for(const std::chrono::nanoseconds & nanoseconds)
|
sleep_for(const std::chrono::nanoseconds & nanoseconds)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue