Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::environment::EnvironmentMonitor Class Referenceabstract

Tesseract Environment Monitor Interface Class. More...

#include <environment_monitor.h>

Public Types

using Ptr = std::shared_ptr<EnvironmentMonitor>
using ConstPtr = std::shared_ptr<const EnvironmentMonitor>
using UPtr = std::unique_ptr<EnvironmentMonitor>
using ConstUPtr = std::unique_ptr<const EnvironmentMonitor>

Public Member Functions

 EnvironmentMonitor (std::string monitor_namespace)
 Constructor.
 EnvironmentMonitor (std::shared_ptr< Environment > env, std::string monitor_namespace)
 Constructor.
 EnvironmentMonitor (const EnvironmentMonitor &)=default
EnvironmentMonitor & operator= (const EnvironmentMonitor &)=default
 EnvironmentMonitor (EnvironmentMonitor &&)=default
EnvironmentMonitor & operator= (EnvironmentMonitor &&)=default
virtual const std::string & getNamespace () const
 Get the namespace of this monitor.
virtual Environment & environment ()
 Returns an threadsafe reference to the current environment.
virtual const Environment & environment () const
 Returns an threadsafe const reference to the current environment.
virtual std::shared_ptr< Environment > getEnvironment ()
 Returns an threadsafe shared pointer to the current environment.
virtual std::shared_ptr< const Environment > getEnvironment () const
 Returns an threadsafe const shared point to the current environment.
virtual bool waitForConnection (std::chrono::duration< double > duration=std::chrono::seconds(0)) const =0
 Wait for connection to upstream environment.
virtual void startPublishingEnvironment ()=0
 Start publishing the maintained environment.
virtual void stopPublishingEnvironment ()=0
 Stop publishing the maintained environment.
virtual void setEnvironmentPublishingFrequency (double hz)=0
 Set the maximum frequency at which environment are being published.
virtual double getEnvironmentPublishingFrequency () const =0
 Get the maximum frequency at which environment are published (Hz).
virtual void startStateMonitor (const std::string &joint_states_topic, bool publish_tf=true)=0
 Start the current state monitor.
virtual void stopStateMonitor ()=0
 Stop the state monitor.
virtual void setStateUpdateFrequency (double hz=10)=0
 Update the scene using the monitored state at a specified frequency, in Hz. This function has an effect only when updates from the CurrentStateMonitor are received at a higher frequency. In that case, the updates are throttled down, so that they do not exceed a maximum update frequency specified here.
virtual double getStateUpdateFrequency () const =0
 Get the maximum frequency (Hz) at which the current state of the planning scene is updated.
virtual void updateEnvironmentWithCurrentState ()=0
 Update the scene using the monitored state. This function is automatically called when an update to the current state is received (if startStateMonitor() has been called). The updates are throttled to a maximum update frequency however, which is set by setStateUpdateFrequency().
virtual void startMonitoringEnvironment (const std::string &monitored_namespace, MonitoredEnvironmentMode mode=MonitoredEnvironmentMode::DEFAULT)=0
 Start the monitoring of an environment topic.
virtual void stopMonitoringEnvironment ()=0
 Stop monitoring the external environment.
virtual bool waitForCurrentState (std::chrono::duration< double > duration=std::chrono::seconds(1))=0
 Wait for robot state to become more recent than time t.
virtual void shutdown ()=0
 Shutdown advertised services.

Protected Attributes

std::shared_ptr< tesseract::environment::Environment > env_
std::string monitor_namespace_
MonitoredEnvironmentMode mode_ { MonitoredEnvironmentMode::DEFAULT }

Detailed Description

Tesseract Environment Monitor Interface Class.

Constructor & Destructor Documentation

◆ EnvironmentMonitor() [1/2]

tesseract::environment::EnvironmentMonitor::EnvironmentMonitor ( std::string monitor_namespace)

Constructor.

Parameters
monitor_namespaceA name identifying this monitor, must be unique

◆ EnvironmentMonitor() [2/2]

tesseract::environment::EnvironmentMonitor::EnvironmentMonitor ( std::shared_ptr< Environment > env,
std::string monitor_namespace )

Constructor.

Parameters
envThe environment to use internal to the monitor
monitor_namespaceA name identifying this monitor, must be unique

Member Function Documentation

◆ environment() [1/2]

Environment & tesseract::environment::EnvironmentMonitor::environment ( )
virtual

Returns an threadsafe reference to the current environment.

Modification should only be made if this monitor is the master. If this is monitoring another environment the local changes will get removed on the next update cycle. Recommend using the TesseractMonitorInterface to apply commands to the monitored environment until the todo below is implemented.

Returns
The current environment.

◆ environment() [2/2]

const Environment & tesseract::environment::EnvironmentMonitor::environment ( ) const
virtual

Returns an threadsafe const reference to the current environment.

Returns
The current environment.

◆ getEnvironment() [1/2]

std::shared_ptr< Environment > tesseract::environment::EnvironmentMonitor::getEnvironment ( )
virtual

Returns an threadsafe shared pointer to the current environment.

Modification should only be made if this monitor is the master. If this is monitoring another environment the local changes will get removed on the next update cycle. Recommend using the TesseractMonitorInterface to apply commands to the monitored environment until the todo below is implemented.

Returns
The current environment.

◆ getEnvironment() [2/2]

std::shared_ptr< const Environment > tesseract::environment::EnvironmentMonitor::getEnvironment ( ) const
virtual

Returns an threadsafe const shared point to the current environment.

Returns
The current environment.

◆ waitForConnection()

virtual bool tesseract::environment::EnvironmentMonitor::waitForConnection ( std::chrono::duration< double > duration = std::chrono::seconds(0)) const
pure virtual

Wait for connection to upstream environment.

Parameters
durationThe time to wait in seconds before returning, if zero it waits indefinitely
Returns
True if it has connected to upstream environment, otherwise false

◆ startStateMonitor()

virtual void tesseract::environment::EnvironmentMonitor::startStateMonitor ( const std::string & joint_states_topic,
bool publish_tf = true )
pure virtual

Start the current state monitor.

Parameters
joint_states_topicthe topic to listen to for joint states
publish_tfIf true, TFs will be published for each joint. Default: true

◆ setStateUpdateFrequency()

virtual void tesseract::environment::EnvironmentMonitor::setStateUpdateFrequency ( double hz = 10)
pure virtual

Update the scene using the monitored state at a specified frequency, in Hz. This function has an effect only when updates from the CurrentStateMonitor are received at a higher frequency. In that case, the updates are throttled down, so that they do not exceed a maximum update frequency specified here.

Parameters
hzthe update frequency. By default this is 10Hz.

◆ startMonitoringEnvironment()

virtual void tesseract::environment::EnvironmentMonitor::startMonitoringEnvironment ( const std::string & monitored_namespace,
MonitoredEnvironmentMode mode = MonitoredEnvironmentMode::DEFAULT )
pure virtual

Start the monitoring of an environment topic.

Parameters
monitored_namespaceThe namespace of the environment to monitor

◆ waitForCurrentState()

virtual bool tesseract::environment::EnvironmentMonitor::waitForCurrentState ( std::chrono::duration< double > duration = std::chrono::seconds(1))
pure virtual

Wait for robot state to become more recent than time t.

Parameters
durationThe time to wait in seconds

If there is no state monitor active, there will be no scene updates. Hence, you can specify a timeout to wait for those updates. Default is 1s.