I have surrounded an arena of 10x10 boxes in Argos2 simulator.
According to arena, i made an array of [10]X[10]. I write code for declaration of array in my header file as private attribute.
Code: Select all
Real DataStorageArray[10][10];
Code: Select all
for( int w=-2;w<=6;w++)
{
if(w==0)
{
for( int x=4;x>=-4;x--)
{
if(x==-1)
{
DataStorageArray[-0][-0]=0.0f;
printf("%s%f"," ", DataStorageArray[-0][-0]);
}
DataStorageArray[-0][x]=0.0f;
printf("%s%f"," ", DataStorageArray[-0][x]);
}
printf("\n\n\n");
}
for( int y=4;y>=-4;y--)
{
if(y==-1)
{
DataStorageArray[w][-0]=0.0f;
printf("%s%f"," ", DataStorageArray[w][-0]);
}
DataStorageArray[w][y]=0.0f;
printf("%s%f"," ", DataStorageArray[w][y]);
}
printf("\n\n\n");
}
When i start simulation step by step, then after first step, i get the following output. And this is my correct output as i code.
Code: Select all
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
But when i press button for next step from Argos Simulator, then i get the following error.
Segmentation fault (core dumped)
What is the reason behind this? If there had been an error in my code, then it shouldn't work even on first step.
Why it is showing an error while on second step and why it is giving correct output first time?
Thanks