Lifecycle nodes#
ICEY supports lifecycle nodes, for this you simply need to derive from a icey::LifecycleNode
:
class ExampleLifecycleNode : public icey::LifecycleNode {
public:
using Base = icey::LifecycleNode;
ExampleLifecycleNode(std::string name) : Base(name) { timer_ = icey().create_timer(100ms); }
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_activate(
const rclcpp_lifecycle::State &state) {
RCLCPP_INFO(get_logger(), "on_activate() was called");
}
};
See also the lifecycle node example.
The API for creating Streams remains the same regardless of whether you use a regular node or an lifecycle node.
This is because the underlying icey::Context
-type is the same.
This means that if you want to create functions that are generic and work for both regular nodes and lifecycle nodes, you can take as icey::Context
as an argument:
void create_subscriptions(icey::Context &context) {
context.create_subscription<sensor_msgs::msg::Image>("camera")
.then(...);
context.create_transform_subscription("map", "base_link")
.then(...);
}
This also means, you do need to use function templates that use the node as a template parameter.