Пример #1
0
static int
Velodyne_init(Velodyne *self, PyObject *args, PyObject *kwds)
{
    PyObject *images;
	char* poster_name;

    if (!PyArg_ParseTuple(args, "snnn", &poster_name, &(self->width), &(self->height), &(self->nb_rot)))
		return -1;

	size_t poster_size = sizeof(velodyne3DImage);

	STATUS s = posterCreate (poster_name, poster_size, &self->id);
	if (s == ERROR)
	{
		char buf[1024];
		h2getErrMsg(errnoGet(), buf, sizeof(buf));
		printf ("Unable to create the %s poster : %s\n",poster_name, buf);
		return -1;
	}

	printf("Succesfully created poster %s of size %zd\n", poster_name, poster_size); 

	self->size = self->width * self->height;

	self->img.width = VELODYNE_3D_IMAGE_WIDTH;
	self->img.maxScanWidth = VELODYNE_3D_IMAGE_WIDTH;
	self->img.height = (int)(ceil)(self->size * self->nb_rot / VELODYNE_3D_IMAGE_WIDTH);

	self->current_rot = 0;

    return 0;
}
Пример #2
0
POSTER_ID init_data (const char* poster_name, const char* reference_frame, 
					 float confidence, int* ok)
{
	POSTER_ID id;

	STATUS s = posterCreate (poster_name, sizeof(POM_ME_POS), &id);
	if (s == ERROR)
	{
		char buf[1024];
		h2getErrMsg(errnoGet(), buf, sizeof(buf));
		printf ("Unable to create the %s poster : %s\n", poster_name, buf);
        *ok = 0;
		return (NULL);
	}

	printf ("INIT ID = %p (pointer)\n", id);
	ref_name = strdup(reference_frame);

	POM_ME_POS* pos = posterAddr(id);
	memset(pos, 0, sizeof(POM_ME_POS));
	pos->kind = POM_ME_ABSOLUTE;
	pos->confidence = confidence;

    *ok = 1;

	return (id);
}
Пример #3
0
/*
 * Create a poster, and fill it with information which don't change during the
 * execution, including bank_name, camera_name, nb_images, size of images,
 * camera calibration...
 *
 * Return a POSTER_ID on success, NULL otherwise
 *
 * you must call finalize when you don't use anymore the POSTER_ID
 */
POSTER_ID init_data (char* poster_name)
{
	POSTER_ID id;

	STATUS s = posterCreate (poster_name, sizeof(SICK_CART_MEASURES_STR), &id);
	if (s == ERROR)
	{
		char buf[1024];
		h2getErrMsg(errnoGet(), buf, sizeof(buf));
		printf ("Unable to create the %s poster : %s\n",poster_name, buf);
		return (NULL);
	}

	return (id);
}
Пример #4
0
static int
Stereopixel_init(Stereopixel *self, PyObject *args, PyObject *kwds)
{
    PyObject *images;
	char* poster_name;

    if (!PyArg_ParseTuple(args, "snn", &poster_name, &(self->width), &(self->height)))
		return -1;

	size_t poster_size = sizeof(Spix3DImage) + 
		self->width * self->height * sizeof(Spix3DPixel);

	STATUS s = posterCreate (poster_name, poster_size, &self->id);
	if (s == ERROR)
	{
		char buf[1024];
		h2getErrMsg(errnoGet(), buf, sizeof(buf));
		printf ("Unable to create the %s poster : %s\n",poster_name, buf);
		return -1;
	}

	printf("Succesfully created poster %s of size %zd\n", poster_name, poster_size); 

	Spix3DImage* img = posterAddr(self->id);

	posterTake(self->id, POSTER_WRITE);

	img->width = self->width;
	img->height = self->height;
	self->size = self->width * self->height;

	// dummy matrix
	memset(img->intrinseque_rectified, 0, sizeof(img->intrinseque_rectified));

	posterGive(self->id);

    return 0;
}
Пример #5
0
/*
 * Create a poster, and fill it with information that don't change during the
 * execution
 *
 * Return a POSTER_ID on success, NULL otherwise
 *
 * you must call finalize when you don't use anymore the POSTER_ID
 */
