YARP
Yet Another Robot Platform
yarp::os::RosNameSpace Class Reference

#include <yarp/os/RosNameSpace.h>

+ Inheritance diagram for yarp::os::RosNameSpace:

Public Member Functions

 RosNameSpace (const Contact &contact)
 
virtual ~RosNameSpace ()
 
Contact getNameServerContact () const override
 Get an address for a name server that manages the name space, if available. More...
 
Contact queryName (const std::string &name) override
 Map from port name to contact information. More...
 
Contact registerName (const std::string &name) override
 Record contact information to tie to a port name. More...
 
Contact registerContact (const Contact &contact) override
 Record contact information (should include a port name). More...
 
Contact unregisterName (const std::string &name) override
 Disassociate contact information from a port name. More...
 
Contact unregisterContact (const Contact &contact) override
 Disassociate contact information (should include a port name). More...
 
virtual Contact registerAdvanced (const Contact &contact, NameStore *store) override
 Record contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual Contact unregisterAdvanced (const std::string &name, NameStore *store) override
 Remove contact information, with access to the contact information of other ports for cross-referencing. More...
 
virtual bool setProperty (const std::string &name, const std::string &key, const Value &value) override
 Associate a key/value pair with a named port. More...
 
virtual ValuegetProperty (const std::string &name, const std::string &key) override
 Get the value of a named key from a named port. More...
 
virtual bool connectPortToTopic (const Contact &src, const Contact &dest, const ContactStyle &style) override
 Publish a port to a topic. More...
 
virtual bool connectTopicToPort (const Contact &src, const Contact &dest, const ContactStyle &style) override
 Subscribe a port to a topic. More...
 
virtual bool disconnectPortFromTopic (const Contact &src, const Contact &dest, const ContactStyle &style) override
 Stop publishing a port to a topic. More...
 
virtual bool disconnectTopicFromPort (const Contact &src, const Contact &dest, const ContactStyle &style) override
 Stop subscribing a port to a topic. More...
 
virtual bool connectPortToPortPersistently (const Contact &src, const Contact &dest, const ContactStyle &style) override
 Connect two ports with persistence. More...
 
virtual bool disconnectPortToPortPersistently (const Contact &src, const Contact &dest, const ContactStyle &style) override
 Disconnect two ports, removing any persistence. More...
 
virtual bool connectTopic (Bottle &cmd, bool srcIsTopic, const Contact &src, const Contact &dest, const ContactStyle &style, bool activeRegistration)
 
bool localOnly () const override
 Check if the NameSpace is only valid for the current process ("local"). More...
 
bool usesCentralServer () const override
 Check if a central server is involved in managing the NameSpace. More...
 
bool serverAllocatesPortNumbers () const override
 Check if a central server is responsible for allocating port numbers, or if this should be left up to the operating system. More...
 
bool connectionHasNameOfEndpoints () const override
 When connections are made involving ports managed by this NameSpace do the ports involved end up knowing the names of their counterparties? More...
 
