Skip to content

Commit 9ac8b90

Browse files
committedMar 16, 2024
adjust pid for hero yaw and pitch params, and echo accumulate angle in angle feedback
1 parent 06b1240 commit 9ac8b90

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed
 

‎dev/application/param_adjusts/pa_hero/can_motor_config.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ CANMotorBase CANMotorCFG::CANMotorProfile[MOTOR_COUNT] = {
99
{CANMotorBase::can_channel_2, 0x201, CANMotorBase::M3508, 3572},//Front Right
1010
{CANMotorBase::can_channel_2, 0x204, CANMotorBase::M3508, 3572},//Back Right
1111
{CANMotorBase::can_channel_2, 0x203, CANMotorBase::M3508, 3572},//Back Left
12-
{CANMotorBase::can_channel_2, 0x208, CANMotorBase::GM6020, 1994},//Yaw
13-
{CANMotorBase::can_channel_1, 0x205, CANMotorBase::GM6020, 3301},//PITCH 侧面的6020
12+
{CANMotorBase::can_channel_2, 0x208, CANMotorBase::GM6020, 70},//Yaw
13+
{CANMotorBase::can_channel_1, 0x205, CANMotorBase::GM6020, 3208},//PITCH 侧面的6020
1414
{CANMotorBase::can_channel_1, 0x201, CANMotorBase::M3508_without_deceleration, 3344},
1515
{CANMotorBase::can_channel_2, 0x206, CANMotorBase::M3508, 3572}, //Bullet Loader
1616
{CANMotorBase::can_channel_1, 0x203, CANMotorBase::M3508_without_deceleration, 3572},//FW_UP(左边)
@@ -22,8 +22,8 @@ PIDController::pid_params_t CANMotorCFG::a2vParams[MOTOR_COUNT] = {
2222
{10, 0.0f, 0.2, 100, 500},
2323
{10, 0.0f, 0.2, 100, 500},
2424
{10, 0.0f, 0.2, 100, 500},
25-
{10, 0.0f, 0.1, 70, 90},
26-
{40., 1.0f, 0.1, 100, 200},
25+
{15, 0.02f, 0.1, 70, 150},
26+
{40., 0.1f, 0.1f, 100, 200},
2727
{10, 0.0f, 0.2, 100, 500},
2828
{50, 0.0f, 0.18, 100, 250},//Bullet Loader temprarily to 2.5x to surpass the friction
2929
{10, 0.0f, 0.2, 100, 500},
@@ -35,8 +35,8 @@ PIDController::pid_params_t CANMotorCFG::v2iParams[MOTOR_COUNT] = {
3535
{26.0f,0.1f,0.02f,2000.0,6000.0},
3636
{26.0f,0.1f,0.02f,2000.0,6000.0},
3737
{26.0f,0.1f,0.02f,2000.0,6000.0},
38-
{50.0f, 0.0f, 0.0f, 5000.0f, 15000.0f},
39-
{ 35.f, 5.f, 0.00f, 5000.0f, 15000.0f},
38+
{35.0f, 1.0f, 1.0f, 5000.0f, 15000.0f},
39+
{ 35.f, 1.f, 0.00f, 5000.0f, 15000.0f},
4040
{26.0f, 0.1f, 0.02f, 2000.0f, 6000.0f},
4141
{35.0f, 2.1f, 0.0f, 3000.0f, 16383.0f},//Bullet Loader
4242
{26.0f, 0.1f, 0.02f, 2000.0f, 6000.0f},

‎dev/application/param_adjusts/pa_hero/pa_hero.cpp

+28-7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const char *motor_name[10] = {
3636
constexpr unsigned USER_THREAD_INTERVAL = 7; // [ms]
3737

3838
float gimbal_yaw_target_angle_ = 0;
39+
float gimbal_pitch_target_angle_= 0.0f;
3940
float gimbal_rc_yaw_max_speed = 180; // [degree/s]
4041

4142
float gimbal_pitch_min_angle = -30; // down range for pitch [degree]
@@ -273,15 +274,35 @@ class TopControlThread : public BaseStaticThread<512> {
273274
setName("TopControlThread");
274275
Remote::rc_status_t previous_rcs1_state = Remote::rc.s1;
275276
CANMotorCFG::motor_id_t vel_group[] = {CANMotorCFG::YAW, CANMotorCFG::PITCH};
276-
CANMotorCFG::motor_id_t angle_group[] = {CANMotorCFG::FL, CANMotorCFG::FR,
277-
CANMotorCFG::BL, CANMotorCFG::BR,
278-
CANMotorCFG::FW_UP, CANMotorCFG::FW_DOWN,
279-
CANMotorCFG::BULLET_LOADER};
277+
CANMotorCFG::motor_id_t angle_group[] = {CANMotorCFG::YAW, CANMotorCFG::PITCH};
280278
while (!shouldTerminate()) {
281-
282279
if (Remote::rc.s1 == Remote::S_DOWN) {
283-
284-
280+
if(previous_rcs1_state == Remote::S_DOWN) {
281+
for(auto &i : angle_group) {
282+
CANMotorCFG::enable_a2v[i] = true;
283+
CANMotorCFG::enable_v2i[i] = true;
284+
}
285+
}
286+
/// Gimbal Response Test through Remote Controller
287+
gimbal_yaw_target_angle_ +=
288+
-Remote::rc.ch0 * 0.7f;
289+
gimbal_pitch_target_angle_ += Remote::rc.ch1 * 0.3f;
290+
291+
VAL_CROP(gimbal_pitch_target_angle_, gimbal_pitch_max_angle, gimbal_pitch_min_angle);
292+
// if the right button is up, adjust Pitch only, if it is down, adjust Yaw only
293+
// if it it in the middle then both
294+
switch(Remote::rc.s2) {
295+
case Remote::S_UP:
296+
gimbal_yaw_target_angle_ = 0.0f;
297+
break;
298+
case Remote::S_DOWN:
299+
gimbal_pitch_target_angle_ = 0.0f;
300+
break;
301+
default:
302+
break;
303+
}
304+
CANMotorController::set_target_angle(CANMotorCFG::PITCH, gimbal_pitch_target_angle_);
305+
CANMotorController::set_target_angle(CANMotorCFG::YAW, gimbal_yaw_target_angle_);
285306
}
286307

287308
if(Remote::rc.s1 == Remote::S_UP){

‎dev/interface/can_motor/can_motor_controller.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void CANMotorController::feedbackThread::main() {
177177
Shell::printf("!fb,%u,%u,%.2f,%.2f,%.2f,%.2f,%d,%d" SHELL_NEWLINE_STR,
178178
SYSTIME,
179179
i, // Motor ID
180-
CANMotorIF::motor_feedback[i].actual_angle, CANMotorController::SKDThread.targetA[i],
180+
CANMotorIF::motor_feedback[i].accumulate_angle(), CANMotorController::SKDThread.targetA[i],
181181
CANMotorIF::motor_feedback[i].actual_velocity, CANMotorController::SKDThread.targetV[i],
182182
CANMotorIF::motor_feedback[i].torque_current(), (int)CANMotorController::SKDThread.PID_output[i]);
183183
}

0 commit comments

Comments
 (0)