I am trying to set some parameters in node through launch file as below:

asked 2023-01-04 00:45:58 -0500

Basma gravatar image

In launch file the setting is as follow:

    <node pkg="floam" type="floam_laser_processing_node" name="floam_laser_processing_node" output="screen">
        <param name="base_link" type="string" value="$(arg robot_name)/base_link"/>
         <remap from= "/laser_cloud_edge" to= "/$(arg robot_name)/laser_cloud_edge"/>
        <remap from= "/laser_cloud_surf" to= "/$(arg robot_name)/laser_cloud_surf"/>
 <remap from= "/velodyne_points" to= "/$(arg robot_name)/velodyne_points"/>
        </node>

and In the node.cpp file I got the parameter base_link correctly in the main section:

 main(){
     ros::NodeHandle nh_private("~");
     nh_private.getParam("base_link", base_link);
     ROS_INFO("base_frame is: %s  \n \n",base_link.c_str());
     ros::Subscriber subLaserCloud = nh.subscribe<sensor_msgs::PointCloud2>("/velodyne_points", 100, velodyneHandler);
std::thread laser_processing_process{laser_processing};
    }

but in the called function the base_link parameter didnot set correctly . it is empty. How can solve the problem.??

void laser_processing(){
...
 laserCloudFilteredMsg.header.frame_id = base_link;
....
}
edit retag flag offensive close merge delete

Comments

is your base_link variable global? You're not giving a lot of information here. Provide full file contents for best response quality.

kacaroll gravatar image kacaroll  ( 2023-01-04 20:16:34 -0500 )edit