virtual Contact detectNameServer (bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
 Find a name server for this NameSpace, if applicable. More...
 
virtual bool writeToNameServer (PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
 Write a message to a name server for this NameSpace, if applicable. More...
 
void run () override
 Main body of the new thread. More...
 
- Public Member Functions inherited from yarp::os::NameSpace
virtual ~NameSpace ()
 Destructor. More...
 
virtual bool checkNetwork ()
 Check if a name space is available. More...
 
virtual bool checkNetwork (double timeout)
 Check if a name space is available, with a timeout on any network operations needed. More...
 
virtual std::string getNameServerName () const
 Get the port name of a name server that manages the name space, if available. More...
 
- Public Member Functions inherited from yarp::os::Thread
 Thread ()
 Constructor. More...
 
virtual ~Thread ()
 Destructor. More...
 
virtual void onStop ()
 Call-back, called while halting the thread (before join). More...
 
bool start ()
 Start the new thread running. More...
 
bool stop ()
 Stop the thread. More...
 
virtual void beforeStart ()
 Called just before a new thread starts. More...
 
virtual void afterStart (bool success)
 Called just after a new thread starts (or fails to start), this is executed by the same thread that calls start(). More...
 
virtual bool threadInit ()
 Initialization method. More...
 
virtual void threadRelease ()
 Release method. More...
 
bool isStopping ()
 Returns true if the thread is stopping (Thread::stop has been called). More...
 
bool isRunning ()
 Returns true if the thread is running (Thread::start has been called successfully and the thread has not stopped). More...
 
long int getKey ()
 Get a unique identifier for the thread. More...
 
int setPriority (int priority, int policy=-1)
 Set the priority and scheduling policy of the thread, if the OS supports that. More...
 
int getPriority ()
 Query the current priority of the thread, if the OS supports that. More...
 
int getPolicy ()
 Query the current scheduling policy of the thread, if the OS supports that. More...
 
bool join (double seconds=-1)
 The function returns when the thread execution has completed. More...
 
void setOptions (int stackSize=0)
 Set the stack size for the new thread. More...
 

Static Public Member Functions

static std::string toRosName (const std::string &name)
 Possible ROS names are a subset of YARP names. More...
 
static std::string fromRosName (const std::string &name)
 
static std::string toRosNodeName (const std::string &name)
 
static std::string fromRosNodeName (const std::string &name)
 
static Contact rosify (const Contact &contact)
 
- Static Public Member Functions inherited from yarp::os::Thread
static int getCount ()
 Check how many threads are running. More...
 
static long int getKeyOfCaller ()
 Get a unique identifier for the calling thread. More...
 
static void yield ()
 Reschedule the execution of current thread, allowing other threads to run. More...
 
static void setDefaultStackSize (int stackSize)
 Set the default stack size for all threads created after this point. More...
 

Detailed Description

Definition at line 23 of file RosNameSpace.h.

Constructor & Destructor Documentation

◆ RosNameSpace()

RosNameSpace::RosNameSpace ( const Contact contact)

Definition at line 32 of file RosNameSpace.cpp.

◆ ~RosNameSpace()

RosNameSpace::~RosNameSpace ( )
virtual

Definition at line 38 of file RosNameSpace.cpp.

Member Function Documentation

◆ connectionHasNameOfEndpoints()

bool RosNameSpace::connectionHasNameOfEndpoints ( ) const
overridevirtual

When connections are made involving ports managed by this NameSpace do the ports involved end up knowing the names of their counterparties?

Implements yarp::os::NameSpace.

Definition at line 540 of file RosNameSpace.cpp.

◆ connectPortToPortPersistently()

bool RosNameSpace::connectPortToPortPersistently ( const Contact src,
const Contact dest,
const ContactStyle style 
)
overridevirtual

Connect two ports with persistence.

Implements yarp::os::NameSpace.

Definition at line 456 of file RosNameSpace.cpp.

◆ connectPortToTopic()

bool RosNameSpace::connectPortToTopic ( const Contact src,
const Contact dest,
const ContactStyle style 
)
overridevirtual

Publish a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 404 of file RosNameSpace.cpp.

◆ connectTopic()

bool RosNameSpace::connectTopic ( Bottle cmd,
bool  srcIsTopic,
const Contact src,
const Contact dest,
const ContactStyle style,
bool  activeRegistration 
)
virtual

Definition at line 476 of file RosNameSpace.cpp.

◆ connectTopicToPort()

bool RosNameSpace::connectTopicToPort ( const Contact src,
const Contact dest,
const ContactStyle style 
)
overridevirtual

Subscribe a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 418 of file RosNameSpace.cpp.

◆ detectNameServer()

Contact RosNameSpace::detectNameServer ( bool  useDetectedServer,
bool &  scanNeeded,
bool &  serverUsed 
)
overridevirtual

Find a name server for this NameSpace, if applicable.

Parameters
useDetectedServeruse any server found for future queries.
scanNeededset to true if a search was needed, rather than finding a name server based on cached hints.
serverUsedset to true if a server was found and marked for use in future queries.

Implements yarp::os::NameSpace.

Definition at line 545 of file RosNameSpace.cpp.

◆ disconnectPortFromTopic()

bool RosNameSpace::disconnectPortFromTopic ( const Contact src,
const Contact dest,
const ContactStyle style 
)
overridevirtual

Stop publishing a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 432 of file RosNameSpace.cpp.

◆ disconnectPortToPortPersistently()

bool RosNameSpace::disconnectPortToPortPersistently ( const Contact src,
const Contact dest,
const ContactStyle style 
)
overridevirtual

Disconnect two ports, removing any persistence.

Implements yarp::os::NameSpace.

Definition at line 466 of file RosNameSpace.cpp.

◆ disconnectTopicFromPort()

bool RosNameSpace::disconnectTopicFromPort ( const Contact src,
const Contact dest,
const ContactStyle style 
)
overridevirtual

Stop subscribing a port to a topic.

Implements yarp::os::NameSpace.

Definition at line 444 of file RosNameSpace.cpp.

◆ fromRosName()

std::string RosNameSpace::fromRosName ( const std::string &  name)
static

Definition at line 678 of file RosNameSpace.cpp.

◆ fromRosNodeName()

std::string RosNameSpace::fromRosNodeName ( const std::string &  name)
static

Definition at line 712 of file RosNameSpace.cpp.

◆ getNameServerContact()

Contact RosNameSpace::getNameServerContact ( ) const
overridevirtual

Get an address for a name server that manages the name space, if available.

Implements yarp::os::NameSpace.

Definition at line 43 of file RosNameSpace.cpp.

◆ getProperty()

Value * RosNameSpace::getProperty ( const std::string &  name,
const std::string &  key 
)
overridevirtual

Get the value of a named key from a named port.

Returns
nullptr if no value was set for the named key.

Implements yarp::os::NameSpace.

Definition at line 396 of file RosNameSpace.cpp.

◆ localOnly()

bool RosNameSpace::localOnly ( ) const
overridevirtual

Check if the NameSpace is only valid for the current process ("local").

Implements yarp::os::NameSpace.

Definition at line 525 of file RosNameSpace.cpp.

◆ queryName()

Contact RosNameSpace::queryName ( const std::string &  name)
overridevirtual

Map from port name to contact information.

Implements yarp::os::NameSpace.

Definition at line 48 of file RosNameSpace.cpp.

◆ registerAdvanced()

Contact RosNameSpace::registerAdvanced ( const Contact contact,
NameStore store 
)
overridevirtual

Record contact information, with access to the contact information of other ports for cross-referencing.

Parameters
contactthe contact information to record
storean interface to port information as presented via the YARP client API (as opposed to what a single NameSpace would have access to).

Reimplemented from yarp::os::NameSpace.

Definition at line 110 of file RosNameSpace.cpp.

◆ registerContact()

Contact RosNameSpace::registerContact ( const Contact contact)
overridevirtual

Record contact information (should include a port name).

Implements yarp::os::NameSpace.

Definition at line 105 of file RosNameSpace.cpp.

◆ registerName()

Contact RosNameSpace::registerName ( const std::string &  name)
overridevirtual

Record contact information to tie to a port name.

Implements yarp::os::NameSpace.

Definition at line 95 of file RosNameSpace.cpp.

◆ rosify()

Contact RosNameSpace::rosify ( const Contact contact)
static

Definition at line 717 of file RosNameSpace.cpp.

◆ run()

void RosNameSpace::run ( )
overridevirtual

Main body of the new thread.

Override this method to do what you want. After Thread::start is called, this method will start running in a separate thread. It is important that this method either keeps checking Thread::isStopping to see if it should stop, or you override the Thread::onStop method to interact with it in some way to shut the new thread down. There is no really reliable, portable way to stop a thread cleanly unless that thread cooperates.

Implements yarp::os::Thread.

Definition at line 730 of file RosNameSpace.cpp.

◆ serverAllocatesPortNumbers()

bool RosNameSpace::serverAllocatesPortNumbers ( ) const
overridevirtual

Check if a central server is responsible for allocating port numbers, or if this should be left up to the operating system.

Implements yarp::os::NameSpace.

Definition at line 535 of file RosNameSpace.cpp.

◆ setProperty()

bool RosNameSpace::setProperty ( const std::string &  name,
const std::string &  key,
const Value value 
)
overridevirtual

Associate a key/value pair with a named port.

Implements yarp::os::NameSpace.

Definition at line 386 of file RosNameSpace.cpp.

◆ toRosName()

std::string RosNameSpace::toRosName ( const std::string &  name)
static

Possible ROS names are a subset of YARP names.

For nodes, in practice there isn't much restriction, except ":" is definitely ruled out. Since plenty of valid YARP ports have a ":" in them, we need to quote this.

Definition at line 662 of file RosNameSpace.cpp.

◆ toRosNodeName()

std::string RosNameSpace::toRosNodeName ( const std::string &  name)
static

Definition at line 707 of file RosNameSpace.cpp.

◆ unregisterAdvanced()

Contact RosNameSpace::unregisterAdvanced ( const std::string &  name,
NameStore store 
)
overridevirtual

Remove contact information, with access to the contact information of other ports for cross-referencing.

Reimplemented from yarp::os::NameSpace.

Definition at line 270 of file RosNameSpace.cpp.

◆ unregisterContact()

Contact RosNameSpace::unregisterContact ( const Contact contact)
overridevirtual

Disassociate contact information (should include a port name).

Implements yarp::os::NameSpace.

Definition at line 366 of file RosNameSpace.cpp.

◆ unregisterName()

Contact RosNameSpace::unregisterName ( const std::string &  name)
overridevirtual

Disassociate contact information from a port name.

Implements yarp::os::NameSpace.

Definition at line 265 of file RosNameSpace.cpp.

◆ usesCentralServer()

bool RosNameSpace::usesCentralServer ( ) const
overridevirtual

Check if a central server is involved in managing the NameSpace.

Implements yarp::os::NameSpace.

Definition at line 530 of file RosNameSpace.cpp.

◆ writeToNameServer()

bool RosNameSpace::writeToNameServer ( PortWriter cmd,
PortReader reply,
const ContactStyle style 
)
overridevirtual

Write a message to a name server for this NameSpace, if applicable.

Messages are name-server-specific.

Implements yarp::os::NameSpace.

Definition at line 574 of file RosNameSpace.cpp.


The documentation for this class was generated from the following files: