Getting external callbacks (SDK) called in a ROS node
Hello all;
I am trying to integrate a new sensor in a robot. This sensor provides an SDK and the way of acquiring its data is by using a callback, everytime that there are data available, the callback is called. Inside the callback it is possible to access the data. The program with the SDK has been tested and works fine, accesing the sensor callback. The problem comes when trying to integrate all thi code in ROS. ROS is attending to its framework and callbacks, and the sensor callback is not being executed. Due to the characteristics of the SDK of the sensor, I can not call the callback explicitly when I want to collect data. The library is a Windows SDK, there is not a Linux Version, so, we are using WinROS with this node...
Is there any way to make ROS attend callbacks that are not from its own environment??
UPDATE. CODE ATTACHED
#include<smart_ray/smart_ray.h>
void smartRayControlCb(const std_msgs::BoolConstPtr &msg)
{
if(msg->data)
{
initSmartRaySensor();
//captura
startSmartRayCapture();
}
else
{
stopSmartRaySensor();
}
}
int CBunknownCommand(CAMDESC* cd)
{
char msg[260];
sprintf (msg, "unknown data received. command no: 0x%02x", cd->command);
return 0;
}
int CBstatusMsg (CAMDESC* cd, int msgType, int msgdata1, int msgdata2, char *msg)
{
int Laserlight;
int Laserstatus;
int digIn[4];
int digOut[2];
int FPS;
if(msg==NULL) //No message data available
return -1;
if (msgType == MSGTYPE_CONNECTION) //Ethernet connection messages
{
if(msgdata1 == CAMERA_CONNECTED) // TCP/IP connection established
{
printf("%s.\n",msg);
sensor.connectionstate = STATE_CAMERA_CONNECTED;
return(0);
}
else // disconnected
{
printf("%s.\n",msg);
sensor.connectionstate = STATE_CAMERA_CLOSED;
return(0);
}
}
else if (msgType == MSGTYPE_INFO) // Info messages
{
printf("%s.\n",msg);
return(0);
}
else if (msgType == MSGTYPE_ERROR) // Error messages
{
printf("%s",msg);
return(1);
}
// Sensor IO and general data (sensor sends this every 200ms)
else if (msgType == MSGTYPE_DATA && msgdata1 == DATATYPE_IO)
{
digIn[0] = cd->digio_in[0];
digIn[1] = cd->digio_in[1];
digIn[2] = cd->digio_in[2];
digIn[3] = cd->digio_in[3];
// Digital output status (via CAMDESC* cd e.g. cd->digio_out[0] = DigOut0)
digOut[0] = cd->digio_out[0];
digOut[1] = cd->digio_out[1];
// Laser Status (enabled - disabled)
Laserstatus = cd->laser_status;
// Laser light on/off
Laserlight = cd->laserlight;
// Frames per second (current/last INTERNAL! framerate of the sensor)
FPS = cd->fps;
}
return 0;
}
int CBprofileImageCallback (CAMDESC* cd, int dattyp, int startX, int height, int width, void* pdata)
{
int i=0;
int k=0;
unsigned short* data = NULL;
//~ unsigned short* pDataProf = NULL;
//~ unsigned short* pDataInten = NULL;
std::vector<int16_t> pDataProf;
std::vector<int16_t> pDataInten;
//memory reservation
//~ pDataProf = (unsigned short *)malloc(width*height*sizeof(unsigned short));
//~ pDataInten = (unsigned short *)malloc(width*height*sizeof(unsigned short));
// data contents depends on settings of parameter in PROFILE_SETUP and ACQUIRE module
data = (unsigned short*) pdata;
// data includes just contour info
if (dattyp == DATATYPE_PROFILE)
{
for (i=0;i<width*height;i++)
{
pDataProf.push_back(data[i]);
}
}
else if (dattyp == DATATYPE_INTENSITY)
{
for (i=0;i<width*height;i++)
{
pDataInten.push_back(data[i]);
}
}
// data includes contour AND intensity info
// and must be separated
else if (dattyp == DATATYPE_PROFILE_PLUS_INTENSITY)
{
for (i=0;i<width*height;i ...
Could you post some example code of your node with the callback that does not get called?
Code posted...there you can have a look at the "Non-ROS" callbacks, which are not working...