Skip to content

Commit

Permalink
dart can shoot within 10 seconds now. Mechanical parts broken, so tes…
Browse files Browse the repository at this point in the history
…t is not complete.
  • Loading branch information
Raventhatfly committed Jul 26, 2023
1 parent 539da93 commit b83ab10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions dev/application/vehicles/dart/can_motor_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ CANMotorBase CANMotorCFG::CANMotorProfile[MOTOR_COUNT] = {

PIDController::pid_params_t CANMotorCFG::a2vParams[MOTOR_COUNT] = {
{20, 0.0f, 500, 000, 550},
{10, 0, 0.2, 100, 500},
{10, 0, 0.2, 100, 500},
{20, 0, 0.2, 100, 3000},
{20, 0, 0.2, 100, 3000},
{10, 0, 0.2, 100, 500},
};

PIDController::pid_params_t CANMotorCFG::v2iParams[MOTOR_COUNT] = {
{15.0f,0.0f,5.0f,5000,30000.0},
{26.0f, 0.1f, 0.02f, 2000.0, 6000.0},
{26.0f, 0.1f, 0.02f, 2000.0, 6000.0},
{50.0f, 0.1f, 0.02f, 2000.0, 6000.0},
{50.0f, 0.1f, 0.02f, 2000.0, 6000.0},
{26.0f, 0.1f, 0.02f, 2000.0, 6000.0},
};

Expand Down
18 changes: 13 additions & 5 deletions dev/application/vehicles/dart/user_dart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void UserDart::UserThread::main(){
angle = feedback.accumulate_angle();
Rudder rudder1(&PWMD4, nullptr,0,Rudder::MG995);
rudder1.start();
start_flag = true;
start_flag = false;
timer_started = false;
static virtual_timer_t release_vt;
chVTObjectInit(&release_vt);
Expand Down Expand Up @@ -78,7 +78,7 @@ void UserDart::UserThread::main(){
CANMotorController::set_target_angle(CANMotorCFG::YAW,angle);
uint8_t status = Referee::dart_client.dart_launch_opening_status;
if(status == 0){
if(Remote::rc.ch3 > 0.2){
if(Remote::rc.wheel > 0.2){
start_flag = true;
}
if(start_flag){
Expand All @@ -87,11 +87,11 @@ void UserDart::UserThread::main(){
timer_started = true;
}
current_time = TIME_I2MS(chVTGetSystemTimeX());
if(current_time - start_time < 12000){
if(current_time - start_time < 2000){
CANMotorController::set_target_angle(CANMotorCFG::STORE_ENERGY_LEFT,3900);
CANMotorController::set_target_angle(CANMotorCFG::STORE_ENERGY_RIGHT,-3900);

chThdSleepSeconds(1);
chThdSleepMilliseconds(5);
CANMotorCFG::enable_a2v[CANMotorCFG::STORE_ENERGY_LEFT] = false;
CANMotorCFG::enable_v2i[CANMotorCFG::STORE_ENERGY_LEFT] = false;
CANMotorCFG::enable_a2v[CANMotorCFG::STORE_ENERGY_RIGHT] = false;
Expand All @@ -101,9 +101,17 @@ void UserDart::UserThread::main(){
CANMotorCFG::enable_v2i[CANMotorCFG::STORE_ENERGY_LEFT] = true;
CANMotorCFG::enable_a2v[CANMotorCFG::STORE_ENERGY_RIGHT] = true;
CANMotorCFG::enable_v2i[CANMotorCFG::STORE_ENERGY_RIGHT] = true;
}else if(current_time - start_time >= 12000){
}else if(current_time - start_time >= 2000 && current_time - start_time < 4000){
CANMotorController::set_target_angle(CANMotorCFG::STORE_ENERGY_LEFT,0);
CANMotorController::set_target_angle(CANMotorCFG::STORE_ENERGY_RIGHT,0);

}else if(current_time -start_time >= 4000 && current_time - start_time < 6000){
rudder1.set_rudder_angle(0);
chThdSleepMilliseconds(900);
rudder1.set_rudder_angle(180);
chThdSleepMilliseconds(900);
}else if(current_time > 8000){
start_flag = false;
timer_started = false;
}
}
Expand Down

0 comments on commit b83ab10

Please sign in to comment.