}
catch(const std::exception &e)
{
- RCLCPP_ERROR_STREAM(node_->get_logger(),"Exception thrown in on_init() with message: " << e.what() << "\n");
+ RCLCPP_ERROR_STREAM(node_->get_logger(),"Exception thrown in on_init() with message: " << e.what());
return CallbackReturn::ERROR;
}
g[1]=node_->get_parameter("gravity.y").get_value<double>();
g[2]=node_->get_parameter("gravity.x").get_value<double>();
- if((idsolver_=new KDL::ChainIdSolver_RNE(chain_,g)) == NULL)
+ try
+ {
+ idsolver_=std::make_unique<KDL::ChainIdSolver_RNE>(chain_,g);
+ }
+ catch(const std::exception &e)
{
- RCLCPP_ERROR(node_->get_logger(),"Failed to create ChainIDSolver_RNE.");
+ RCLCPP_ERROR_STREAM(node_->get_logger(),"Exception thrown while creating ChainIdSolver_RNE with message: " << e.what());
return CallbackReturn::ERROR;
}