示例#1
0
VALUE stepper_initialize(VALUE self, VALUE serial) {
  PhidgetInfo *info = device_info(self);
  CPhidgetStepperHandle stepper = 0;
  ensure(CPhidgetStepper_create(&stepper));
  info->handle = (CPhidgetHandle)stepper;
  return rb_call_super(1, &serial);
}
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
   const real_T   *Upos  = (const real_T*) ssGetInputPortSignal(S,1);
   
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   stepperMove(*Upos, stepper);
 }
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
   //Lidar setup
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   //Stepper Setup
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   //Zero prameters
   counter = 0;
   
 }
示例#4
0
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
   const real_T   *Upos  = (const real_T*) ssGetInputPortSignal(S,1);
   const int32_T   *potVal  = (const int32_T*) ssGetInputPortSignal(S,0);
    
   
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   //Zero prameters
   int zeroPos = 418;
   int dpot;
   int dstep;
   
   //Zero stepper on start
   if (zeroPos > *potVal) {
       zeroPos = 418;
   }
   if (zeroPos < *potVal) {
       zeroPos = 419;
   }
   
   
   printf("potVal:%d\n",*potVal);
   dpot = zeroPos - *potVal;
   printf("Dpot:%d\n",dpot);
   dstep = -1036/45*dpot;
   printf("Dstep:%d\n",dstep);
   //stepperMove(dstep, stepper);
   
   CPhidgetStepper_setCurrentPosition(stepper, 0, 0);
   stepperMove(*Upos, stepper);
   
   
   
 }
示例#5
0
 /* Function: mdlStart =======================================================
  * Abstract:
  *    This function is called once at start of model execution. If you
  *    have states that should be initialized once, this is the place
  *    to do it.
  */
 static void mdlStart(SimStruct *S)
 {
       //Lidar setup
   ret = urg_connect(&urg, device, 115200);
   if (ret < 0) {
       urg_exit(&urg, "urg_connect()");
   }
   else
       urg_setCaptureTimes(&urg, UrgInfinityTimes);
   
   //Stepper Setup
   CPhidgetStepper_create(&stepper);
   stepperConnect(600000, 1214,stepper);
   
   //Zero prameters
   counter = 0;
   
   // Webcam SetUp
   capture1  = cvCaptureFromCAM( -1 ); //Sets up Camera Object
   if ( !capture1 ) 
       fprintf( stderr, "ERROR: capture is NULL \n" );
 }
/* Function: mdlStart =======================================================
 * Abstract:
 *    This function is called once at start of model execution. If you
 *    have states that should be initialized once, this is the place
 *    to do it.
 */
static void mdlStart(SimStruct *S) {
    // Lidar Setup
    ret  = urg_connect(&urg, device, 115200);
    if(ret<0)
        urg_exit(&urg, "urg_connect()");
    else
        urg_setCaptureTimes(&urg, UrgInfinityTimes);
    
    // Stepper Setup
    // Default 1214 Speed before Speed Input
    CPhidgetStepper_create(&stepper);
    stepperConnect(1000000, 1214, stepper);
    
    // Zero Counter variables
    counter = 0;
    camCounter = 0;
    lidarCounter = 0;
    bothCounter = 0;
    
    // Webcam Setup
    capture1  = cvCaptureFromCAM( -1 ); //Sets up Camera Object
    if (!capture1)
        fprintf( stderr, "ERROR: capture is NULL \n" );
}