Command line argument passing in rosrun
Hi All,
I am trying to pass the command line arguments while running
rosrun <package> <node> <parameter>
So that a particular block of code could be executed based on the parameter.
Below is the approach.
int main(int argc, char *argv[])
{
std::string param;
ros::init(argc, argv, "node_name");
ros::NodeHandle nh("~");
ROS_INFO("Got parameter : %s", param.c_str());
if(nh.getParam("blue", param))
{
blue(); //Run program blue
}
else if(nh.getParam("green", param))
{
green();
}
else
{
cout << "Don't run anything !! " << endl;
}
return 0;
}
Also when I try to print the value of param it shows nothing.
Can anybody help me to fix this please.
Thank you, KK