TraveSim Adapters  0.1
Protobuf adapters for TraveSim project
travesim::AdapterConfigurer< AdapterConfigType > Class Template Reference

#include "adapter_configurer.hpp"

Inheritance diagram for travesim::AdapterConfigurer< AdapterConfigType >:
Collaboration diagram for travesim::AdapterConfigurer< AdapterConfigType >:

Public Member Functions

 AdapterConfigurer (void)
 Construct a new AdapterConfigurer object. More...
 
 AdapterConfigurer (std::string config_namespace)
 Construct a new AdapterConfigurer object. More...
 
bool get_reset (void)
 Get the reset config. More...
 

Protected Attributes

bool reconfigured
 
AdapterConfigType config
 
boost::recursive_mutex mutex
 

Private Member Functions

void callback (AdapterConfigType &config, uint32_t level)
 Dynamic Reconfigure Server Callback. More...
 

Private Attributes

std::unique_ptr< ros::NodeHandle > node_handle
 
std::unique_ptr< dynamic_reconfigure::Server< AdapterConfigType > > server
 

Detailed Description

template<class AdapterConfigType>
class travesim::AdapterConfigurer< AdapterConfigType >

Definition at line 35 of file adapter_configurer.hpp.

Constructor & Destructor Documentation

◆ AdapterConfigurer() [1/2]

template<class AdapterConfigType >
travesim::AdapterConfigurer< AdapterConfigType >::AdapterConfigurer ( void  )

Construct a new AdapterConfigurer object.

Note
The base namespace is used

Definition at line 85 of file adapter_configurer.hpp.

87 }
AdapterConfigurer(void)
Construct a new AdapterConfigurer object.
#define BASE_CONFIGURER_NAMESPACE

◆ AdapterConfigurer() [2/2]

template<class AdapterConfigType >
travesim::AdapterConfigurer< AdapterConfigType >::AdapterConfigurer ( std::string  config_namespace)

Construct a new AdapterConfigurer object.

Parameters
config_namespaceNamespace of the adapter configurer

Definition at line 90 of file adapter_configurer.hpp.

90  {
91  this->reconfigured = false;
92 
93  this->node_handle = std::unique_ptr<ros::NodeHandle>(new ros::NodeHandle(config_namespace));
94 
95  using server_t = dynamic_reconfigure::Server<AdapterConfigType>;
96  this->server = std::unique_ptr<server_t>(new server_t(this->mutex, *(this->node_handle)));
97 
98  typename server_t::CallbackType server_cb;
99  server_cb = boost::bind(&AdapterConfigurer::callback, this, _1, _2);
100  this->server->setCallback(server_cb);
101 
102  // Update the default config in the dynamic reconfigurer
103  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
104  this->server->getConfigDefault(this->config);
105  this->server->updateConfig(this->config);
106 }
void callback(AdapterConfigType &config, uint32_t level)
Dynamic Reconfigure Server Callback.
std::unique_ptr< dynamic_reconfigure::Server< AdapterConfigType > > server
std::unique_ptr< ros::NodeHandle > node_handle
boost::recursive_mutex mutex

Member Function Documentation

◆ callback()

template<class AdapterConfigType>
void travesim::AdapterConfigurer< AdapterConfigType >::callback ( AdapterConfigType &  config,
uint32_t  level 
)
private

Dynamic Reconfigure Server Callback.

Parameters
configNew config received
levelResult of doing an "OR" operation between all of level values of the parameters that have changed

Definition at line 132 of file adapter_configurer.hpp.

132  {
133  this->config = config;
134  this->reconfigured = true;
135 }

◆ get_reset()

template<class AdapterConfigType >
bool travesim::AdapterConfigurer< AdapterConfigType >::get_reset ( void  )

Get the reset config.

Returns
true if should reset, false otherwise

Definition at line 109 of file adapter_configurer.hpp.

109  {
110  bool should_reset = this->config.reset || this->reconfigured;
111 
112  if (should_reset) {
113  boost::recursive_mutex::scoped_lock scoped_lock(this->mutex);
114 
115  this->reconfigured = false;
116 
117  this->config.reset = this->reconfigured;
118 
119  this->server->updateConfig(this->config);
120 
121  return true;
122  }
123 
124  return false;
125 }
std::unique_ptr< dynamic_reconfigure::Server< AdapterConfigType > > server
boost::recursive_mutex mutex
Here is the caller graph for this function:

Member Data Documentation

◆ config

template<class AdapterConfigType>
AdapterConfigType travesim::AdapterConfigurer< AdapterConfigType >::config
protected

Current config

Definition at line 61 of file adapter_configurer.hpp.

◆ mutex

template<class AdapterConfigType>
boost::recursive_mutex travesim::AdapterConfigurer< AdapterConfigType >::mutex
protected

Dynamic Reconfigure Server Mutex for thread-safety

Definition at line 63 of file adapter_configurer.hpp.

◆ node_handle

template<class AdapterConfigType>
std::unique_ptr<ros::NodeHandle> travesim::AdapterConfigurer< AdapterConfigType >::node_handle
private

Pointer to ROS Node Handle

Definition at line 66 of file adapter_configurer.hpp.

◆ reconfigured

template<class AdapterConfigType>
bool travesim::AdapterConfigurer< AdapterConfigType >::reconfigured
protected

Whether the configs where changed or not

Definition at line 59 of file adapter_configurer.hpp.

◆ server

template<class AdapterConfigType>
std::unique_ptr<dynamic_reconfigure::Server<AdapterConfigType> > travesim::AdapterConfigurer< AdapterConfigType >::server
private

Dynamic Reconfigure Server

Definition at line 68 of file adapter_configurer.hpp.


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