src/experiments/k4/K4ClientPIC/ClientPIC.cpp
char CClientPIC::D_MovePosWait(byte addr, byte mode, long pos, long vel, long acc, byte pwm,  short uselimit_flag)
{

  //check first if motor has been calibrated
    if (calibrated[addr-1] == 1 || uselimit_flag == 0){
      
      if (uselimit_flag == 1){
	//now check if pos is within limits_min & max
	if (pos < limits_min[addr-1]){
	  if (DEBUG) printf("Pos = %d < limits_min = %d",pos,limits_min[addr-1]);
	  //change pos to limits_min + 1
	  pos = limits_min[addr-1] + 1;
	  if (DEBUG) printf(", change pos to %d\n",pos);
	}
	if (pos > limits_max[addr-1]){
	  if (DEBUG) printf("Pos = %d > limits_max = %d",pos,limits_max[addr-1]);
	  //change pos to limits_max - 1
	  pos = limits_max[addr-1] - 1;
	  if (DEBUG) printf(", change pos to %d\n",pos);
	}
      }
          int status;
      
          this->out_msg.id=_D_MOVEPOSWAIT;
      
          this->out_msg.msg.fdServoLoadTraj.addr=addr;
          this->out_msg.msg.fdServoLoadTraj.acc=acc;
          this->out_msg.msg.fdServoLoadTraj.mode=mode;
          this->out_msg.msg.fdServoLoadTraj.pos=pos;
          this->out_msg.msg.fdServoLoadTraj.pwm=pwm;
          this->out_msg.msg.fdServoLoadTraj.vel=vel;
      
      
      
          status=Send(this->pid,&out_msg,&in_msg,sizeof(out_msg),sizeof(in_msg));
          return(status);
    }
    else {
          //if not calibrated
          printf("Motor addr %d has not been calibrated. Ignore move.\n",addr);
      return 0;
    }
}
/* this function is also similar to the above two functions except that it
   does not return until the requested move has been finished 
   this is also not currently used by YAPOC */
this function is also similar to the above two functions except that it
does not return until the requested move has been finished
this is also not currently used by YAPOC
this function is also similar to the above two functions except that it does not return until the requested move has been finished this is also not currently used by YAPOC
char CClientPIC::D_MovePosWait(byte addr, byte mode, long pos, long vel, long acc, byte pwm,  short uselimit_flag)
{
    if (calibrated[addr-1] == 1 || uselimit_flag == 0){
      if (uselimit_flag == 1){
	if (pos < limits_min[addr-1]){
	  if (DEBUG) printf("Pos = %d < limits_min = %d",pos,limits_min[addr-1]);
	  pos = limits_min[addr-1] + 1;
	  if (DEBUG) printf(", change pos to %d\n",pos);
	}
	if (pos > limits_max[addr-1]){
	  if (DEBUG) printf("Pos = %d > limits_max = %d",pos,limits_max[addr-1]);
	  pos = limits_max[addr-1] - 1;
	  if (DEBUG) printf(", change pos to %d\n",pos);
	}
      }
          int status;
          this->out_msg.id=_D_MOVEPOSWAIT;
          this->out_msg.msg.fdServoLoadTraj.addr=addr;
          this->out_msg.msg.fdServoLoadTraj.acc=acc;
          this->out_msg.msg.fdServoLoadTraj.mode=mode;
          this->out_msg.msg.fdServoLoadTraj.pos=pos;
          this->out_msg.msg.fdServoLoadTraj.pwm=pwm;
          this->out_msg.msg.fdServoLoadTraj.vel=vel;
          status=Send(this->pid,&out_msg,&in_msg,sizeof(out_msg),sizeof(in_msg));
          return(status);
    }
    else {
          printf("Motor addr %d has not been calibrated. Ignore move.\n",addr);
      return 0;
    }
}
char CClientPIC :: D_MovePosWait ( byte addr , byte mode , long pos , long vel , long acc , byte pwm , short uselimit_flag ) { if ( calibrated [ addr - 1 ] == 1 || uselimit_flag == 0 ) { if ( uselimit_flag == 1 ) { if ( pos < limits_min [ addr - 1 ] ) { if ( DEBUG ) printf ( " " , pos , limits_min [ addr - 1 ] ) ; pos = limits_min [ addr - 1 ] + 1 ; if ( DEBUG ) printf ( " \n " , pos ) ; } if ( pos > limits_max [ addr - 1 ] ) { if ( DEBUG ) printf ( " " , pos , limits_max [ addr - 1 ] ) ; pos = limits_max [ addr - 1 ] - 1 ; if ( DEBUG ) printf ( " \n " , pos ) ; } } int status ; this -> out_msg . id = _D_MOVEPOSWAIT ; this -> out_msg . msg . fdServoLoadTraj . addr = addr ; this -> out_msg . msg . fdServoLoadTraj . acc = acc ; this -> out_msg . msg . fdServoLoadTraj . mode = mode ; this -> out_msg . msg . fdServoLoadTraj . pos = pos ; this -> out_msg . msg . fdServoLoadTraj . pwm = pwm ; this -> out_msg . msg . fdServoLoadTraj . vel = vel ; status = Send ( this -> pid , & out_msg , & in_msg , sizeof ( out_msg ) , sizeof ( in_msg ) ) ; return ( status ) ; } else { printf ( " \n " , addr ) ; return 0 ; } }
this function is also similar to the above two functions except that it
does not return until the requested move has been finished
this is also not currently used by YAPOC
this function is also similar to the above two functions except that it does not return until the requested move has been finished this is also not currently used by YAPOC
//check first if motor has been calibrated //now check if pos is within limits_min & max //change pos to limits_min + 1 //change pos to limits_max - 1 //if not calibrated