/* Set the voltage reference you prefer, default is vcc * It needs to recalibrate */ void ADC::setReference(uint8_t type) { if (type) { // internal reference requested if (!analog_reference_internal) { analog_reference_internal = 1; if (calibrating) ADC0_SC3 = 0; // cancel cal calibrate(); } } else { // vcc or external reference requested if (analog_reference_internal) { analog_reference_internal = 0; if (calibrating) ADC0_SC3 = 0; // cancel cal calibrate(); } } }
int main(int argc, char **argv) { suseconds_t s = 100000; unit = calibrate(s); master(); return EXIT_SUCCESS; }
/* Function: p7_Builder() * Synopsis: Build a new HMM from an MSA. * * Purpose: Take the multiple sequence alignment <msa> and a build configuration <bld>, * and build a new HMM. * * Effective sequence number determination and calibration steps require * additionally providing a null model <bg>. * * Args: bld - build configuration * msa - multiple sequence alignment * bg - null model * opt_hmm - optRETURN: new HMM * opt_trarr - optRETURN: array of faux tracebacks, <0..nseq-1> * opt_gm - optRETURN: profile corresponding to <hmm> * opt_om - optRETURN: optimized profile corresponding to <gm> * opt_postmsa - optRETURN: RF-annotated, possibly modified MSA * * Returns: <eslOK> on success. The new HMM is optionally returned in * <*opt_hmm>, along with optional returns of an array of faux tracebacks * for each sequence in <*opt_trarr>, the annotated MSA used to construct * the model in <*opt_postmsa>, a configured search profile in * <*opt_gm>, and an optimized search profile in <*opt_om>. These are * all optional returns because the caller may, for example, be interested * only in an optimized profile, or may only be interested in the HMM. * * Returns <eslENORESULT> if no consensus columns were annotated. * Returns <eslEFORMAT> on MSA format problems, such as a missing RF annotation * line in hand architecture construction. On any returned error, * <bld->errbuf> contains an informative error message. * * Throws: <eslEMEM> on allocation error. * <eslEINVAL> if relative weights couldn't be calculated from <msa>. * * Xref: J4/30. */ int p7_Builder(P7_BUILDER *bld, ESL_MSA *msa, P7_BG *bg, P7_HMM **opt_hmm, P7_TRACE ***opt_trarr, P7_PROFILE **opt_gm, P7_OPROFILE **opt_om, ESL_MSA **opt_postmsa) { int i,j; uint32_t checksum = 0; /* checksum calculated for the input MSA. hmmalign --mapali verifies against this. */ P7_HMM *hmm = NULL; P7_TRACE **tr = NULL; P7_TRACE ***tr_ptr = (opt_trarr != NULL || opt_postmsa != NULL) ? &tr : NULL; int status; if ((status = validate_msa (bld, msa)) != eslOK) goto ERROR; if ((status = esl_msa_Checksum (msa, &checksum)) != eslOK) ESL_XFAIL(status, bld->errbuf, "Failed to calculate checksum"); if ((status = relative_weights (bld, msa)) != eslOK) goto ERROR; if ((status = esl_msa_MarkFragments(msa, bld->fragthresh)) != eslOK) goto ERROR; if ((status = build_model (bld, msa, &hmm, tr_ptr)) != eslOK) goto ERROR; //Ensures that the weighted-average I->I count <= bld->max_insert_len //(MI currently contains the number of observed insert-starts) if (bld->max_insert_len>0) for (i=1; i<hmm->M; i++ ) hmm->t[i][p7H_II] = ESL_MIN(hmm->t[i][p7H_II], bld->max_insert_len*hmm->t[i][p7H_MI]); if ((status = effective_seqnumber (bld, msa, hmm, bg)) != eslOK) goto ERROR; if ((status = parameterize (bld, hmm)) != eslOK) goto ERROR; if ((status = annotate (bld, msa, hmm)) != eslOK) goto ERROR; if ((status = calibrate (bld, hmm, bg, opt_gm, opt_om)) != eslOK) goto ERROR; if ((status = make_post_msa (bld, msa, hmm, tr, opt_postmsa)) != eslOK) goto ERROR; //force masked positions to background (it'll be close already, so no relevant impact on weighting) if (hmm->mm != NULL) for (i=1; i<hmm->M; i++ ) if (hmm->mm[i] == 'm') for (j=0; j<hmm->abc->K; j++) hmm->mat[i][j] = bg->f[j]; if ( bld->abc->type == eslDNA || bld->abc->type == eslRNA ) { if (bld->w_len > 0) hmm->max_length = bld->w_len; else if (bld->w_beta == 0.0) hmm->max_length = hmm->M *4; else if ( (status = p7_Builder_MaxLength(hmm, bld->w_beta)) != eslOK) goto ERROR; } hmm->checksum = checksum; hmm->flags |= p7H_CHKSUM; if (opt_hmm != NULL) *opt_hmm = hmm; else p7_hmm_Destroy(hmm); if (opt_trarr != NULL) *opt_trarr = tr; else p7_trace_DestroyArray(tr, msa->nseq); return eslOK; ERROR: p7_hmm_Destroy(hmm); p7_trace_DestroyArray(tr, msa->nseq); if (opt_gm != NULL) p7_profile_Destroy(*opt_gm); if (opt_om != NULL) p7_oprofile_Destroy(*opt_om); return status; }
/*--------------------------------------------*/ void Calibrate_Class::calibrateRoutine() { if (millis() > utils->lastWrite_offboard + utils->offboardWriteInc) { utils->multiplexInCVs(); if(calibrating == true) calibrate(); writeCalibrate_lcd(); utils->lastWrite_offboard = millis(); } }
void loop() { // int sensorValue = 0; // sensorValue = analogRead(A0); // double ampl = abs(mean-sensorValue); // if(ampl>meanAmpl){ // Serial.println("Calla puta!"); // } calibrate(); delay(1000); }
/* * -- sniffer_start * * In order to start the Syskonnect sk98 we open the device and * mmap a region in memory that the driver has allocated for us * (it will keep the tokens for the packets). * Then, we inform the driver of the size of the packet buffer and * where it is. Finally, start timer calibration using the sk98-timers API. * It returns 0 on success, -1 on failure. * */ static int sniffer_start(source_t * src) { struct _snifferinfo * info; struct sk98_ioctl_map args; int fd; /* Start up the timestamps library * * XXX where do we get 78110207 from? (initial frequency?) */ initialise_timestamps(1, 78110207, NULL); /* open the device */ fd = open(src->device, O_RDWR); if (fd < 0) { logmsg(LOGWARN, "sniffer-sk98: cannot open %s: %s\n", src->device, strerror(errno)); return -1; } src->ptr = safe_malloc(sizeof(struct _snifferinfo)); info = (struct _snifferinfo *) src->ptr; /* * mmap the region that contains the ring buffers * with the tokens. */ info->m = mmap(NULL, sizeof(struct map_area_header), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (info->m == MAP_FAILED) { logmsg(LOGWARN, "sniffer-sk98: failed to mmap %s: %s\n", src->device, strerror(errno)); free(src->ptr); return -1; } /* inform the driver of where the packets should go */ args.len = 1024 * 1024 * BUFFER_MB; args.offset = 0; info->packet_pool = safe_malloc(args.len); args.start_addr = info->packet_pool; if (ioctl(fd, SK98_IOCTL_MAP, &args) < 0) { logmsg(LOGWARN, "sniffer-sk98: failed creating packet pool: %s\n", strerror(errno)); free(src->ptr); return -1; } /* do timer calibration */ calibrate(info); src->fd = fd; return 0; /* success */ }
void Perspective::calibrate(Coord ca, Coord cb, Coord cc, Coord cd) { Vector* a = new Vector(ca); Vector* b = new Vector(cb); Vector* c = new Vector(cc); Vector* d = new Vector(cd); calibrate(a, b, c, d); delete a, b, c, d; }
float LIS3MDL_TWI::readAzimut() { calibrate(); float heading = atan2(_yCalibrate, _xCalibrate); if(heading < 0) heading += TWO_PI; else if(heading > TWO_PI) heading -= TWO_PI; float headingDegrees = heading * RAD_TO_DEG; return headingDegrees; }
void CNCArduinostepsClass::calculatecurcorunits(currencoord inputcurcor, currencoordunits &outputcurcorunits) { if (calibset) { //outputcurcorunits.currentXunits = inputcurcor.currentXs*calibrationX; //outputcurcorunits.currentYunits = inputcurcor.currentYs*calibrationY; outputcurcorunits.currentXunits = inputcurcor.currentXs/stepspermmX; outputcurcorunits.currentYunits = inputcurcor.currentYs/stepspermmY; } else { calibrate(2,false); } }
LinuxJoystick::LinuxJoystick(int which, int doCalibrate) { joy = which; fd = -1; has_z = has_r = 0; naxis = 2; read_def_file(joy ? joydef1 : joydef0 ); if (doCalibrate) calibrate(); active = open(); }
task main() { tSensors ports[3] = {in1, in2, in3}; newGyroArray(&gyroArray, ports, 3); // Set up gyroArray in analog ports 1, 2, and 3. calibrate(&gyroArray); // Calibrate gyroArray. newGyro(&gyro1, in1); calibrate(&gyro1); newGyro(&gyro2, in2); calibrate(&gyro2); newGyro(&gyro3, in3); calibrate(&gyro3); startTask(background); // Update gyro angle in the background. // Turn left 90 degrees. while (getDifferenceInAngleDegrees(getAngle(&gyroArray), 90.0) > 0.0) { motor[port2] = 127; motor[port3] = -127; } motor[port2] = motor[port3] = 0; }
void DAQCalibration::execute(void) { if(data_idx < 1/period) { channel_data.push_back(input(0)); data_idx++; if(data_idx == 1/period) calibrate(); } return; }
bool Calibration::calibrateFromDirectory(string directory) { ofDirectory dirList; ofImage cur; dirList.listDir(directory); for(int i = 0; i < (int)dirList.size(); i++) { cur.loadImage(dirList.getPath(i)); if(!add(toCv(cur))) { ofLog(OF_LOG_ERROR, "Calibration::add() failed on " + dirList.getPath(i)); } } return calibrate(); }
void main(void) { // Initialise system setup(); // used for debugging. TRISBbits.RB4 = 0; PORTBbits.RB4 = 0; // Loop until the system is turned off while (req_state & POWER_ON) { int serial_data; switch (cur_state) { case ST_WEIGH: weigh(); break; case ST_COUNT_I: case ST_COUNT_F: count(); break; case ST_CALIBRATE: calibrate(); break; } serial_data = parseSerial(); if (serial_data != RS232_NO_DATA) { RS232writeByte(COMM_DEBUG); RS232writeByte(cur_state); RS232writeByte(disp_type); //RS232writeByte(serial_data); } if (req_state != ST_NONE) { // int timeout = 0xFFFF; // int serial_return; cur_state = req_state; // Send Change to GUI. if (!st_chng_rs232_flag) { if (cur_state == ST_COUNT_F) { RS232sendData_b_i(COMM_CHANGE_STATE, cur_state, number_items); } else { RS232sendData_b(COMM_CHANGE_STATE, cur_state); } } st_chng_rs232_flag = 0; req_state = ST_NONE; } } powerDown(); // Save state and power down. }
int main(int argc, char** argv) { ros::init(argc, argv, "calibrate"); CalibrateAction calibrate(ros::this_node::getName()); ROS_INFO("Calibration Server started"); ros::spin(); return 0; }
void maininit(void) { calibrate(); ginit(); gpal(0); setretr(true); initkeyb(); detectjoy(); inir(); initsound(); recstart(); }
// With fixed volatility calibrate the reversions one by one // to the given helpers. In this case the step dates must be chosen // according to the maturities of the calibration instruments. void calibrateReversionsIterative( const std::vector<boost::shared_ptr<CalibrationHelper> > &helpers, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint = Constraint(), const std::vector<Real> &weights = std::vector<Real>()) { for (Size i = 0; i < helpers.size(); i++) { std::vector<boost::shared_ptr<CalibrationHelper> > h(1, helpers[i]); calibrate(h, method, endCriteria, constraint, weights, MoveReversion(i)); } }
/* * This is a top level for video layer 2 which should * start "../eyer/eyemc" * start "../eyel/eyemc" * "./v2grab/v2grab" application, * and control them by sending commands */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> #include <string.h> #define MAX_COUNT 200 #define BUF_SIZE 100 #define EXENAME 80 char eye0exec[EXENAME]; char eye1exec[EXENAME]; char grabexec[EXENAME]; /////////////////// // Calibration parameters int calibrated = 0; int resolution_defined = 0; double lx_res, ly_res; double rx_res, ry_res; ////////////////////// // Eye defined. If reye == 0, it means that /dev/video0 is right. // If reye == 1, right eye is /dev/video1 int reye = 0; ///////////////////// // Report from eyes int bad_report = 0; int order = 0; void get_config(char * configname) { FILE* config_fp ; char line[MAX_COUNT + 1] ; char* token ; config_fp = fopen( configname , "r" ) ; if (config_fp == NULL) { perror("Open config"); exit(1); } while( fgets( line, MAX_COUNT, config_fp ) != NULL ) { token = strtok( line, "\t =\n\r" ) ; if( token != NULL && token[0] != '#' ) { if (!strncmp(token, "eye0", 4) ) { //printf( "%s : ", token ) ; token = strtok( NULL, "\t =\n\r" ) ; //printf( "%s\n", token ) ; memset(eye0exec, 0, EXENAME); strcpy(eye0exec, token); } if (!strncmp(token, "eye1", 4) ) { //printf( "%s : ", token ) ; token = strtok( NULL, "\t =\n\r" ) ; //printf( "%s\n", token ) ; memset(eye1exec, 0, EXENAME); strcpy(eye1exec, token); } if (!strncmp(token, "grabber", 7) ) { //printf( "%s : ", token ) ; token = strtok( NULL, "\t =\n\r" ) ; //printf( "%s\n", token ) ; memset(grabexec, 0, EXENAME); strcpy(grabexec, token); } } } } ///////////////////////// // This function defines which eye corresponds to which device. int find_camera_names(){ return 0; } //////////////////////// // Sends calibration command int calibrate() { printf("Calibrating...\n"); sleep(3); printf("Calibration done.\n"); return 1; } //////////////////////// // int do_jump () { return 0; } int define_camera_resolutions() { return 1; } //////////////////////// // If there is no order eyes do a lookup of environment and compose the report.*/ int do_lookup() { // 1) if calibration was not done before, do calibration sequence. if (!calibrated) { calibrated = calibrate(); } else if(!resolution_defined ) { resolution_defined = define_camera_resolutions(); } else { // 2) read and analyse report from eyes. // Ждем обновления репорта от глаз о перемещении. // Должны прийти текущие координаты осей глаз. // Либо сообщение об ошибке если не удается задать позицию глаза. // Перед тем как проверить позицию v2s посылает rem координаты. printf("Read eyes reports\n"); sleep(1); // 2.0) if (bad_report){ // save everything and exit exit(1); } // Следим за каталогом с картинками, как только там начинают // появляться картинки запускаем по очереди фильтры. // printf("Processing images. Motion detect, interesting points\n"); sleep(1); printf("Processing images 2. Updating points information.\n"); sleep(1); printf("Write report to upper level.\n"); sleep(1); printf("Calculate new eye jump\n"); sleep(1); printf("Do jump\n"); do_jump(); } return 0; }
task main() { newGyro(&gyro, in1); // Set up gyro in analog port 1. calibrate(&gyro, 1000, 1); // Calibrate gyro for 1 second, sampling at 1 millisecond intervals. startTask(background); // Update gyro angle in the background. // Turn left 90 degrees. while (getDifferenceInAngleDegrees(getAngle(&gyro), 90.0) > 0.0) { motor[port2] = 127; motor[port3] = -127; } motor[port2] = motor[port3] = 0; }
task main(){ calibrate(); motor[Dribbler] = 100; if(SensorValue(TouchSensor) == 0){ while(SensorValue(TouchSensor) == 0){ // While the Touch Sensor is inactive (hasn't been pressed): motor[Kicker] = 100; } motor[Kicker] = 0; } while(true){ move(calc()); } }
Perspective::Perspective(Coord ca, Coord cb, Coord cc, Coord cd) : fov(FOV*PI/360) , view(new Vector(.5, .5, 0.5/tan(fov), true)) { Vector* a = new Vector(ca); Vector* b = new Vector(cb); Vector* c = new Vector(cc); Vector* d = new Vector(cd); calibrate(a, b, c, d); delete a, b, c, d; }
AxisController::AxisController() { Servo m_axisServo; m_pinNum = DEFAULT_PIN_NUM; SoftwareSerial m_output(DEFAULT_RX_PIN, DEFAULT_TX_PIN); m_outMin = DEFAULT_OUTMIN; m_outMax = DEFAULT_OUTMAX; m_axisServo.attach(m_pinNum); m_output.begin(9600); calibrate(MAX_SAMPLES); }
void operatorControl() { while (true) { calibrate(); handleLocks(); handleLcdButtons(); legs(); int shouldshoot = 0; while (joystickGetDigital(1, 7, JOY_LEFT)){ shouldshoot = 1; } //start the shoot loop if (shouldshoot){ shootgo = 1; bot = shoot; shootLoop(); } int shouldlift = 0; while (joystickGetDigital(2, 8, JOY_LEFT)){ shouldlift = 1; } if (shouldlift){ if (bot == lift){ bot = control; } else { bot = lift; } } if (bot == control){ if (joystickGetDigital(1, 8, JOY_LEFT)){ shootLeft(); } if (joystickGetDigital(1, 8, JOY_RIGHT)){ shootRight(); } } delay(25); } }
int main(int argc, char **argv) { const std::string port = argc>1 ? argv[1] : "COM7"; std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!! ArduinoConnection conn(port); std::vector<PwmDrive> drives = { PwmDrive(conn,1), PwmDrive(conn,2), PwmDrive(conn,3), PwmDrive(conn,4), PwmDrive(conn,5) }; drives[0].configure( 4.5, 2, 2, 0.1, 65 ); drives[1].configure( 5, 2, 2, 0.1, 95 ); drives[2].configure( 6, 2, 2, 0.1, 75 ); drives[3].configure( 3.5, 2, 1.5, 0.1, 65 ); drives[4].configure( 1, 0.15, 40, 0.001, 120 ); printHeader( std::cout ) << std::endl; //move(conn); //moveSpeed(drive2, 10); //drives[4].moveTo(-7); //moveTo(drives[3], 5); //moveTo(drives[2], -240); // moveTo(drives[0], -50); calibrate(drives[0]); drives[0].moveTo(-180); drives[1].moveTo(-120); drives[2].moveTo(240); drives[3].moveTo(-95); waitForExecDrives(drives.begin(), drives.end()); boost::this_thread::sleep(boost::posix_time::milliseconds(5000)); for (auto drive : drives) { drive.moveTo(0); } waitForExecDrives(drives.begin(), drives.end()); // moveTo(drives[3], 5); // moveTo(drives[0], 0); //printHeader( std::cout ) << std::endl; //measure(drive); //moveSpeed(conn, 140); // int16_t target = 0; // while(target>-15000) { // std::cout << "Enter target:"; // std::cin >> target; // if(target>-15000) // moveTo(conn, target); // while( true ) { // PwmDrive drive(conn,1); // std::cout << "error=" << drive.error() << ", position="<< drive.position() << ", speed=" << drive.actualSpeed() << std::endl; // } // } return 0; }
uint_least16_t ADS7846::getY(void) { calibrate(); switch(lcd_orientation) { case 0: return lcd_y; case 90: return LCD_WIDTH-lcd_x; case 180: return LCD_HEIGHT-lcd_y; case 270: return lcd_x; } return 0; }
AxisController::AxisController(Servo axisServo, int pinNum, SoftwareSerial output, int outMin=0, int outMax=179) { m_axisServo = axisServo; m_pinNum = pinNum; SoftwareSerial m_output(DEFAULT_RX_PIN, DEFAULT_TX_PIN); m_outMin = outMin; m_outMax = outMax; m_axisServo.attach(m_pinNum); m_output.begin(9600); calibrate(MAX_SAMPLES); }
int main() { CvCalibFilter* calib; IplImage** images; cv_dc1394_init(); calib = calibrate(); printf("Displaying undistorted images\n"); while (cv_sdl_process_events()) { images = cv_dc1394_capture_yuv(2); calib->Undistort(images, images); cv_sdl_show_yuv_tiles(images, 2, 2); } }
/* Initialize stuff: * - Start Vref module * - Clear all fail flags * - Internal reference (default: external vcc) * - Mux between a and b channels (b channels) * - Calibrate with 32 averages and low speed * - When first calibration is done it sets: * - Resolution (default: 10 bits) * - Conversion speed and sampling time (both set to medium speed) * - Averaging (set to 4) */ void ADC_Module::analog_init() { // default settings: /* - 10 bits resolution - 4 averages - vcc reference - no interrupts - pga gain=1 - conversion speed = medium - sampling speed = medium initiate to 0 (or 1) so the corresponding functions change it to the correct value */ analog_res_bits = 0; analog_max_val = 0; analog_num_average = 0; analog_reference_internal = 2; var_enableInterrupts = 0; pga_value = 1; conversion_speed = 0; sampling_speed = 0; calibrating = 0; fail_flag = ADC_ERROR_CLEAR; // clear all errors num_measurements = 0; // select b channels // *ADC_CFG2_muxsel = 1; setBit(ADC_CFG2, ADC_CFG2_MUXSEL_BIT); // set reference to vcc setReference(ADC_REF_3V3); // set resolution to 10 setResolution(10); // the first calibration will use 32 averages and lowest speed, // when this calibration is over the averages and speed will be set to default by wait_for_cal and init_calib will be cleared. init_calib = 1; setAveraging(32); setConversionSpeed(ADC_LOW_SPEED); setSamplingSpeed(ADC_LOW_SPEED); // begin init calibration calibrate(); }
/* Initialize stuff: * - Start Vref module * - Clear all fail flags * - Internal reference (default: external vcc) * - Mux between a and b channels (b channels) * - Calibrate with 32 averages and low speed * - When first calibration is done it sets: * - Resolution (default: 10 bits) * - Conversion speed and sampling time (both set to medium speed) * - Averaging (set to 4) */ void ADC_Module::analog_init() { // default settings: /* - 10 bits resolution - 4 averages - vcc reference - no interrupts - pga gain=1 - conversion speed = medium - sampling speed = medium initiate to 0 (or 1) so the corresponding functions change it to the correct value */ analog_res_bits = 0; analog_max_val = 0; analog_num_average = 0; analog_reference_internal = 1; var_enableInterrupts = 0; pga_value = 1; conversion_speed = 0; sampling_speed = 0; // the first calibration will use 32 averages and lowest speed, // when this calibration is over the averages and speed will be set to default by wait_for_cal and init_calib will be cleared. init_calib = 1; fail_flag = ADC_ERROR_CLEAR; // clear all errors // Internal reference initialization VREF_TRM = VREF_TRM_CHOPEN | 0x20; // enable module and set the trimmer to medium (max=0x3F=63) VREF_SC = VREF_SC_VREFEN | VREF_SC_REGEN | VREF_SC_ICOMPEN | VREF_SC_MODE_LV(1); // (=0xE1) enable 1.2 volt ref with all compensations // select b channels *ADC_CFG2_muxsel = 1; // set reference to vcc/external setReference(ADC_REF_EXTERNAL); // set resolution to 10 setResolution(10); // calibrate at low speed and max repetitions setAveraging(32); setConversionSpeed(ADC_LOW_SPEED); setSamplingSpeed(ADC_LOW_SPEED); // begin init calibration calibrate(); }
/* Process the finger data gathered from the last set of events */ void processFingers() { int i; fingersDown = 0; for(i = 0; i < 2; i++) { if(fingerInfos[i].slotUsed) { calibrate(&(fingerInfos[i])); fingersDown++; } } processFingerGesture(fingerInfos, fingersDown, fingersWereDown); /* Save number of fingers to compare next time */ fingersWereDown = fingersDown; }