-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Nandish Patel edited this page Jun 29, 2021
·
4 revisions
The node_registry package provides the base node classes and utils to eliminate boilerplates when creating ROS nodes. For example when using the simulator all the use_sim_time
parameter of all nodes in the system should be set to True
. Using the registry base class, such functionalities can easily be accomplished. This is applicable for both C++/Python
The XNode should be the base class all of the python nodes.
class MyNode(XNode):
def __init__(self, node_name='my_node', **kwargs):
super(MyNode, self).__init__(node_name, **kwargs)
...
A python node can also be created using the easy to use decorators.
#!/usr/bin/env python3
from node_registry import register, rosnode
# This should be the first function below the import
@rosnode
def node() -> str:
return 'my_node'
# register the node spinning.
register()
The CPP nodes should be the subclass of node_registry::xnode::XNode
.
#include <node_registry/rosnode.hpp>
using node_registry::xnode::XNode;
MyNode::MyNode(
const rclcpp::NodeOptions &options,
const std::string node_name):
XNode(node_name, options) {
}