Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/wwwroot/phxin.top/usr/themes/Joe/public/config.php on line 19

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/wwwroot/phxin.top/usr/themes/Joe/public/config.php on line 20

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/wwwroot/phxin.top/usr/themes/Joe/public/config.php on line 21

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/wwwroot/phxin.top/usr/themes/Joe/public/config.php on line 22

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/wwwroot/phxin.top/usr/themes/Joe/public/config.php on line 23
参数设置 - Hello World

参数设置

清歌
2022-12-13 / 0 评论 / 0 阅读 / 正在检测是否收录...

直接设置参数

启动乌龟显示节点,并设置参数 A = 100

rosrun turtlesim turtlesim_node _A:=100
launch文件设置参数
<launch>
    <!-- 全局>
    <param name="radius" value="0.2" />
    <node pkg="turtlesim" type="turtlesim_node" name="t1" ns="xxx">
    <!-- 私有>
    <param name="radius" value="0.08"/>
    </node>
 </launch>
编码设置参数
#include "ros/ros.h"
int main(int argc, char  *argv[])
{
    ros::init(argc,argv,"world");
/*
        使用ros::param 来设置参数
*/

//全局参数
ros::param::set("/radiusA",100);
//相对参数
ros::param::set("radiusB",100);
//私有参数
ros::param::set("~radiusC",100);

/*
        使用Nodehandle 来设置参数
*/
ros::NodeHandle nh;   
//全局参数
nh.setParam("/radius_nh_X",1000);
//相对参数
nh.setParam("radius_nh_Y",1000);
//私有参数
ros::NodeHandle nh_private ("~");
nh_private.setParam("radius_nh_Z",1000);

    return 0;
}

请输入图片描述

0

评论 (0)

取消