0
$\begingroup$

Rosanswers logo

I have a node and I want assign 2 parameters from the Parameter Server. They are both strings:

nh.param("robot_frame", robotFrame, std::string("/base_link"));
nh.param<std::string>("world_frame", worldFrame, "/map");

When I compile, everything is OK. What I'm curious about is what is the underlying difference on how these 2 parameters are assigned? Or there is no difference at all?

Thanks!


Originally posted by Vicente Queiroz on ROS Answers with karma: 3 on 2022-12-20

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Both versions call the same templated method in nh. For the first version, the c++ compiler will guess the typename by looking at the types of the 2nd and 3rd arguments.

P.S. Unrelated to your question, but for years now, the ros convention is to not use a leading slash on a frame name.


Originally posted by Mike Scheutzow with karma: 4903 on 2022-12-21

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Vicente Queiroz on 2022-12-22:
Thanks for the answer and the convention advice!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.