目录
一、参数名获取
二、参数修改
1、代码修改
C++
python
2、命令行修改
3、启动时修改
4、launch文件传参修改
一、参数名获取
rosparam list
二、参数修改
1、代码修改
C++
#include "ros/ros.h"
int main(int argc, char *argv[])
{
ros::init(argc,argv,"haha");
ros::NodeHandle nh("turtlesim");
//ros::NodeHandle nh;
// ros::param::set("/turtlesim/background_r",0);
// ros::param::set("/turtlesim/background_g",0);
// ros::param::set("/turtlesim/background_b",0);
nh.setParam("background_r",0);
nh.setParam("background_g",0);
nh.setParam("background_b",0);
return 0;
}
python
#! /usr/bin/env python
import rospy
if __name__ == "__main__":
rospy.init_node("hehe")
# rospy.set_param("/turtlesim/background_r",255)
# rospy.set_param("/turtlesim/background_g",255)
# rospy.set_param("/turtlesim/background_b",255)
rospy.set_param("background_r",255)
rospy.set_param("background_g",255)
rospy.set_param("background_b",255)
2、命令行修改
rosparam set /turtlesim/background_b 自定义数值
3、启动时修改
rosrun turtlesim turtlesim_node _background_r:=100 _background_g=0 _background_b=0
4、launch文件传参修改
<launch>
<node pkg="turtlesim" type="turtlesim_node" name="set_bg" output="screen">
<!-- launch 传参策略 -->
<param name="background_b" value="0" type="int" />
<param name="background_g" value="0" type="int" />
<param name="background_r" value="0" type="int" />
</node>
</