Node that can run both with and without a ROS master. This can be useful for one-off scripts that do not need to publish or subscribe anything, but they want to make use of the parameter processing and name remapping. More...
#include <node_with_optional_master.h>
Public Member Functions | |
::cras::BoundParamHelperPtr | getPrivateParams () const |
Get private parameters of the node. More... | |
void | init (const ::ros::M_string &remappings, const ::std::string &name, uint32_t options) |
Initialize the node, autodetecting whether a ros master is running or not. More... | |
void | init (const ::ros::VP_string &remappings, const ::std::string &name, uint32_t options) |
Initialize the node, autodetecting whether a ros master is running or not. More... | |
void | init (int &argc, char **argv, const ::std::string &name, uint32_t options) |
Initialize the node, autodetecting whether a ros master is running or not. More... | |
bool | isInitialized () const |
Has init() been called? More... | |
NodeWithOptionalMaster (const ::cras::LogHelperPtr &log) | |
bool | ok () const |
Equivalent of ros::ok() . More... | |
::std::string | resolveName (const ::std::string &name, bool remap=true) const |
Resolve a name relative to the global namespace. More... | |
void | shutdown () |
Shutdown the node. More... | |
bool | usesMaster () const |
Is a live ROS master being used? More... | |
virtual | ~NodeWithOptionalMaster () |
![]() | |
::cras::LogHelperConstPtr | getCrasLogger () const |
This is the function picked up by CRAS_* logging macros. More... | |
HasLogger (const ::cras::LogHelperPtr &log) | |
Associate the logger with this interface. More... | |
void | setCrasLogger (const ::cras::LogHelperPtr &log) |
Set the logger to be used for logging. More... | |
Private Attributes | |
::std::unique_ptr< NodeWithOptionalMasterPrivate > | data |
PIMPL. More... | |
Additional Inherited Members | |
![]() | |
::cras::LogHelperPtr | log |
Log helper. More... | |
Node that can run both with and without a ROS master. This can be useful for one-off scripts that do not need to publish or subscribe anything, but they want to make use of the parameter processing and name remapping.
This class provides an interface similar to ros::NodeHandle. However, when init() is called, it first checks whether the rosmaster is running and can be contacted. If not, this class falls back to a mode with no master. It will still provide parameters and name resolving, however, only for the parameters and remaps directly specified when launching the node. When running without master, simulation time is never used.
Definition at line 33 of file node_with_optional_master.h.
|
explicit |
[in] | log | Logger. |
|
virtual |
::cras::BoundParamHelperPtr cras::NodeWithOptionalMaster::getPrivateParams | ( | ) | const |
Get private parameters of the node.
void cras::NodeWithOptionalMaster::init | ( | const ::ros::M_string & | remappings, |
const ::std::string & | name, | ||
uint32_t | options | ||
) |
Initialize the node, autodetecting whether a ros master is running or not.
[in] | remappings | Remappings of parameters and topics. |
[in] | name | Node name. |
[in] | options | Node init options. |
void cras::NodeWithOptionalMaster::init | ( | const ::ros::VP_string & | remappings, |
const ::std::string & | name, | ||
uint32_t | options | ||
) |
Initialize the node, autodetecting whether a ros master is running or not.
[in] | remappings | Remappings of parameters and topics. |
[in] | name | Node name. |
[in] | options | Node init options. |
void cras::NodeWithOptionalMaster::init | ( | int & | argc, |
char ** | argv, | ||
const ::std::string & | name, | ||
uint32_t | options | ||
) |
Initialize the node, autodetecting whether a ros master is running or not.
[in] | argc | Nr. of CLI args. |
[in] | argv | CLI args. |
[in] | name | Node name. |
[in] | options | Node init options. |
bool cras::NodeWithOptionalMaster::isInitialized | ( | ) | const |
Has init() been called?
bool cras::NodeWithOptionalMaster::ok | ( | ) | const |
Equivalent of ros::ok() .
::std::string cras::NodeWithOptionalMaster::resolveName | ( | const ::std::string & | name, |
bool | remap = true |
||
) | const |
Resolve a name relative to the global namespace.
name | The name to be resolved (cannot start with ~). |
remap | Whether remapping should be applied. |
void cras::NodeWithOptionalMaster::shutdown | ( | ) |
Shutdown the node.
bool cras::NodeWithOptionalMaster::usesMaster | ( | ) | const |
Is a live ROS master being used?
|
private |
PIMPL.
Definition at line 103 of file node_with_optional_master.h.