environment_monitor.h
Go to the documentation of this file.
1 
26 #ifndef TESSERACT_ENVIRONMENT_ENVIRONMENT_MONITOR_H
27 #define TESSERACT_ENVIRONMENT_ENVIRONMENT_MONITOR_H
28 
31 #include <chrono>
32 #include <memory>
33 #include <string>
35 
36 namespace tesseract_environment
37 {
38 class Environment;
39 
40 enum class MonitoredEnvironmentMode : int
41 {
50  DEFAULT = 0,
51 
63  SYNCHRONIZED = 1
64 };
65 
68 {
69 public:
70  using Ptr = std::shared_ptr<EnvironmentMonitor>;
71  using ConstPtr = std::shared_ptr<const EnvironmentMonitor>;
72  using UPtr = std::unique_ptr<EnvironmentMonitor>;
73  using ConstUPtr = std::unique_ptr<const EnvironmentMonitor>;
74 
79  EnvironmentMonitor(std::string monitor_namespace);
80 
86  EnvironmentMonitor(std::shared_ptr<Environment> env, std::string monitor_namespace);
87 
88  virtual ~EnvironmentMonitor() = default;
89  EnvironmentMonitor(const EnvironmentMonitor&) = default;
93 
95  virtual const std::string& getNamespace() const;
96 
104  virtual Environment& environment();
105 
109  virtual const Environment& environment() const;
110 
118  virtual std::shared_ptr<Environment> getEnvironment();
119 
124  virtual std::shared_ptr<const Environment> getEnvironment() const;
125 
131  virtual bool waitForConnection(std::chrono::duration<double> duration = std::chrono::seconds(0)) const = 0;
132 
134  virtual void startPublishingEnvironment() = 0;
135 
137  virtual void stopPublishingEnvironment() = 0;
138 
140  virtual void setEnvironmentPublishingFrequency(double hz) = 0;
141 
143  virtual double getEnvironmentPublishingFrequency() const = 0;
144 
150  virtual void startStateMonitor(const std::string& joint_states_topic, bool publish_tf = true) = 0;
151 
153  virtual void stopStateMonitor() = 0;
154 
161  virtual void setStateUpdateFrequency(double hz = 10) = 0;
162 
164  virtual double getStateUpdateFrequency() const = 0;
165 
171  virtual void updateEnvironmentWithCurrentState() = 0;
172 
177  virtual void startMonitoringEnvironment(const std::string& monitored_namespace,
179 
181  virtual void stopMonitoringEnvironment() = 0;
182 
189  virtual bool waitForCurrentState(std::chrono::duration<double> duration = std::chrono::seconds(1)) = 0;
190 
192  virtual void shutdown() = 0;
193 
194 protected:
195  std::shared_ptr<tesseract_environment::Environment> env_;
196  std::string monitor_namespace_;
198 };
199 
200 } // namespace tesseract_environment
201 #endif // TESSERACT_ENVIRONMENT_ENVIRONMENT_MONITOR_H
tesseract_environment::EnvironmentMonitor::EnvironmentMonitor
EnvironmentMonitor(std::string monitor_namespace)
Constructor.
Definition: environment_monitor.cpp:35
tesseract_environment
Definition: command.h:45
tesseract_environment::EnvironmentMonitor::waitForCurrentState
virtual bool waitForCurrentState(std::chrono::duration< double > duration=std::chrono::seconds(1))=0
Wait for robot state to become more recent than time t.
duration
std::chrono::system_clock::duration duration
tesseract_environment::EnvironmentMonitor::getEnvironmentPublishingFrequency
virtual double getEnvironmentPublishingFrequency() const =0
Get the maximum frequency at which environment are published (Hz)
tesseract_environment::EnvironmentMonitor::UPtr
std::unique_ptr< EnvironmentMonitor > UPtr
Definition: environment_monitor.h:72
tesseract_environment::EnvironmentMonitor::stopStateMonitor
virtual void stopStateMonitor()=0
Stop the state monitor.
tesseract_environment::EnvironmentMonitor
Tesseract Environment Monitor Interface Class.
Definition: environment_monitor.h:67
tesseract_environment::EnvironmentMonitor::stopMonitoringEnvironment
virtual void stopMonitoringEnvironment()=0
Stop monitoring the external environment.
tesseract_environment::EnvironmentMonitor::updateEnvironmentWithCurrentState
virtual void updateEnvironmentWithCurrentState()=0
Update the scene using the monitored state. This function is automatically called when an update to t...
tesseract_environment::EnvironmentMonitor::Ptr
std::shared_ptr< EnvironmentMonitor > Ptr
Definition: environment_monitor.h:70
tesseract_environment::EnvironmentMonitor::setStateUpdateFrequency
virtual void setStateUpdateFrequency(double hz=10)=0
Update the scene using the monitored state at a specified frequency, in Hz. This function has an effe...
tesseract_environment::EnvironmentMonitor::startPublishingEnvironment
virtual void startPublishingEnvironment()=0
Start publishing the maintained environment.
tesseract_environment::EnvironmentMonitor::~EnvironmentMonitor
virtual ~EnvironmentMonitor()=default
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_environment::EnvironmentMonitor::monitor_namespace_
std::string monitor_namespace_
Definition: environment_monitor.h:196
tesseract_environment::EnvironmentMonitor::shutdown
virtual void shutdown()=0
Shutdown advertised services.
tesseract_environment::EnvironmentMonitor::getNamespace
virtual const std::string & getNamespace() const
Get the namespace of this monitor.
Definition: environment_monitor.cpp:44
tesseract_environment::MonitoredEnvironmentMode
MonitoredEnvironmentMode
Definition: environment_monitor.h:40
tesseract_environment::EnvironmentMonitor::getEnvironment
virtual std::shared_ptr< Environment > getEnvironment()
Returns an threadsafe shared pointer to the current environment.
Definition: environment_monitor.cpp:50
tesseract_environment::EnvironmentMonitor::ConstPtr
std::shared_ptr< const EnvironmentMonitor > ConstPtr
Definition: environment_monitor.h:71
tesseract_environment::Environment
Definition: environment.h:71
tesseract_environment::EnvironmentMonitor::getStateUpdateFrequency
virtual double getStateUpdateFrequency() const =0
Get the maximum frequency (Hz) at which the current state of the planning scene is updated.
TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_environment::EnvironmentMonitor::stopPublishingEnvironment
virtual void stopPublishingEnvironment()=0
Stop publishing the maintained environment.
tesseract_environment::EnvironmentMonitor::setEnvironmentPublishingFrequency
virtual void setEnvironmentPublishingFrequency(double hz)=0
Set the maximum frequency at which environment are being published.
tesseract_environment::EnvironmentMonitor::env_
std::shared_ptr< tesseract_environment::Environment > env_
Definition: environment_monitor.h:195
tesseract_environment::MonitoredEnvironmentMode::DEFAULT
@ DEFAULT
The default behavior when monitoring another environment is the following.
tesseract_environment::EnvironmentMonitor::startStateMonitor
virtual void startStateMonitor(const std::string &joint_states_topic, bool publish_tf=true)=0
Start the current state monitor.
tesseract_environment::EnvironmentMonitor::startMonitoringEnvironment
virtual void startMonitoringEnvironment(const std::string &monitored_namespace, MonitoredEnvironmentMode mode=MonitoredEnvironmentMode::DEFAULT)=0
Start the monitoring of an environment topic.
macros.h
tesseract_environment::EnvironmentMonitor::waitForConnection
virtual bool waitForConnection(std::chrono::duration< double > duration=std::chrono::seconds(0)) const =0
Wait for connection to upstream environment.
tesseract_environment::EnvironmentMonitor::environment
virtual Environment & environment()
Returns an threadsafe reference to the current environment.
Definition: environment_monitor.cpp:46
tesseract_environment::EnvironmentMonitor::operator=
EnvironmentMonitor & operator=(const EnvironmentMonitor &)=default
tesseract_environment::EnvironmentMonitor::mode_
MonitoredEnvironmentMode mode_
Definition: environment_monitor.h:197
tesseract_environment::MonitoredEnvironmentMode::SYNCHRONIZED
@ SYNCHRONIZED
The synchronized behavior when monitoring another environment is the following.
tesseract_environment::EnvironmentMonitor::ConstUPtr
std::unique_ptr< const EnvironmentMonitor > ConstUPtr
Definition: environment_monitor.h:73


tesseract_environment
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:21