예제 #1
0
void AnimationController::request_animation(std::string newAnimationName)
{
	// If we're trying to request a non-existent animation, replace it with the rest animation.
	if(!m_skeleton->has_animation(newAnimationName))
	{
#if 0
		std::cerr << "Non-existent animation " << newAnimationName << ", defaulting to rest animation\n";
#endif
		newAnimationName = "<rest>";
	}

	// If we're already playing the requested animation, ignore the request.
	if(m_animationName == newAnimationName) return;

	// Set up a transition towards the new pose. Note that if we're already in a transition, we
	// keep transitioning, just towards the new target.
	if(m_state == AS_REST)
	{
		m_state = AS_TRANSITION;
		m_transitionStart = m_skeleton->make_rest_pose();
	}
	else if(m_state == AS_PLAY)
	{
		m_state = AS_TRANSITION;
		m_transitionStart = get_pose();
	}

	m_animationName = newAnimationName;
	m_animationTime = 0;
}
예제 #2
0
/**
 * Only applicable for reduced-coordinate articulated bodies
 */
void JOINT::update_spatial_axes()
{
  // setup the spatial axis vector and frame
  _s.resize(num_dof());
  for (unsigned i=0; i< _s.size(); i++)
    _s[i].pose = get_pose();
}
예제 #3
0
//=============================================================================
void
tracker::start_logging(char* filename)
{
  if (get_logging())
    return;

  char logfilename[128];
  FILE* file;
  timer t;
  unsigned long time;
  double x,y,z,ya,pi,ro;

  if (filename == NULL)
  if (get_default_log_filename(logfilename, 128) == -1)
  {
    #if TraceErrors
    printf("tracker: start_logging: could not get default log filename\n");
    #endif
    return;
  }
  
  
  child_pid_ = fork();
  if (child_pid_ == -1)
  {
    #if TraceErrors
    printf("tracker: start_logging: error creating child process\n");
    #endif
    return;
  }

  set_logging(1);

  if (child_pid_ == 0)
  {

    file = fopen(logfilename, "a+");
    if (file == NULL)
    {
      #if TraceErrors
      printf("tracker: start_logging: error opening file\n");
      #endif
    }  
      
    t.timer_reset();
    
    while(get_logging())
    {
      get_pose(&x,&y,&z,&ya,&pi,&ro);
      time = t.timer_read();
      fprintf(file, "%lu %.2lf %.2lf %.2lf %.2lf %.2lf %.2lf\n", time, x, y, z, ya, pi, ro);
    }

    fclose(file);
    exit(0);
  }
}
예제 #4
0
//=============================================================================
void
tracker::set_boresight_to_current(void)
{
  if (get_logging())
    return;

  //char buf[MAX_LENGTH];
  //sprintf(buf, "B%d\r", STATION);
  //port->send_comport(buf);

  //Boresight not working, do it manually
  double yaw, pitch, roll;
  get_pose(NULL, NULL, NULL, &yaw, &pitch, &roll);
  set_boresight(yaw, pitch, roll);
}
예제 #5
0
//=============================================================================
void
tracker::start_logging_xml(char* filename)
{
  if (get_logging())
    return;

  char logfilename[128];
  FILE* file;
  timer t;
  unsigned long time;
  double x,y,z,ya,pi,ro;
  //double *x, *y, *z, *ya, *pi, *ro;
  //int num = 2;

  if (filename == NULL)
  if (get_default_xml_filename(logfilename, 128) == -1)
  {
    #if TraceErrors
    printf("tracker: start_logging: could not get default log filename\n");
    #endif
    return;
  }
  
  
  child_pid_ = fork();
  if (child_pid_ == -1)
  {
    #if TraceErrors
    printf("tracker: start_logging: error creating child process\n");
    #endif
    return;
  }

  set_logging(1);

  if (child_pid_ == 0)
  {

    file = fopen(logfilename, "a+");
    if (file == NULL)
    {
      #if TraceErrors
      printf("tracker: start_logging: error opening file\n");
      #endif
    }  
      
    t.timer_reset();
    
    fprintf(file,"<demo>\n");
    while(get_logging())
    {
      
      get_pose(&x,&y,&z,&ya,&pi,&ro);
      //get_multi_pose(num,&x,&y,&z,&ya,&pi,&ro);

      time = t.timer_read();
      fprintf(file,"<point>\n");
      fprintf(file,"<time>%.3lf</time>\n",((double)time) /1000 );
      fprintf(file,"<end-effector>");
      fprintf(file, "<position>%.2lf;%.2lf;%.2lf</position><YPR>%.2lf;%.2lf;%.2lf</YPR>", x, y, z, ya, pi, ro);
      //fprintf(file, "<position>%.2lf;%.2lf;%.2lf</position><YPR>%.2lf;%.2lf;%.2lf</YPR>", x, y, z, ya, pi, ro);
      printf("%lu %.2lf %.2lf %.2lf %.2lf %.2lf %.2lf\n",time,  x, y, z, ya, pi, ro);
      /*for(int i=0;i<num;i++){
	printf("%lu %.2lf %.2lf %.2lf %.2lf %.2lf %.2lf\n",time,  x[i], y[i], z[i], ya[i], pi[i], ro[i]);
      }*/
      fprintf(file,"</end-effector>\n");
      fprintf(file,"</point>\n");
    }
    fprintf(file,"</demo>\n");
    fclose(file);
    exit(0);
  }
}