参考:ROS向节点传递参数的方法总结(rosrun,launch) + (参数服务器,main函数参数)https://blog.csdn.net/u013834525/article/details/88744327
rosrun 向 参数服务器
rosrun package node _param:=value
param前加 "_"
roslaunch 向 参数服务器
使用param标签
<launch>
<node name="imu2txt" pkg="data2txt" type="imu2txt" respawn="false" output="screen" >
<param name="file_name" type="string" value="/home/night_fury/Documents/record_bags/calibration/imudata_to_wall.txt"/>
</node>
</launch>
rosrun 向 main()
直接在后边添加
rosrun package node p1 p2 p3
roslaunch 向 main()
在 node标签中,使用 args
<node pkg="ros_tutorials_parameter" type="service_client_with_parameter" name="service_client" args="6 8">
<param name="calculation_method" value="2"/>
<launch>
<node name="map_server" pkg="map_server" type="map_server" args="(findcostmap2d)/test/willow−full−0.025.pgm 0.025"/>
<node name="rosplay"pkg="rosbag"type="play"args="−s 5 −r 1 −−clock −−hz=10 (find costmap_2d)/test/simple_driving_test_indexed.bag" />
</launch>