void tpl_init_machine(void) { nxt_device_init(); tpl_init_machine_generic(); InitButtons(); ecrobot_set_motor_rev(NXT_PORT_A, 0); ecrobot_set_motor_rev(NXT_PORT_B, 0); ecrobot_set_motor_rev(NXT_PORT_C, 0); }
//初期処理 void ecrobot_device_initialize(void) { ecrobot_set_light_sensor_active(NXT_PORT_S3); ecrobot_init_bt_slave("LEJOS-OSEK"); ecrobot_set_motor_rev(NXT_PORT_A,0); ecrobot_set_motor_rev(NXT_PORT_B,0); ecrobot_set_motor_rev(NXT_PORT_C,0); }
//初期処理関数(プログラムの最初に呼び出し) void ecrobot_device_initialize(void){ ecrobot_set_light_sensor_active(NXT_PORT_S3); //光センサ起動 ecrobot_init_bt_slave("LEJOS-OSEK"); //Bluetooth起動 ecrobot_init_sonar_sensor(NXT_PORT_S2); //超音波センサ起動 //モータリセット ecrobot_set_motor_rev(NXT_PORT_A,0); ecrobot_set_motor_rev(NXT_PORT_B,0); ecrobot_set_motor_rev(NXT_PORT_C,0); ecrobot_set_motor_speed(NXT_PORT_A,0); ecrobot_set_motor_speed(NXT_PORT_B,0); ecrobot_set_motor_speed(NXT_PORT_C,0); }
//後始末処理関数(プログラム終了時呼び出し) void ecrobot_device_terminate(void) { ecrobot_set_light_sensor_inactive(NXT_PORT_S3); //光センサ終了 ecrobot_term_bt_connection(); //Bluetooth終了 //モータリセット ecrobot_set_motor_rev(NXT_PORT_A,0); ecrobot_set_motor_rev(NXT_PORT_B,0); ecrobot_set_motor_rev(NXT_PORT_C,0); ecrobot_set_motor_speed(NXT_PORT_A, 0); ecrobot_set_motor_speed(NXT_PORT_B, 0); ecrobot_set_motor_speed(NXT_PORT_C, 0); }
//後始末処理関数(プログラム終了時呼び出し) void ecrobot_device_terminate(void){ tail_mode = RN_TAILUP; //尻尾を上げる(意味あるのか?) ecrobot_set_light_sensor_inactive(NXT_PORT_S3); //光センサ終了 ecrobot_term_sonar_sensor(NXT_PORT_S2); //超音波センサ終了 ecrobot_term_bt_connection(); //Bluetooth終了 //モータリセット ecrobot_set_motor_rev(NXT_PORT_A,0); ecrobot_set_motor_rev(NXT_PORT_B,0); ecrobot_set_motor_rev(NXT_PORT_C,0); ecrobot_set_motor_speed(NXT_PORT_A, 0); ecrobot_set_motor_speed(NXT_PORT_B, 0); ecrobot_set_motor_speed(NXT_PORT_C, 0); }
//走行体状態設定関数 void RN_modesetting(){ switch (runner_mode){ //走行体初期状態 case (RN_MODE_INIT): cmd_forward = 0; cmd_turn = 0; ecrobot_set_motor_rev(NXT_PORT_B,0); ecrobot_set_motor_rev(NXT_PORT_C,0); nxt_motor_set_speed(NXT_PORT_C, 0, 1); nxt_motor_set_speed(NXT_PORT_B, 0, 1); break; //バランサー case (RN_MODE_BALANCE): balance_control( (F32)cmd_forward, (F32)cmd_turn, (F32)ecrobot_get_gyro_sensor(NXT_PORT_S1), (F32)gyro_offset, (F32)nxt_motor_get_count(NXT_PORT_C), (F32)nxt_motor_get_count(NXT_PORT_B), (F32)ecrobot_get_battery_voltage(), &pwm_l, &pwm_r); nxt_motor_set_speed(NXT_PORT_C, pwm_l, 1); nxt_motor_set_speed(NXT_PORT_B, pwm_r, 1); break; //バランサー無し case (RN_MODE_BALANCEOFF): break; default: nxt_motor_set_speed(NXT_PORT_C, 0, 1); nxt_motor_set_speed(NXT_PORT_B, 0, 1); break; } }
/** * BalancerUnitの初期化処理 */ void BLNU_pre(void) { ecrobot_set_motor_rev(L_MOTOR_PORT, 0); ecrobot_set_motor_rev(R_MOTOR_PORT, 0); balance_init(); BLNU_motor_angle_control = false; }