Ask Your Question

Revision history [back]

if (ros::param::has("/rateFilterUWB")) {
    ros::param::get("/rateFilterUWB", rateFilterUWB);
    ros::Rate loop_rate(rateFilterUWB);
}
else
ros::Rate loop_rate(100);

Your issue is right here -- you have scoped the definition of the loop_rate variable.

You could use a default value parameter to fix this.

double rate;
ros::param::param<double>("/rateFilterUWB", rate, 100);

if (ros::param::has("/rateFilterUWB")) { ros::param::get("/rateFilterUWB", rateFilterUWB); ros::Rate loop_rate(rateFilterUWB); } else ros::Rate loop_rate(100);

loop_rate(100);

Your issue is right here -- you have scoped the definition of the loop_rate variable.

You could use a default value parameter to fix this.

double rate;
ros::param::param<double>("/rateFilterUWB", rate, 100);

See here for more information.