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

Don´t understand ROS::nodehandler [closed]

asked 2016-08-15 10:00:34 -0600

Rodrigo Lourenço gravatar image

I have the following code.

double globalResizingFactor; ros::init(argc, argv, "image_listener"); ros::NodeHandle nh; ...

if (!nh.getParam("resizing_factor", globalResizingFactor)) { ROS_ERROR (" .... "); ros::shutdown(); }

This code compiles with no problems, but it is a transition from a old ROS distribution to a more recente one, this is, Fuerte to Hydro, both are very diferent, a made a huge problem to be solved, the fact is that I was able to change e few things and compile.

When Runing It stops here, at this if, since the globalResizingFactor isn´t got, it fails. Please some help understanding what´s hapening in this code.


edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by Rodrigo Lourenço
close date 2016-08-23 06:17:51.689651

1 Answer

Sort by » oldest newest most voted

answered 2016-08-15 15:32:37 -0600

ghkraju gravatar image

nh.getParam("variable", variable in class) will get the values from your launch file or you have to pass the value when you launch your node something like rosrun [package_name] [node_name] [variable="resizing_factor"] (don't use [] that is just for your understanding)

In your case, probably the values are not getting passed while launching the node so it falls in ROS_ERROR. Please try the above method or use a launch file.

For launch file, follow this link: Refer 5.1 and 5.3 I hope this will help to solve your problem.

edit flag offensive delete link more


You´re right, that was the problem. Thanks.

Rodrigo Lourenço gravatar image Rodrigo Lourenço  ( 2016-08-18 17:46:51 -0600 )edit

Nice to hear that..... You can mark it as answered in that case.

ghkraju gravatar image ghkraju  ( 2016-08-19 04:03:20 -0600 )edit

How do I mark answered?

Rodrigo Lourenço gravatar image Rodrigo Lourenço  ( 2016-08-19 04:50:58 -0600 )edit

I am new too here.... I think you can click the tick mark on the left side of the comment(answer provided).

ghkraju gravatar image ghkraju  ( 2016-08-19 06:05:28 -0600 )edit

Question Tools

1 follower


Asked: 2016-08-15 10:00:34 -0600

Seen: 339 times

Last updated: Aug 15 '16