ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I was able to get the expected result by updating the code as given below.
int main(int argc, char *argv[])
{
ros::init(argc, argv, "node_name");
std::string param;
ros::NodeHandle nh("~");
std::string check;
nh.getParam("param", check);
cout << check << endl;
ROS_INFO("Got parameter : %s", check.c_str());
if(check.compare("blue") == 0)
{
cout << check << endl;
blue();
}
else if(check.compare("greeen") == 0)
{
cout << check << endl;
green();
}
else
{
cout << "Control has come out !!! " << endl;
}
return 0;
}
command to run rosrun package node_name _param:=blue rosrun package node_name _param:=green
2 | No.2 Revision |
I was able to get the expected result by updating the code as given below.
int main(int argc, char *argv[])
{
ros::init(argc, argv, "node_name");
std::string param;
ros::NodeHandle nh("~");
std::string check;
nh.getParam("param", check);
cout << check << endl;
ROS_INFO("Got parameter : %s", check.c_str());
if(check.compare("blue") == 0)
{
cout << check << endl;
blue();
}
else if(check.compare("greeen") == 0)
{
cout << check << endl;
green();
}
else
{
cout << "Control has come out !!! " << endl;
}
return 0;
}
command to run
rosrun package node_name _param:=blue
rosrun package node_name _param:=green _param:=green