ROSaic
Data Structures | Functions | Variables
rosaic_node Namespace Reference

Data Structures

class  ROSaicNode
 This class represents the ROsaic node, to be extended.. More...
 

Functions

template<typename V , typename T >
void checkRange (V val, T min, T max, std::string name)
 Checks whether the parameter is in the given range. More...
 
template<typename V , typename T >
void checkRange (std::vector< V > val, T min, T max, std::string name)
 Check whether the elements of the vector are in the given range. More...
 
template<typename U >
bool getROSInt (const std::string &key, U &u)
 Gets an integer or unsigned integer value from the parameter server. More...
 
template<typename U >
void getROSInt (const std::string &key, U &u, U default_val)
 Gets an integer or unsigned integer value from the parameter server. More...
 
template<typename U >
bool getROSInt (const std::string &key, std::vector< U > &u)
 Gets an unsigned integer or integer vector from the parameter server. More...
 

Variables

io_comm_rx::Comm_IO IO
 Handles communication with the Rx. More...
 

Detailed Description

This namespace is for the ROSaic node, handling all aspects regarding ROS parameters, ROS message publishing etc.

Function Documentation

◆ checkRange() [1/2]

template<typename V , typename T >
void rosaic_node::checkRange ( val,
min,
max,
std::string  name 
)

Checks whether the parameter is in the given range.

Parameters
[in]valThe value to check
[in]minThe minimum for this value
[in]maxThe maximum for this value
[in]nameThe name of the parameter
Exceptions
std::runtime_errorif it is out of bounds

Definition at line 107 of file rosaic_node.hpp.

Referenced by checkRange(), and getROSInt().

108  {
109  if(val < min || val > max)
110  {
111  std::stringstream ss;
112  ss << "Invalid settings: " << name << " must be in range [" << min << ", " << max << "].";
113  throw std::runtime_error(ss.str());
114  }
115  }
Here is the caller graph for this function:

◆ checkRange() [2/2]

template<typename V , typename T >
void rosaic_node::checkRange ( std::vector< V >  val,
min,
max,
std::string  name 
)

Check whether the elements of the vector are in the given range.

Parameters
[in]valThe vector to check
[in]minThe minimum for this value
[in]maxThe maximum for this value
[in]nameThe name of the parameter

Definition at line 125 of file rosaic_node.hpp.

References checkRange().

126  {
127  for(size_t i = 0; i < val.size(); i++)
128  {
129  std::stringstream ss;
130  ss << name << "[" << i << "]";
131  checkRange(val[i], min, max, ss.str());
132  }
133  }
void checkRange(std::vector< V > val, T min, T max, std::string name)
Check whether the elements of the vector are in the given range.
Here is the call graph for this function:

◆ getROSInt() [1/3]

template<typename U >
bool rosaic_node::getROSInt ( const std::string &  key,
U &  u 
)

Gets an integer or unsigned integer value from the parameter server.

Parameters
[in]keyThe key to be used in the parameter server's dictionary
[out]uStorage for the retrieved value, of type U, which can be either unsigned int or int
Exceptions
std::runtime_errorif the parameter is out of bounds
Returns
True if found, false if not found

Definition at line 143 of file rosaic_node.hpp.

References checkRange(), and g_nh.

Referenced by getROSInt(), rosaic_node::ROSaicNode::getROSParams(), and main().

143  {
144  int param;
145  if (!g_nh->getParam(key, param)) return false;
146  U min = std::numeric_limits<U>::lowest();
147  U max = std::numeric_limits<U>::max();
148  try
149  {
150  checkRange((U) param, min, max, key);
151  }
152  catch (std::runtime_error& e)
153  {
154  std::ostringstream ss;
155  ss << e.what();
156  ROS_INFO("%s", ss.str().c_str());
157  }
158  u = (U) param;
159  return true;
160  }
boost::shared_ptr< ros::NodeHandle > g_nh
void checkRange(std::vector< V > val, T min, T max, std::string name)
Check whether the elements of the vector are in the given range.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getROSInt() [2/3]

template<typename U >
void rosaic_node::getROSInt ( const std::string &  key,
U &  u,
default_val 
)

Gets an integer or unsigned integer value from the parameter server.

Parameters
[in]keyThe key to be used in the parameter server's dictionary
[out]uStorage for the retrieved value, of type U, which can be either unsigned int or int
[in]valValue to use if the server doesn't contain this parameter
Exceptions
std::runtime_errorif the parameter is out of bounds
Returns
True if found, false if not found

Definition at line 171 of file rosaic_node.hpp.

References getROSInt().

172  {
173  if(!getROSInt(key, u))
174  u = default_val;
175  }
bool getROSInt(const std::string &key, std::vector< U > &u)
Gets an unsigned integer or integer vector from the parameter server.
Here is the call graph for this function:

◆ getROSInt() [3/3]

template<typename U >
bool rosaic_node::getROSInt ( const std::string &  key,
std::vector< U > &  u 
)

Gets an unsigned integer or integer vector from the parameter server.

Parameters
[in]keyThe key to be used in the parameter server's dictionary
[out]uStorage for the retrieved value, of type std::vector<U>, where U can be either unsigned int or int
Exceptions
std::runtime_errorif the parameter is out of bounds
Returns
True if found, false if not found

Definition at line 185 of file rosaic_node.hpp.

References checkRange(), and g_nh.

186  {
187  std::vector<int> param;
188  if (!g_nh->getParam(key, param)) return false;
189  U min = std::numeric_limits<U>::lowest();
190  U max = std::numeric_limits<U>::max();
191  checkRange(param, min, max, key);
192  u.insert(u.begin(), param.begin(), param.end());
193  return true;
194  }
boost::shared_ptr< ros::NodeHandle > g_nh
void checkRange(std::vector< V > val, T min, T max, std::string name)
Check whether the elements of the vector are in the given range.
Here is the call graph for this function:

Variable Documentation

◆ IO

io_comm_rx::Comm_IO rosaic_node::IO

Handles communication with the Rx.

Definition at line 96 of file rosaic_node.hpp.

Referenced by rosaic_node::ROSaicNode::configureRx(), rosaic_node::ROSaicNode::defineMessages(), and rosaic_node::ROSaicNode::reconnect().