forked from robotology/yarp-devices-ros2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ParamsParser to RgbdSensor_nws_ros2
Signed-off-by: Ettore Landini <[email protected]>
- Loading branch information
1 parent
502cc7c
commit 7bd138a
Showing
6 changed files
with
315 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
src/devices/rgbdSensor_nws_ros2/RgbdSensor_nws_ros2_ParamsParser.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) | ||
* SPDX-License-Identifier: LGPL-2.1-or-later | ||
*/ | ||
|
||
|
||
// Generated by yarpDeviceParamParserGenerator (1.0) | ||
// This is an automatically generated file. Please do not edit it. | ||
// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON. | ||
|
||
// Generated on: Mon Sep 2 10:47:31 2024 | ||
|
||
|
||
#include "RgbdSensor_nws_ros2_ParamsParser.h" | ||
#include <yarp/os/LogStream.h> | ||
#include <yarp/os/Value.h> | ||
|
||
namespace { | ||
YARP_LOG_COMPONENT(RgbdSensor_nws_ros2ParamsCOMPONENT, "yarp.device.RgbdSensor_nws_ros2") | ||
} | ||
|
||
|
||
RgbdSensor_nws_ros2_ParamsParser::RgbdSensor_nws_ros2_ParamsParser() | ||
{ | ||
} | ||
|
||
|
||
std::vector<std::string> RgbdSensor_nws_ros2_ParamsParser::getListOfParams() const | ||
{ | ||
std::vector<std::string> params; | ||
params.push_back("period"); | ||
params.push_back("node_name"); | ||
params.push_back("color_topic_name"); | ||
params.push_back("depth_topic_name"); | ||
params.push_back("force_info_synch"); | ||
params.push_back("depth_frame_id"); | ||
params.push_back("color_frame_id"); | ||
return params; | ||
} | ||
|
||
|
||
bool RgbdSensor_nws_ros2_ParamsParser::parseParams(const yarp::os::Searchable & config) | ||
{ | ||
//Check for --help option | ||
if (config.check("help")) | ||
{ | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << getDocumentationOfDeviceParams(); | ||
} | ||
|
||
std::string config_string = config.toString(); | ||
yarp::os::Property prop_check(config_string.c_str()); | ||
//Parser of parameter period | ||
{ | ||
if (config.check("period")) | ||
{ | ||
m_period = config.find("period").asFloat64(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using value:" << m_period; | ||
} | ||
else | ||
{ | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'period' using DEFAULT value:" << m_period; | ||
} | ||
prop_check.unput("period"); | ||
} | ||
|
||
//Parser of parameter node_name | ||
{ | ||
if (config.check("node_name")) | ||
{ | ||
m_node_name = config.find("node_name").asString(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'node_name' using value:" << m_node_name; | ||
} | ||
else | ||
{ | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'node_name' not found!"; | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: name of the ros2 node"; | ||
return false; | ||
} | ||
prop_check.unput("node_name"); | ||
} | ||
|
||
//Parser of parameter color_topic_name | ||
{ | ||
if (config.check("color_topic_name")) | ||
{ | ||
m_color_topic_name = config.find("color_topic_name").asString(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'color_topic_name' using value:" << m_color_topic_name; | ||
} | ||
else | ||
{ | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'color_topic_name' not found!"; | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: ros rgb topic (it's also the base name for the rgb camera_info topic)"; | ||
return false; | ||
} | ||
prop_check.unput("color_topic_name"); | ||
} | ||
|
||
//Parser of parameter depth_topic_name | ||
{ | ||
if (config.check("depth_topic_name")) | ||
{ | ||
m_depth_topic_name = config.find("depth_topic_name").asString(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'depth_topic_name' using value:" << m_depth_topic_name; | ||
} | ||
else | ||
{ | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'depth_topic_name' not found!"; | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: ros depth topic (it's also the base name for the depth camera_info topic)"; | ||
return false; | ||
} | ||
prop_check.unput("depth_topic_name"); | ||
} | ||
|
||
//Parser of parameter force_info_synch | ||
{ | ||
if (config.check("force_info_synch")) | ||
{ | ||
m_force_info_synch = config.find("force_info_synch").asInt64(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'force_info_synch' using value:" << m_force_info_synch; | ||
} | ||
else | ||
{ | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'force_info_synch' using DEFAULT value:" << m_force_info_synch; | ||
} | ||
prop_check.unput("force_info_synch"); | ||
} | ||
|
||
//Parser of parameter depth_frame_id | ||
{ | ||
if (config.check("depth_frame_id")) | ||
{ | ||
m_depth_frame_id = config.find("depth_frame_id").asString(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'depth_frame_id' using value:" << m_depth_frame_id; | ||
} | ||
else | ||
{ | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'depth_frame_id' not found!"; | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The depth image frame"; | ||
return false; | ||
} | ||
prop_check.unput("depth_frame_id"); | ||
} | ||
|
||
//Parser of parameter color_frame_id | ||
{ | ||
if (config.check("color_frame_id")) | ||
{ | ||
m_color_frame_id = config.find("color_frame_id").asString(); | ||
yCInfo(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Parameter 'color_frame_id' using value:" << m_color_frame_id; | ||
} | ||
else | ||
{ | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Mandatory parameter 'color_frame_id' not found!"; | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "Description of the parameter: The color image frame"; | ||
return false; | ||
} | ||
prop_check.unput("color_frame_id"); | ||
} | ||
|
||
/* | ||
//This code check if the user set some parameter which are not check by the parser | ||
//If the parser is set in strict mode, this will generate an error | ||
if (prop_check.size() > 0) | ||
{ | ||
bool extra_params_found = false; | ||
for (auto it=prop_check.begin(); it!=prop_check.end(); it++) | ||
{ | ||
if (m_parser_is_strict) | ||
{ | ||
yCError(RgbdSensor_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!"; | ||
extra_params_found = true; | ||
} | ||
else | ||
{ | ||
yCWarning(RgbdSensor_nws_ros2ParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!"; | ||
} | ||
} | ||
if (m_parser_is_strict && extra_params_found) | ||
{ | ||
return false; | ||
} | ||
} | ||
*/ | ||
return true; | ||
} | ||
|
||
|
||
std::string RgbdSensor_nws_ros2_ParamsParser::getDocumentationOfDeviceParams() const | ||
{ | ||
std::string doc; | ||
doc = doc + std::string("\n=============================================\n"); | ||
doc = doc + std::string("This is the help for device: RgbdSensor_nws_ros2\n"); | ||
doc = doc + std::string("\n"); | ||
doc = doc + std::string("This is the list of the parameters accepted by the device:\n"); | ||
doc = doc + std::string("'period': refresh period of the broadcasted values in s\n"); | ||
doc = doc + std::string("'node_name': name of the ros2 node\n"); | ||
doc = doc + std::string("'color_topic_name': ros rgb topic (it's also the base name for the rgb camera_info topic)\n"); | ||
doc = doc + std::string("'depth_topic_name': ros depth topic (it's also the base name for the depth camera_info topic)\n"); | ||
doc = doc + std::string("'force_info_synch': if 1, it forces synching images time stamp with and cameras time stamp\n"); | ||
doc = doc + std::string("'depth_frame_id': The depth image frame\n"); | ||
doc = doc + std::string("'color_frame_id': The color image frame\n"); | ||
doc = doc + std::string("\n"); | ||
doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n"); | ||
doc = doc + " yarpdev --device rgbdSensor_nws_ros2 --period 0.02 --node_name <mandatory_value> --color_topic_name <mandatory_value> --depth_topic_name <mandatory_value> --force_info_synch 0 --depth_frame_id <mandatory_value> --color_frame_id <mandatory_value>\n"; | ||
doc = doc + std::string("Using only mandatory params:\n"); | ||
doc = doc + " yarpdev --device rgbdSensor_nws_ros2 --node_name <mandatory_value> --color_topic_name <mandatory_value> --depth_topic_name <mandatory_value> --depth_frame_id <mandatory_value> --color_frame_id <mandatory_value>\n"; | ||
doc = doc + std::string("=============================================\n\n"); return doc; | ||
} |
Oops, something went wrong.