calling a service from an other file on the same machine
Hello guys, I am a newbie to ROS, I am trying to make my ARDRONE more intelligent by using Brown's package for ARDRONE.T I I need to call this service :
bool toggleCamCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response)
{
if (cam_state == 0) // toggle to 1, the vertical camera
{
cam_state = 1;
#ifdef _USING_SDK_1_7_
ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_channel, &cam_state, NULL);
#else
ardrone_at_set_toy_configuration("video:video_channel","1");
#endif
fprintf(stderr, "\nToggling from frontal camera to vertical camera.\n");
}
else if (cam_state == 1) // toggle to the forward camera
{
cam_state = 0;
#ifdef _USING_SDK_1_7_
ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_channel, &cam_state, NULL);
#elsebool toggleCamCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response)
{
if (cam_state == 0) // toggle to 1, the vertical camera
{
cam_state = 1;
#ifdef _USING_SDK_1_7_
ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_channel, &cam_state, NULL);
#else
ardrone_at_set_toy_configuration("video:video_channel","1");
#endif
fprintf(stderr, "\nToggling from frontal camera to vertical camera.\n");
}
else if (cam_state == 1) // toggle to the forward camera
{
cam_state = 0;
#ifdef _USING_SDK_1_7_
ARDRONE_TOOL_CONFIGURATION_ADDEVENT (video_channel, &cam_state, NULL);
#else
ardrone_at_set_toy_configuration("video:video_channel","0");
#endif
fprintf(stderr, "\nToggling from vertical camera to frontal camera.\n");
}
return true;
}
ardrone_at_set_toy_configuration("video:video_channel","0");
#endif
fprintf(stderr, "\nToggling from vertical camera to frontal camera.\n");
}
return true;
}
I was able to invoke the service by entering the command: "rosservice call/ardrone/togglecam"*
But ,I am trying to find a way to call the service from other file(so that I can toggle between the cameras easily) please help!!!!!