Skip to content

Commit

Permalink
redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrhm committed Sep 15, 2024
1 parent 06c768f commit c3c555d
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions parameter_utils/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,35 @@ namespace mrover {
std::visit(overload{
[&](int* arg){
try{
if(std::holds_alternative<int*>(mData)){
*arg = static_cast<int>(node->get_parameter(mParamDescriptor).as_int());
}else{
throw std::runtime_error("Parameter has wrong type!");
}
*arg = static_cast<int>(node->get_parameter(mParamDescriptor).as_int());
}catch(rclcpp::exceptions::ParameterUninitializedException& e){
*arg = 0;
}
},
[&](std::string* arg){
try{
if(std::holds_alternative<std::string*>(mData)){
*arg = node->get_parameter(mParamDescriptor).as_string();
}else{
throw std::runtime_error("Parameter has wrong type!");
}
}catch(rclcpp::exceptions::ParameterUninitializedException& e){
*arg = std::string();
}
},
[&](bool* arg){
try{
if(std::holds_alternative<bool*>(mData)){
*arg = node->get_parameter(mParamDescriptor).as_bool();
}else{
throw std::runtime_error("Parameter has wrong type!");
}
*arg = node->get_parameter(mParamDescriptor).as_bool();
}catch(rclcpp::exceptions::ParameterUninitializedException& e){
*arg = false;
}
},
[&](double* arg){
try{
if(std::holds_alternative<double*>(mData)){
*arg = node->get_parameter(mParamDescriptor).as_double();
}else{
throw std::runtime_error("Parameter has wrong type!");
}
*arg = node->get_parameter(mParamDescriptor).as_double();
}catch(rclcpp::exceptions::ParameterUninitializedException& e){
*arg = 0.0;
}
},
[&](float* arg){
try{
if(std::holds_alternative<float*>(mData)){
*arg = static_cast<float>(node->get_parameter(mParamDescriptor).as_double());
}else{
throw std::runtime_error("Parameter has wrong type!");
}
*arg = static_cast<float>(node->get_parameter(mParamDescriptor).as_double());
}catch(rclcpp::exceptions::ParameterUninitializedException& e){
*arg = 0.0;
}
Expand Down

0 comments on commit c3c555d

Please sign in to comment.