void thread_body (void const *args) { while(1) { if (can_msg_is_missing(CAN_MISSING_CMD_BODY_ID)) stop_body(); else { //if a message has been received, set lights if (can_cmd_body.flag == CAN_FLAG_RECEIVED) { light_r = can_cmd_body.payload.msg.light_r; light_l = can_cmd_body.payload.msg.light_l; light_c = can_cmd_body.payload.msg.light_c; can_cmd_body.flag = CAN_FLAG_EMPTY; } } //send sensors' values can_sts_body.payload.msg.eye_l = read_distance(&back_l); can_sts_body.payload.msg.eye_r = read_distance(&back_r); can_sts_body.payload.msg.hit_front = hit_front.read(); can_sts_body.payload.msg.hit_rear = hit_rear.read(); can_sts_body.payload.msg.hit_left = hit_left.read(); can_sts_body.payload.msg.hit_right = hit_right.read(); can_sts_body.payload.msg.light_sens = photo.read(); #ifdef DEBUG printf("HIT: %d %d %d %d\n\r", hit_front.read(), hit_rear.read(), hit_left.read(), hit_right.read()); printf("EYE: %d %d\n\r", can_sts_body.payload.msg.eye_l, can_sts_body.payload.msg.eye_r); #endif // Thread::wait(BODY_THREAD_PERIOD); osThreadEndPeriod(); } }
void listen_sonar(void) { for(;;) { s_forward= read_distance(); Task_Next(); s_right = read_distance(); Task_Next(); s_left = read_distance(); Task_Next(); } }
// Main function void main(void) { reset_peripheral(); initClock(); initTimer(); initDisplay(); initPin(); initGPIO(); initADC(); initConsole(); int i = 0; //init_password(); send_data(); initCircBuf (&speed_buffer, BUF_SIZE); init_set_speed_data(&speed_set_data); int screen = 0; int screen_prev = 0; float speed = 0; float buffed_speed = 0; int fake_speed = 0; float acc = 0; float max_acc = 0; //float fuel_eco = 0; float distance = 0; bool fix = 0; uint8_t satillite = 0; float quality = 0; clock time; int aim_pos = 0; unsigned long adc = 0; //int error_stepper = 0; IntMasterEnable(); while(1){ //reading data read_data = split_data(UART_char_data_old, read_data); // decode data speed = read_speed(); //read data into variables adc = run_adc()/7; //calculations aim_pos = speed_feedback(buffed_speed, encoder_1/40, speed_set_data.speed); if (speed_set_data.enable == 1){ step_motor_control(encoder_1/40, aim_pos); } //sending fake data fake_speed = (int)adc;//= random_at_most(100/1.852); send_info(fake_speed);//knots //storing data store_speed(speed); buffed_speed = analysis_speed(); acc = read_acceleration(buffed_speed); max_acc = max_acc_func(acc, max_acc); time = read_time(); satillite = read_satillite(); fix = read_fix(); quality = read_quality(); debounce_button(); // debounce buttons screen = read_button_screen(screen, fix); distance = read_distance(); select_read(); //need a mosfet for turning power off // select adds a an on and off switch yo if (screen == 1){ if(screen_prev != 1 && screen == 1){ speed_set_data.speed = buffed_speed; } speed_set_data.speed = set_speed(speed_set_data.speed); // set the speed to cruise at } if (screen == 2){ //0 to 100 acceleration_test(speed); } // refresh chainging if (fix == 1 && speed_set_data.old == speed_set_data.speed && refresh_rate < 4){ UARTSend((unsigned char *)PMTK_SET_NMEA_UPDATE_5HZ, 18, 0); refresh_rate += 1; } if (i >= 50){ display(screen, buffed_speed, acc, max_acc, speed_set_data.speed, satillite, encoder_1/40, time, distance, quality, UART_char_data_old, aim_pos, adc, acc_times); i = 0; } screen_prev = screen; i++; } }
void CPseudoGigant::Load(LPCSTR section) { inherited::Load (section); anim().AddReplacedAnim(&m_bDamaged, eAnimRun, eAnimRunDamaged); anim().AddReplacedAnim(&m_bDamaged, eAnimWalkFwd, eAnimWalkDamaged); //anim().AddReplacedAnim(&m_bRunTurnLeft, eAnimRun, eAnimRunTurnLeft); //anim().AddReplacedAnim(&m_bRunTurnRight, eAnimRun, eAnimRunTurnRight); anim().accel_load (section); //anim().accel_chain_add (eAnimWalkFwd, eAnimRun); //anim().accel_chain_add (eAnimWalkFwd, eAnimRunTurnLeft); //anim().accel_chain_add (eAnimWalkFwd, eAnimRunTurnRight); //anim().accel_chain_add (eAnimWalkDamaged, eAnimRunDamaged); step_effector.time = pSettings->r_float(section, "step_effector_time"); step_effector.amplitude = pSettings->r_float(section, "step_effector_amplitude"); step_effector.period_number = pSettings->r_float(section, "step_effector_period_number"); SVelocityParam &velocity_none = move().get_velocity(MonsterMovement::eVelocityParameterIdle); SVelocityParam &velocity_turn = move().get_velocity(MonsterMovement::eVelocityParameterStand); SVelocityParam &velocity_walk = move().get_velocity(MonsterMovement::eVelocityParameterWalkNormal); // SVelocityParam &velocity_run = move().get_velocity(MonsterMovement::eVelocityParameterRunNormal); SVelocityParam &velocity_walk_dmg = move().get_velocity(MonsterMovement::eVelocityParameterWalkDamaged); // SVelocityParam &velocity_run_dmg = move().get_velocity(MonsterMovement::eVelocityParameterRunDamaged); SVelocityParam &velocity_steal = move().get_velocity(MonsterMovement::eVelocityParameterSteal); anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimRun, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimRunDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandIdle, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandTurnLeft, "stand_turn_ls_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandTurnRight, "stand_turn_rs_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimLieIdle, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimSitIdle, "sit_idle_", -1, &velocity_none, PS_SIT, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimSleep, "stand_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimWalkFwd, "stand_walk_fwd_", -1, &velocity_walk, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimWalkDamaged, "stand_walk_fwd_dmg_", -1, &velocity_walk_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimRun, "stand_run_fwd_", -1, &velocity_run, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimRunDamaged, "stand_run_dmg_", -1, &velocity_run_dmg, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimEat, "stand_eat_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimAttack, "stand_attack_", -1, &velocity_turn, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimLookAround, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimSteal, "stand_steal_", -1, &velocity_steal, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimDie, "stand_idle_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimStandLieDown, "stand_lie_down_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimLieToSleep, "lie_to_sleep_", -1, &velocity_none, PS_LIE, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); //anim().AddAnim(eAnimThreaten, "stand_kick_", -1, &velocity_none, PS_STAND, "fx_stand_f", "fx_stand_b", "fx_stand_l", "fx_stand_r"); // anim().AddAnim(eAnimRunTurnLeft, "stand_run_left_", -1, &velocity_run, PS_STAND); // anim().AddAnim(eAnimRunTurnRight, "stand_run_right_", -1, &velocity_run, PS_STAND); anim().LinkAction(ACT_STAND_IDLE, eAnimStandIdle); anim().LinkAction(ACT_SIT_IDLE, eAnimSitIdle); anim().LinkAction(ACT_LIE_IDLE, eAnimLieIdle); anim().LinkAction(ACT_WALK_FWD, eAnimWalkFwd); anim().LinkAction(ACT_WALK_BKWD, eAnimWalkFwd); anim().LinkAction(ACT_RUN, eAnimRun); anim().LinkAction(ACT_EAT, eAnimEat); anim().LinkAction(ACT_SLEEP, eAnimSleep); anim().LinkAction(ACT_REST, eAnimSleep); anim().LinkAction(ACT_DRAG, eAnimWalkFwd); anim().LinkAction(ACT_ATTACK, eAnimAttack); anim().LinkAction(ACT_STEAL, eAnimSteal); anim().LinkAction(ACT_LOOK_AROUND, eAnimStandIdle); // define transitions anim().AddTransition(eAnimStandLieDown, eAnimSleep, eAnimLieToSleep, false); anim().AddTransition(PS_STAND, eAnimSleep, eAnimStandLieDown, true); anim().AddTransition(PS_STAND, PS_LIE, eAnimStandLieDown, false); #ifdef DEBUG anim().accel_chain_test (); #endif // Load psi postprocess -------------------------------------------------------- LPCSTR ppi_section = pSettings->r_string(section, "threaten_effector"); m_threaten_effector.ppi.duality.h = pSettings->r_float(ppi_section,"duality_h"); m_threaten_effector.ppi.duality.v = pSettings->r_float(ppi_section,"duality_v"); m_threaten_effector.ppi.gray = pSettings->r_float(ppi_section,"gray"); m_threaten_effector.ppi.blur = pSettings->r_float(ppi_section,"blur"); m_threaten_effector.ppi.noise.intensity = pSettings->r_float(ppi_section,"noise_intensity"); m_threaten_effector.ppi.noise.grain = pSettings->r_float(ppi_section,"noise_grain"); m_threaten_effector.ppi.noise.fps = pSettings->r_float(ppi_section,"noise_fps"); VERIFY(!fis_zero(m_threaten_effector.ppi.noise.fps)); sscanf(pSettings->r_string(ppi_section,"color_base"), "%f,%f,%f", &m_threaten_effector.ppi.color_base.r, &m_threaten_effector.ppi.color_base.g, &m_threaten_effector.ppi.color_base.b); sscanf(pSettings->r_string(ppi_section,"color_gray"), "%f,%f,%f", &m_threaten_effector.ppi.color_gray.r, &m_threaten_effector.ppi.color_gray.g, &m_threaten_effector.ppi.color_gray.b); sscanf(pSettings->r_string(ppi_section,"color_add"), "%f,%f,%f", &m_threaten_effector.ppi.color_add.r, &m_threaten_effector.ppi.color_add.g, &m_threaten_effector.ppi.color_add.b); m_threaten_effector.time = pSettings->r_float(ppi_section,"time"); m_threaten_effector.time_attack = pSettings->r_float(ppi_section,"time_attack"); m_threaten_effector.time_release = pSettings->r_float(ppi_section,"time_release"); m_threaten_effector.ce_time = pSettings->r_float(ppi_section,"ce_time"); m_threaten_effector.ce_amplitude = pSettings->r_float(ppi_section,"ce_amplitude"); m_threaten_effector.ce_period_number = pSettings->r_float(ppi_section,"ce_period_number"); m_threaten_effector.ce_power = pSettings->r_float(ppi_section,"ce_power"); // -------------------------------------------------------------------------------- ::Sound->create(m_sound_threaten_hit,pSettings->r_string(section,"sound_threaten_hit"), st_Effect,SOUND_TYPE_WORLD); ::Sound->create(m_sound_start_threaten,pSettings->r_string(section,"sound_threaten_start"), st_Effect,SOUND_TYPE_MONSTER_ATTACKING); m_kick_damage = pSettings->r_float(section,"HugeKick_Damage"); m_kick_particles = pSettings->r_string(section,"HugeKick_Particles"); read_distance (section,"HugeKick_MinMaxDist", m_threaten_dist_min, m_threaten_dist_max); read_delay (section,"HugeKick_MinMaxDelay", m_threaten_delay_min, m_threaten_delay_max); m_time_kick_actor_slow_down = pSettings->r_u32(section,"HugeKick_Time_SlowDown"); PostLoad (section); }