POSTER_ID init_data (char*	poster_name, int* ok)
{
	size_t poster_size = 0;
	POSTER_ID id;

	poster_size = sizeof(VimanObjectPublicArray);

	STATUS s = posterCreate (poster_name, poster_size, &id);
	if (s == ERROR)
	{
		char buf[1024];
		h2getErrMsg(errnoGet(), buf, sizeof(buf));
		printf ("Unable to create the %s poster : %s\n",poster_name, buf);
        *ok = 0;
		return (NULL);
	}

	//printf("Poster '%s' created of type VIMAN (size %zd)\n", poster_name, poster_size); 
	//printf ("INIT ID = %p (pointer)\n", id);

    *ok = 1;

	return (id);
}
Пример #6
0
static void 
$module$ActivitiesXML (FILE *f, $MODULE$_CNTRL_STR *sdic)
{
#define $MODULE$_NB_RQST_EXEC $nbExecRqst$
#if $MODULE$_NB_RQST_EXEC != 0

  $requestNameTabDeclare$
  int i;
  ACTIVITY_EVENT evn;
  ACTIVITY_STATE status;
  int bilan;
  int rqst;
  char strerr[64];

  for (i=0; i<MAX_ACTIVITIES; i++) {
    status = M_ACTIVITY_STATUS(sdic,i);
    bilan = M_ACTIVITY_BILAN(sdic,i);

    if (status != ETHER || bilan != OK) {
      evn = M_ACTIVITY_EVN(sdic,i);
      
      xmlBalise("activity", BEGIN_BALISE_NEWLINE, f, 1);

      xmlBalise("id", BEGIN_BALISE, f, 2);
      fprintf(f, "%d", M_ACTIVITY_ID(sdic, i));
      xmlBalise("id", TERMINATE_BALISE, f, 0);
      
      /* find the name */
      rqst=0;
      while($module$ExecRqstNumTab[rqst] != M_ACTIVITY_RQST_TYPE(sdic,i) 
	    && rqst<$MODULE$_NB_RQST_EXEC)
	rqst++;
      xmlBalise("name", BEGIN_BALISE, f, 2);
      fprintf(f, "%s", 
	  rqst == $MODULE$_NB_RQST_EXEC?
	  "Unknown" : $module$ExecRqstNameTab[rqst]);
      xmlBalise("name", TERMINATE_BALISE, f, 0);
      
      xmlBalise("task", BEGIN_BALISE, f, 2);
      fprintf(f, "%s", 
	  M_ACTIVITY_TASK_NUM(sdic,i) == -1 ? 
	  "not exec" : $module$ExecTaskNameTab[M_ACTIVITY_TASK_NUM(sdic,i)]);
      xmlBalise("task", TERMINATE_BALISE, f, 0);

      xmlBalise("status", BEGIN_BALISE, f, 2);
      fprintf(f, "%s", 
	  evn == NO_EVENT ?
	  h2GetEvnStateString(status) : h2GetEvnStateString(evn));
      xmlBalise("status", TERMINATE_BALISE, f, 0);
      
      xmlBalise("errno", BEGIN_BALISE, f, 2);
      fprintf(f, "%s", h2getErrMsg(bilan, strerr, 64));
      xmlBalise("errno", TERMINATE_BALISE, f, 0);

      xmlBalise("activity", TERMINATE_BALISE, f, 1);
    }

  }	/* for */

#endif /* $MODULE$_NB_RQST_EXEC != 0 */
}
Пример #7
0
STATUS $module$CntrlPosterXML (FILE *f)
{
  $MODULE$_CNTRL_STR *sdic;
  int i;
  char strerr[64];

  /* Read the control IDS */
  sdic = ($MODULE$_CNTRL_STR *)malloc(sizeof($MODULE$_CNTRL_STR));
  if (sdic == NULL) {
    h2perror ("$module$CntrlPosterXML");
    return ERROR;
  }
  if ($module$CntrlPosterRead (sdic) != OK) {
    free(sdic);
    return ERROR;
  }

  /* 
   * display 
   */
  /* control task */
  xmlBalise("task", BEGIN_BALISE_NEWLINE, f, 1);

  xmlBalise("name", BEGIN_BALISE, f, 2);
  fprintf(f, "ControlTask");
  xmlBalise("name", TERMINATE_BALISE, f, 0);

  xmlBalise("status", BEGIN_BALISE, f, 2);
  fprintf(f, "%s", 
	  M_CNTRL_TASK_STATUS(sdic)==OK ? "OK":"ERROR");
  xmlBalise("status", TERMINATE_BALISE, f, 0);
  if (M_CNTRL_TASK_STATUS(sdic) != OK) {
    xmlBalise("errno", BEGIN_BALISE, f, 2);
    fprintf(f, "%s", h2getErrMsg(M_CNTRL_TASK_BILAN(sdic), strerr, 64));
    xmlBalise("errno", TERMINATE_BALISE, f, 0);
  }
  xmlBalise("task", TERMINATE_BALISE, f, 1);

  /* execution tasks */
  for (i=0; i<$MODULE$_NB_EXEC_TASK; i++) {
    xmlBalise("task", BEGIN_BALISE_NEWLINE, f, 1);

    xmlBalise("name", BEGIN_BALISE, f, 2);
    fprintf(f, "%s", $module$ExecTaskNameTab[i]);
    xmlBalise("name", TERMINATE_BALISE, f, 0);

    xmlBalise("status", BEGIN_BALISE, f, 2);
    fprintf(f, "%s", M_EXEC_TASK_STATUS(sdic,i) == OK ? "OK": "ERROR");
    xmlBalise("status", TERMINATE_BALISE, f, 0);
    if (M_EXEC_TASK_STATUS(sdic, i) != OK) {
      xmlBalise("errno", BEGIN_BALISE, f, 2);
      fprintf(f, "%s", h2getErrMsg(M_EXEC_TASK_BILAN(sdic,i), strerr, 64));
      xmlBalise("errno", TERMINATE_BALISE, f, 0);
    }

    if (M_EXEC_TASK_PERIOD(sdic,i) != 0) {
      xmlBalise("period", BEGIN_BALISE, f, 2);
      fprintfBuf (f, "%d", (int)(M_EXEC_TASK_PERIOD(sdic,i)*1000.));
      xmlBalise("period", TERMINATE_BALISE, f, 0);
    }
    xmlBalise("task", TERMINATE_BALISE, f, 1);

  }

  /* Activities */
  $module$ActivitiesXML(f, sdic);

  free(sdic);
  return OK;
}
Пример #8
0
int main(int argc, char *argv[])
{
  POSTER_ID posterIdC;
  POSTER_ID posterIdF;
  TESTPOST_STR testIn = INIT_TESTPOST_STR;
  TESTPOST_STR testOut;
  int size = sizeof(TESTPOST_STR);
  int sizeOut;
  H2_ENDIANNESS endianness;
  char c;
  char msg[256];

  printf ("testPosterWrite: LOCAL ENDIANNESS = %d\n", h2localEndianness());

  /* create */
  if (posterCreate(TEST_POSTER_NAME, size, &posterIdC) == ERROR) {
    printf ("testPosterWrite: posterCreate(%s) failed : %s\n", 
	    TEST_POSTER_NAME, h2getErrMsg(errnoGet(), msg, 256));
    return 1;
  }
  printf ("testPosterWrite: poster %s created. Id = %0x\n", 
	  TEST_POSTER_NAME, (int)posterIdC);
  posterEndianness(posterIdC, &endianness);
  printf ("testPosterWrite: posterEndianness(%s) = %d\n\n", 
	  TEST_POSTER_NAME, endianness);

  /* write */
  if ((sizeOut=posterWrite(posterIdC, 0, (void *)&testIn, size)) != size) {
    printf ("testPosterWrite: posterWrite size = %d != %d \n", sizeOut, size);
    return testEnd(posterIdC);
  }
  printf ("testPosterWrite: poster %s writen\n", TEST_POSTER_NAME);

  /* read after create */
  if ((sizeOut=posterRead(posterIdC, 0, (void *)&testOut, size)) != size) {
    printf ("testPosterWrite: posterRead size = %d != %d \n", sizeOut, size);
    return testEnd(posterIdC);
  }
  printf ("testPosterWrite: poster %s read OK\n", TEST_POSTER_NAME);

  /* display */
  if (endianness != h2localEndianness()) 
    endianswap_TESTPOST_STR(&testOut);
  printTestStr("Write", &testOut);
  printf ("\n");

  /* find */
  if (posterFind(TEST_POSTER_NAME, &posterIdF) == ERROR) {
    printf ("testPosterWrite: posterFind failed\n");
    return testEnd(posterIdC);
  }
/*   printf ("posterFind TEST_POSTER_NAME posterIdF = %d\n", (int)posterIdF); */
  posterEndianness(posterIdF, &endianness);
  printf ("   endianness = %d\n", endianness);

  /* read after find */
  if ((sizeOut=posterRead(posterIdF, 0, (void *)&testOut, size)) != size) {
    printf ("testPosterWrite: posterRead size = %d != %d \n", sizeOut, size);
    return testEnd(posterIdC);
  }

  /* display */
  if (endianness != h2localEndianness()) 
    endianswap_TESTPOST_STR(&testOut);
  printTestStr("Write", &testOut);

  /* find again */
  if (posterFind(TEST_POSTER_NAME, &posterIdF) == ERROR) {
    printf ("testPosterWrite: posterFind failed\n");
    return testEnd(posterIdC);
  }
  printf ("PosterIdF %s = %d\n", TEST_POSTER_NAME, (int)posterIdF);

  
  posterEndianness(posterIdF, &endianness);
  printf ("   endianness = %d\n", endianness);

  printf ("Return to end ....");
  fflush(stdout);
  scanf("%c", &c);

  /* end */
  return testEnd(posterIdF);
}