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)
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.\n");
}
else
printf("ERROR: GetImage() failed.\n");
// 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;
}
}
}