I saw an issue in Orlando where we were trying to gather input from the Analog Input on the DS Software. Sometimes, it returned a null and caused a null-pointer exception. I can’t say if that is your issue but it is possible. Thanks to Andrew Schreiber for helping me track that bug down.
Thanks Bharat. I’m currently going through looking for a similar issue. Figured it must be a an improper pointer assignment, so I’m scouring through the lines hehe. Glad to know I’m on the right track.
I agree - most likely the use of a null pointer. As a general rule of C/C++ programming, this is a MUST – check all pointers before using them. ALSO if you ‘delete’ a pointer, set that pointer to NULL afterwards as well. The programming is a little more ‘verbose’, but it is SAFER. Crashing in a real-time robot is the PITS.
For instance: (Writing a sample that should be rather ‘real’ but is from memory so may come with issues…this is intended to show the use of pointer checking – not syntax and running code)
ColorImage* pImage;
pImage = NULL;
AxisCamera& cam=AxisCamera::GetInstance();
BinaryImage* pBin;
pBin = NULL;
while(IsOperatorControl())
{
if (cam.IsFreshImage())
{
pImage = cam.GetImage();
if (pImage)
{
pBin = pImage->ThresholdHSL(x,y,z,zz,p,d,NULL);
if (pBin)
{
// Do something using pBin like particle report ...
}
else
printf("ERROR: ThresholdHSL() failed.
");
}
else
printf("ERROR: GetImage() failed.
");
// Done with the image -- must dispose of it.
// But *SHOULD* also reset it to NULL so it doesn't get used accidentally.
if (pImage)
{
delete pImage;
pImage = NULL;
}
// Done with the image -- must dispose of it.
// But *SHOULD* also reset it to NULL so it doesn't get used accidentally.
if (pBin)
{
delete pBin;
pBin = NULL;
}
}
}