|
static bool | create_directory (std::string pathDirectory) |
|
static void | out2file (std::string pathFile, std::string output) |
|
static std::vector< std::string > | getFilesInDir (std::string pathFolder) |
|
static int | binomial_coefficent (int n, int k) |
|
static std::string | getPackagePath () |
|
template<class KeyType , class ValueType > |
static std::vector< KeyType > | extract_keys (std::map< KeyType, ValueType > const &input_map) |
|
template<class T > |
static std::vector< std::string > | extract_keys_merged (std::map< std::set< std::string >, T > const &input_map, unsigned int max_string_number=0) |
| Extract all the string in the set keys of a map. More...
|
|
template<class T > |
static std::vector< std::string > | extract_keys_merged (std::map< std::pair< std::string, std::string >, T > const &input_map, unsigned int max_string_number=0) |
| See above, this is the version with pair instead of set. More...
|
|
template<typename keyType , typename valueType1 , typename valueType2 > |
bool | keys_equal (std::map< keyType, valueType1 > const &lhs, std::map< keyType, valueType2 > const &rhs) |
| Return false if two maps have different keys. More...
|
|
template<typename RetType , typename... Args> |
std::unique_ptr< RetType > | loadObject (std::string lib_name, std::string function_name, Args...args) |
| Utils to dynamically load an object. More...
|
|
static std_msgs::Float32MultiArray | eigenMatrixToFloat32MultiArray (Eigen::MatrixXd eigenMatrix) |
| Utility to fill the Float32MultiArray ROS message from an eigen matrix. More...
|
|
static std::vector< float > | eigenVectorToStdVector (Eigen::VectorXd eigenVector) |
|
static Eigen::MatrixXd | yamlMatrixToEigen (const YAML::Node &matrixNode) |
| given a yaml node with a structure like More...
|
|
static Eigen::VectorXd | yamlVectorToEigen (const YAML::Node &vectorNode) |
|
static std_msgs::Float32MultiArray ROSEE::Utils::eigenMatrixToFloat32MultiArray |
( |
Eigen::MatrixXd |
eigenMatrix | ) |
|
|
static |
Utility to fill the Float32MultiArray ROS message from an eigen matrix.
The Float32MultiArray matrix will be stored in column major, independently from the eigen matrix that can be row major (even by default eigen matrix is column major, it can be templatizate specifing the row major)
Definition at line 19 of file UtilsEigen.h.
21 std_msgs::Float32MultiArray rosMatrix;
23 unsigned int nRow = eigenMatrix.rows();
24 unsigned int nCol = eigenMatrix.cols();
25 unsigned int size = nRow*nCol;
28 std::cerr <<
"[Utils::eigenMatrixToFloat32MultiArray] eigenMatrix passed has size 0" << std::endl;
32 rosMatrix.layout.dim.push_back(std_msgs::MultiArrayDimension());
33 rosMatrix.layout.dim.push_back(std_msgs::MultiArrayDimension());
34 rosMatrix.layout.dim[0].label =
"column";
35 rosMatrix.layout.dim[0].size = nCol;
36 rosMatrix.layout.dim[0].stride = nCol*nRow;
38 rosMatrix.layout.dim[1].label =
"row";
39 rosMatrix.layout.dim[1].size = nRow;
40 rosMatrix.layout.dim[1].stride = nRow;
42 rosMatrix.layout.data_offset = 0;
44 rosMatrix.data.resize(size);
46 for (
int iCol=0; iCol<nCol; iCol++){
47 for (
int iRow=0; iRow<nRow; iRow++){
49 rosMatrix.data.at(posRow + iRow) = eigenMatrix(iRow,iCol);
template<typename keyType , typename valueType1 , typename valueType2 >
bool ROSEE::Utils::keys_equal |
( |
std::map< keyType, valueType1 > const & |
lhs, |
|
|
std::map< keyType, valueType2 > const & |
rhs |
|
) |
| |
Return false if two maps have different keys.
The type of the keys (typename
) must be the same obviously, but the values (valueType1
and valueType2
) can be anything, because they are not considered
Definition at line 182 of file Utils.h.
184 auto pred = [] (decltype(*lhs.begin()) a, decltype(*rhs.begin()) b)
185 {
return (a.first == b.first); };
188 return lhs.size() == rhs.size()
189 && std::equal(lhs.begin(), lhs.end(), rhs.begin(), pred);
template<typename RetType , typename... Args>
std::unique_ptr<RetType> ROSEE::Utils::loadObject |
( |
std::string |
lib_name, |
|
|
std::string |
function_name, |
|
|
Args... |
args |
|
) |
| |
Utils to dynamically load an object.
This is used to dynamically load a derived object from a node that only knows the base interface. For example, we call the create_object(ros::nodeHandle) method of a derived EEHAL class The object must be a library which will return a RetType pointer with the function_name
This function will "convert" to smart pointer for convenience
- Parameters
-
lib_name | the name of the compiled library (eg DummyHal). Do not add the suffix .so |
function_name | The method of |
lib_name | which will return a RetType*. |
args | arguments for the function_name , if the case |
- Returns
- std::shared_ptr<RetType> a pointer to the new created object
Definition at line 228 of file Utils.h.
232 if (lib_name.empty()) {
234 std::cerr <<
"[Utils::loadObject] ERROR: Please specify lib_name" << std::endl;
238 std::string lib_name_path =
"lib" + lib_name +
".so";
243 void* lib_handle = dlopen(lib_name_path.c_str(), RTLD_LAZY);
244 auto error = dlerror();
246 if (!lib_handle || error != NULL) {
247 std::cerr <<
"[Utils::loadObject] ERROR in opening the library: " << error << std::endl;
254 RetType* (*function)(Args... args);
255 function =
reinterpret_cast<RetType* (*)(Args... args)
>(dlsym(lib_handle, function_name.c_str()));
257 if ( error != NULL) {
258 std::cerr <<
"[Utils::loadObject] ERROR in returning the function: " << error << std::endl;
262 RetType* objectRaw =
function(args...);
264 std::unique_ptr<RetType> objectPtr(objectRaw);