ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I believe that the problem is that in your launch file, the params are all private params (as they are in the node tag). Therefore you can either declare a private nodehandle i.e. your first line of C++ would read
ros::NodeHandle p_nh("~");
or you could use the other "bare" versions from the API i.e. your parameter calls would read something like
ros::param::param<string>("~KI", KI, "240");
2 | No.2 Revision |
I believe that the problem is that in your launch file, the params are all private params (as they are in the node tag). Therefore you can either declare a private nodehandle i.e. your first line of C++ would read
ros::NodeHandle p_nh("~");
or you could use the other "bare" versions from the API i.e. your parameter calls would read something like
ros::param::param<string>("~KI", KI, "240");
Here's a complete C++ file that does it both ways:
#include <ros/ros.h>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
ros::init(argc, argv, "test");
ros::NodeHandle nh("~");
string KP = "1000";
string KI = "240";
nh.param<std::string>("KP", KP, "1000");
ros::param::param<string>("~KI", KI, "240");
ROS_INFO("KP = %s", KP.c_str());
ROS_INFO("KI = %s", KI.c_str());
return 0;
}
3 | No.3 Revision |
I believe that the problem is that in your launch file, the params are all private params (as they are in the node tag). Therefore you can either declare a private nodehandle i.e. your first line of C++ would read
ros::NodeHandle p_nh("~");
or you could use the "bare" versions from the API i.e. your parameter calls would read something like
ros::param::param<string>("~KI", KI, "240");
Here's a complete C++ file that does it both ways:
#include <ros/ros.h>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
ros::init(argc, argv, "test");
ros::NodeHandle nh("~");
string KP = "1000";
string KI = "240";
nh.param<std::string>("KP", nh.param<string>("KP", KP, "1000");
ros::param::param<string>("~KI", KI, "240");
ROS_INFO("KP = %s", KP.c_str());
ROS_INFO("KI = %s", KI.c_str());
return 0;
}