src/experiments/k4/K4ClientPIC/ClientPIC.cpp
char CClientPIC::D_MovePosNoWait(byte addr, byte mode, long pos, byte pwm,short uselimit_flag)
  {
     //check first if motor has been calibrated
     if (calibrated[addr-1] == 1 || uselimit_flag == 0){
       
       if (uselimit_flag == 1){

	 printf("Checking limits\n");
           //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_MOVEPOSNOWAIT;
       
           this->out_msg.msg.fdServoLoadTraj.addr=addr;
           this->out_msg.msg.fdServoLoadTraj.acc=PICdefaultacc[addr-1];
           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=PICdefaultvel[addr-1];
       
       printf("Move axis %d to %d w/ vel %d acc %d\n",(int)addr,pos,PICdefaultvel[addr-1],PICdefaultacc[addr-1]);
       
       
           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 similar to the one right above, except that PICdefaultvel
   and PICdefaultacc are used instead of passed in as input.
   this is not currently used by YAPOC */
this function is similar to the one right above, except that PICdefaultvel
and PICdefaultacc are used instead of passed in as input.
this is not currently used by YAPOC
this function is similar to the one right above except that PICdefaultvel and PICdefaultacc are used instead of passed in as input . this is not currently used by YAPOC
char CClientPIC::D_MovePosNoWait(byte addr, byte mode, long pos, byte pwm,short uselimit_flag)
  {
     if (calibrated[addr-1] == 1 || uselimit_flag == 0){
       if (uselimit_flag == 1){
	 printf("Checking limits\n");
           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_MOVEPOSNOWAIT;
           this->out_msg.msg.fdServoLoadTraj.addr=addr;
           this->out_msg.msg.fdServoLoadTraj.acc=PICdefaultacc[addr-1];
           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=PICdefaultvel[addr-1];
       printf("Move axis %d to %d w/ vel %d acc %d\n",(int)addr,pos,PICdefaultvel[addr-1],PICdefaultacc[addr-1]);
           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_MovePosNoWait ( byte addr , byte mode , long pos , byte pwm , short uselimit_flag ) { if ( calibrated [ addr - 1 ] == 1 || uselimit_flag == 0 ) { if ( uselimit_flag == 1 ) { printf ( " \n " ) ; 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_MOVEPOSNOWAIT ; this -> out_msg . msg . fdServoLoadTraj . addr = addr ; this -> out_msg . msg . fdServoLoadTraj . acc = PICdefaultacc [ addr - 1 ] ; 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 = PICdefaultvel [ addr - 1 ] ; printf ( " \n " , ( int ) addr , pos , PICdefaultvel [ addr - 1 ] , PICdefaultacc [ addr - 1 ] ) ; 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 similar to the one right above, except that PICdefaultvel
and PICdefaultacc are used instead of passed in as input.
this function is similar to the one right above except that PICdefaultvel and PICdefaultacc are used instead of passed in as input .
//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