ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What is the difference in how you assign these node parameters? (C++)

asked 2022-12-20 08:45:23 -0500

Vicente Queiroz gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-12-21 06:14:55 -0500

Mike Scheutzow gravatar image

updated 2022-12-21 06:19:06 -0500

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.

edit flag offensive delete link more

Comments

Thanks for the answer and the convention advice!

Vicente Queiroz gravatar image Vicente Queiroz  ( 2022-12-22 04:31:12 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-12-20 08:45:23 -0500

Seen: 49 times

Last updated: Dec 21 '22