//Initializes the en-/decoders and the belonging structures for a local video (filepath) JNIEXPORT jint JNICALL Java_sender_FFmpeg_init (JNIEnv *env, jclass thisclass, jstring filepath) { printf("%s\n", "Jumped into JNI"); fflush(stdout); int ret; i = 0; counter = 0; sequence = 0; const char *filename = (*env)->GetStringUTFChars(env, filepath, 0); printf("%s\n", filename); fflush(stdout); f = fopen("sender.mp4", "wb"); av_register_all(); //Open file ifmt_ctx = NULL; if ((ret = avformat_open_input(&ifmt_ctx, filename, NULL, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n"); return ret; } //Find stream information if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n"); return ret; } for (i = 0; i < ifmt_ctx->nb_streams; i++) { stream = ifmt_ctx->streams[i]; codec_ctx = stream->codec; //If video stream is found if (codec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { /* Open decoder */ ret = avcodec_open2(codec_ctx, avcodec_find_decoder(codec_ctx->codec_id), NULL); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Failed to open decoder for stream #%u\n", i); return ret; } break; } } printf("Codec: %s\n", codec_ctx->codec->long_name); fflush(stdout); av_dump_format(ifmt_ctx, 0, filename, 0); initEncoders(); return 0; }
int main(void) { char ch; LockoutProtection(); InitializeMCU(); initUART(); while(1) { UARTprintf("\nROBZ DEMO\n"); UARTprintf(" 0=UART Demo\n 1=Motor Demo\n"); UARTprintf(" 2=Servo Demo\n 3=Line Sensor\n"); UARTprintf(" 4=IR Sensor Demo\n 5=Encoders Demo\n"); UARTprintf(">> "); ch = getc(); putc(ch); UARTprintf("\n"); if (ch == '0') { UARTprintf("\nUART Demo\n"); uartDemo(); } else if (ch == '1') { UARTprintf("\nMotor Demo\n"); initMotors(); motorDemo(); } else if (ch == '2') { UARTprintf("\nServo Demo\n"); initServo(); servoDemo(); } else if (ch == '3') { UARTprintf("\nLine Sensor Demo\n"); initLineSensor(); lineSensorDemo(); } else if (ch == '4') { UARTprintf("\nIR Sensor Demo\n"); initIRSensor(); IRSensorDemo(); } else if (ch == '5') { UARTprintf("\nEncoders Demo\n"); initEncoders(); encoderDemo(); } } }
/* Setup function--runs once at startup. */ void setup() { Serial.begin(BAUDRATE); ticks=0; // Initialize the motor controller if used */ #ifdef USE_BASE initMotorController(); initEncoders(); #endif /* Attach servos if used */ #ifdef USE_SERVOS int i; for (i = 0; i < N_SERVOS; i++) { servos[i].attach(servoPins[i]); } #endif }
void testCalibratePID_MCStyle(int sr,int sl){ initEncoders(); regelverzoegerung=100; pidInit(); pidSetSpeed(sr,sl); }
int main(void) { int pwm; int adc_on; int adc_off; uint16_t i; element elem; robot.rotation_target = 0; robot.right_motor_pos =0; robot.left_motor_pos =0; robot.right_motor_target =0; robot.left_motor_target =0; SysTick_Config(168000000/8/1000000); // interrupr 1000000 per secound initTimer3(1); initMotors(); initEncoders(); initUsart3(); // enableUSART3RXNEInterrupt(); initADC(); initIRSensors(); initLED(); initSPI2(); LED_OFF; waitMs(1000); LED_ON; initPIDStructures(); stopMotors(); resetEncoders(); updateRobotState(); robot.left_ir_sensor_target = measures.left_ir_sensor; robot.right_ir_sensor_target = measures.right_ir_sensor; initQueue(&robot_queue); //addMove(&robot_queue,FORWARD,2000); addMove(&robot_queue,ROTATE,20000); // addMove(&robot_queue,FORWARD,9000); // addMove(&robot_queue,ROTATE,0); // addMove(&robot_queue,ROTATE,6000); // addMove(&robot_queue,FORWARD,9000); // addMove(&robot_queue,ROTATE,6000); // addMove(&robot_queue,ROTATE,12000); // addMove(&robot_queue,FORWARD,9000); // addMove(&robot_queue,ROTATE,12000); // addMove(&robot_queue,ROTATE,3000); // nextMove(); LED_ON; while(1) { if ( isBatteryWeak() ){ stopMotors(); blinkLed(); } if (flags.update_robot == 1){ moveRobot(); updateRobotState(); flags.update_robot =0; } if (flags.usart_custom == 1){ USART3_transmitString(itoa((int) robot.rotation, buf,10)); USART3_transmitString(" "); USART3_transmitString(itoa((int) robot.rotation_target, buf,10)); USART3_transmitString("\n"); } } // flags.usart_custom == 0; // USART3_transmitString("lewe_kolo_diff "); // USART3_transmitString(itoa((int) robot.left_motor_target - robot.left_motor_pos , buf,10)); // USART3_transmitByte('\n'); // USART3_transmitString("lewe kolo pwm "); // USART3_transmitString(itoa((int) getTranslation(LEFT_MOTOR) , buf,10)); // USART3_transmitByte('\n'); // // USART3_transmitString("prawe kolo diff "); // USART3_transmitString(itoa((int) robot.right_motor_target - robot.right_motor_pos , buf,10)); // USART3_transmitByte('\n'); // USART3_transmitString("prawe kolo pwm "); // USART3_transmitString(itoa((int) getTranslation(RIGHT_MOTOR) , buf,10)); // USART3_transmitByte('\n'); // } // // if (flags.usart_graph == 1){ // static uint8_t usart_start = 1; // if (usart_start ){ // usart_start=0; // USART3_transmitString("\n"); // USART3_transmitString("\n"); // USART3_transmitString("\n"); // USART3_transmitString("__start__\n"); // USART3_transmitString("lewe_kolo_pozycja "); // USART3_transmitString("lewe_kolo_cel "); // USART3_transmitString("lewe_kolo_diff "); // USART3_transmitString("lewe_kolo_pwm_T "); // USART3_transmitString("prawe_kolo_pozycja "); // USART3_transmitString("prawe_kolo_cel "); // USART3_transmitString("prawe_kolo_diff "); // USART3_transmitString("prawe_kolo_pwm_T \n"); // USART3_transmitString(" \n"); // } // // USART3_transmitString(itoa((int) robot.right_motor_pos , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) robot.right_motor_target , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) robot.right_motor_target - robot.right_motor_pos , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) getTranslation(RIGHT_MOTOR) , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) robot.left_motor_pos , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) robot.left_motor_target , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) robot.left_motor_target - robot.left_motor_pos , buf,10)); // USART3_transmitString(" "); // USART3_transmitString(itoa((int) getTranslation(LEFT_MOTOR) , buf,10)); // USART3_transmitByte('\n'); // flags.usart_graph = 0; // } // } // return 0; }
int main(int argc, char *argv[]) { // Check for big files #ifdef __USE_LARGEFILE #ifdef __USE_LARGEFILE64 printf("\n LARGE FILE AVAILABLE : %d offset\n", __USE_FILE_OFFSET64 ); #endif #endif /* Initialize Gettext if available */ #ifdef HAVE_DCGETTEXT setlocale (LC_ALL, ""); //#define ALOCALES "/usr/local/share/locale" bindtextdomain ("avidemux", ADMLOCALE); textdomain ("avidemux"); printf("Locales for %s appear to be in %s\n","avidemux", ADMLOCALE); printf("\nI18N : %s \n",dgettext("avidemux","_File")); #endif // thx smurf uk :) signal(11, sig_segfault_handler); // show stacktrace on default printf("\n*******************\n"); printf(" Avidemux 2, v " VERSION "\n"); printf("*******************\n"); printf(" http://fixounet.free.fr/avidemux\n"); printf(" Code : Mean & JSC \n"); printf(" GFX : Nestor Di , [email protected]\n"); printf(" Testing : Jakub Misak\n"); printf(" FreeBSD : Anish Mistry, [email protected]\n"); #if (defined( ARCH_X86) || defined(ARCH_X86_64)) printf("Arcc X86 X86_64 activated.\n"); #endif #ifdef USE_XX_XVID_CVS printf("Probing XvidCVS library....\n"); dloadXvidCVS( ); #endif VPInitLibrary(); register_Encoders( ); atexit(onexit); #ifndef CYG_MANGLING g_thread_init(NULL); #endif gtk_set_locale(); gtk_init(&argc, &argv); gdk_rgb_init(); #ifdef USE_XVID_4 xvid4_init(); #endif CpuCaps::init(); ADM_InitMemcpy(); if(!initGUI()) { printf("\n Fatal : could not init GUI\n"); exit(-1); } video_body = new ADM_Composer; #ifdef HAVE_ENCODER registerVideoFilters( ); #endif #ifdef USE_FFMPEG avcodec_init(); avcodec_register_all(); mpegps_init(); #endif // Load .avidemuxrc prefs->load(); #ifdef HAVE_AUDIO AVDM_audioInit(); #endif buildDistMatrix(); initScaleTab(); initEncoders(); loadEncoderConfig(); if (argc >= 2) { global_argc=argc; global_argv=argv; gtk_timeout_add( 300, (GtkFunction )automation, NULL ); //automation(); } #ifdef USE_SDL printf("Global SDL init...\n"); SDL_Init(0); //SDL_INIT_AUDIO+SDL_INIT_VIDEO); #endif if(SpidermonkeyInit() == true) printf("Spidermonkey initialized.\n"); gtk_main(); SpidermonkeyDestroy(); return 0; }
int main(int argc, char **argv) { //Register signal and signal handler signal(SIGINT, signal_callback_handler); //Init UDP with callbacks and pointer to run status initUDP( &UDP_Command_Handler, &UDP_Control_Handler, &Running ); print("Eddie starting...\r\n"); initIdentity(); double EncoderPos[2] = {0}; initEncoders( 183, 46, 45, 44 ); print("Encoders activated.\r\n"); imuinit(); print("IMU Started.\r\n"); float kalmanAngle; InitKalman(); #ifndef DISABLE_MOTORS print( "Starting motor driver (and resetting wireless) please be patient..\r\n" ); if ( motor_driver_enable() < 1 ) { print("Startup Failed; Error starting motor driver.\r\n"); motor_driver_disable(); return -1; } print("Motor Driver Started.\r\n"); #endif print("Eddie is starting the UDP network thread..\r\n"); pthread_create( &udplistenerThread, NULL, &udplistener_Thread, NULL ); print( "Eddie is Starting PID controllers\r\n" ); /*Set default PID values and init pitchPID controllers*/ pidP_P_GAIN = PIDP_P_GAIN; pidP_I_GAIN = PIDP_I_GAIN; pidP_D_GAIN = PIDP_D_GAIN; pidP_I_LIMIT = PIDP_I_LIMIT; pidP_EMA_SAMPLES = PIDP_EMA_SAMPLES; PIDinit( &pitchPID[0], &pidP_P_GAIN, &pidP_I_GAIN, &pidP_D_GAIN, &pidP_I_LIMIT, &pidP_EMA_SAMPLES ); PIDinit( &pitchPID[1], &pidP_P_GAIN, &pidP_I_GAIN, &pidP_D_GAIN, &pidP_I_LIMIT, &pidP_EMA_SAMPLES ); /*Set default values and init speedPID controllers*/ pidS_P_GAIN = PIDS_P_GAIN; pidS_I_GAIN = PIDS_I_GAIN; pidS_D_GAIN = PIDS_D_GAIN; pidS_I_LIMIT = PIDS_I_LIMIT; pidS_EMA_SAMPLES = PIDS_EMA_SAMPLES; PIDinit( &speedPID[0], &pidS_P_GAIN, &pidS_I_GAIN, &pidS_D_GAIN, &pidS_I_LIMIT, &pidS_EMA_SAMPLES ); PIDinit( &speedPID[1], &pidS_P_GAIN, &pidS_I_GAIN, &pidS_D_GAIN, &pidS_I_LIMIT, &pidS_EMA_SAMPLES ); //Get estimate of starting angle and specify complementary filter and kalman filter start angles getOrientation(); kalmanAngle = filteredPitch = i2cPitch; setkalmanangle( filteredPitch ); filteredRoll = i2cRoll; print( "Eddie startup complete. Hold me upright to begin\r\n" ); double gy_scale = 0.01; last_PID_ms = last_gy_ms = current_milliseconds(); while(Running) { GetEncoders( EncoderPos ); if( fabs(GetEncoder()) > 2000 && !inRunAwayState ) { print( "Help! I'm running and not moving.\r\n"); ResetEncoders(); inRunAwayState=1; } /*Read IMU and calculate rough angle estimates*/ getOrientation(); /*Calculate time since last IMU reading and determine gyro scale (dt)*/ gy_scale = ( current_milliseconds() - last_gy_ms ) / 1000.0f; last_gy_ms = current_milliseconds(); /*Complementary filters to smooth rough pitch and roll estimates*/ filteredPitch = 0.995 * ( filteredPitch + ( gy * gy_scale ) ) + ( 0.005 * i2cPitch ); filteredRoll = 0.98 * ( filteredRoll + ( gx * gy_scale ) ) + ( 0.02 * i2cRoll ); /*Kalman filter for most accurate pitch estimates*/ kalmanAngle = -getkalmanangle(filteredPitch, gy, gy_scale /*dt*/); /* Monitor angles to determine if Eddie has fallen too far... or if Eddie has been returned upright*/ if ( ( inRunAwayState || ( fabs( kalmanAngle ) > 50 || fabs( filteredRoll ) > 45 ) ) && !inFalloverState ) { #ifndef DISABLE_MOTORS motor_driver_standby(1); #endif inFalloverState = 1; print( "Help! I've fallen over and I can't get up =)\r\n"); } else if ( fabs( kalmanAngle ) < 10 && inFalloverState && fabs( filteredRoll ) < 20 ) { if ( ++inSteadyState == 100 ) { inRunAwayState = 0; inSteadyState = 0; #ifndef DISABLE_MOTORS motor_driver_standby(0); #endif inFalloverState = 0; print( "Thank you!\r\n" ); } } else { inSteadyState = 0; } if ( !inFalloverState ) { /* Drive operations */ smoothedDriveTrim = ( 0.99 * smoothedDriveTrim ) + ( 0.01 * driveTrim ); if( smoothedDriveTrim != 0 ) { EncoderAddPos(smoothedDriveTrim); //Alter encoder position to generate movement } /* Turn operations */ if( turnTrim != 0 ) { EncoderAddPos2( turnTrim, -turnTrim ); //Alter encoder positions to turn } double timenow = current_milliseconds(); speedPIDoutput[0] = PIDUpdate( 0, EncoderPos[0], timenow - last_PID_ms, &speedPID[0] );//Wheel Speed PIDs speedPIDoutput[1] = PIDUpdate( 0, EncoderPos[1], timenow - last_PID_ms, &speedPID[1] );//Wheel Speed PIDs pitchPIDoutput[0] = PIDUpdate( speedPIDoutput[0], kalmanAngle, timenow - last_PID_ms, &pitchPID[0] );//Pitch Angle PIDs pitchPIDoutput[1] = PIDUpdate( speedPIDoutput[1], kalmanAngle, timenow - last_PID_ms, &pitchPID[1] );//Pitch Angle PIDs last_PID_ms = timenow; //Limit PID output to +/-100 to match 100% motor throttle if ( pitchPIDoutput[0] > 100.0 ) pitchPIDoutput[0] = 100.0; if ( pitchPIDoutput[1] > 100.0 ) pitchPIDoutput[1] = 100.0; if ( pitchPIDoutput[0] < -100.0 ) pitchPIDoutput[0] = -100.0; if ( pitchPIDoutput[1] < -100.0 ) pitchPIDoutput[1] = -100.0; } else //We are inFalloverState { ResetEncoders(); pitchPID[0].accumulatedError = 0; pitchPID[1].accumulatedError = 0; speedPID[0].accumulatedError = 0; speedPID[1].accumulatedError = 0; driveTrim = 0; turnTrim = 0; } #ifndef DISABLE_MOTORS set_motor_speed_right( pitchPIDoutput[0] ); set_motor_speed_left( pitchPIDoutput[1] ); #endif if ( (!inFalloverState || outputto == UDP) && StreamData ) { print( "PIDout: %0.2f,%0.2f\tcompPitch: %6.2f kalPitch: %6.2f\tPe: %0.3f\tIe: %0.3f\tDe: %0.3f\tPe: %0.3f\tIe: %0.3f\tDe: %0.3f\r\n", speedPIDoutput[0], pitchPIDoutput[0], filteredPitch, kalmanAngle, pitchPID[0].error, pitchPID[0].accumulatedError, pitchPID[0].differentialError, speedPID[0].error, speedPID[0].accumulatedError, speedPID[0].differentialError ); } } //--while(Running) print( "Eddie is cleaning up...\r\n" ); CloseEncoder(); pthread_join(udplistenerThread, NULL); print( "UDP Thread Joined..\r\n" ); #ifndef DISABLE_MOTORS motor_driver_disable(); print( "Motor Driver Disabled..\r\n" ); #endif print( "Eddie cleanup complete. Good Bye!\r\n" ); return 0; }