Shao Rui / CH_Communicatuin_Test

Dependencies:   mbed-dev_spine

Committer:
WXD
Date:
Tue Oct 08 04:35:23 2019 +0000
Revision:
5:6a95726e45b0
Child:
6:aad89fd109c2
qqq

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WXD 5:6a95726e45b0 1 #include "control.h"
WXD 5:6a95726e45b0 2
WXD 5:6a95726e45b0 3
WXD 5:6a95726e45b0 4 unsigned int send_enable = 0;
WXD 5:6a95726e45b0 5
WXD 5:6a95726e45b0 6
WXD 5:6a95726e45b0 7 void control()
WXD 5:6a95726e45b0 8 {
WXD 5:6a95726e45b0 9 if(c_control == 1)
WXD 5:6a95726e45b0 10 command_control();
WXD 5:6a95726e45b0 11
WXD 5:6a95726e45b0 12 if(c_lock == 1) // 处于PC串口锁定模式
WXD 5:6a95726e45b0 13 {
WXD 5:6a95726e45b0 14 cal_command.q_des_pf = SP_pf;
WXD 5:6a95726e45b0 15 cal_command.qd_des_pf = 0.0f;
WXD 5:6a95726e45b0 16 cal_command.kp_pf = 800.0f;
WXD 5:6a95726e45b0 17 cal_command.kd_pf = 100.0f;
WXD 5:6a95726e45b0 18 cal_command.tau_pf_ff = 0.0f;
WXD 5:6a95726e45b0 19
WXD 5:6a95726e45b0 20 cal_command.q_des_df = SP_df;
WXD 5:6a95726e45b0 21 cal_command.qd_des_df = 0.0f;
WXD 5:6a95726e45b0 22 cal_command.kp_df = 800.0f;
WXD 5:6a95726e45b0 23 cal_command.kd_df = 100.0f;
WXD 5:6a95726e45b0 24 cal_command.tau_df_ff = 0.0f;
WXD 5:6a95726e45b0 25 }
WXD 5:6a95726e45b0 26
WXD 5:6a95726e45b0 27 if(c_lock == 0)
WXD 5:6a95726e45b0 28 {
WXD 5:6a95726e45b0 29 calculate_pf();
WXD 5:6a95726e45b0 30 calculate_df();
WXD 5:6a95726e45b0 31 }
WXD 5:6a95726e45b0 32
WXD 5:6a95726e45b0 33 // 将计算得到的数值赋给控制器
WXD 5:6a95726e45b0 34 a_control.pf.p_des = cal_command.q_des_pf;
WXD 5:6a95726e45b0 35 a_control.pf.v_des = cal_command.qd_des_pf;
WXD 5:6a95726e45b0 36 a_control.pf.kp = cal_command.kp_pf;
WXD 5:6a95726e45b0 37 a_control.pf.kd = cal_command.kd_pf;
WXD 5:6a95726e45b0 38 a_control.pf.t_ff = cal_command.tau_pf_ff;
WXD 5:6a95726e45b0 39
WXD 5:6a95726e45b0 40 a_control.df.p_des = cal_command.q_des_df;
WXD 5:6a95726e45b0 41 a_control.df.v_des = cal_command.qd_des_df;
WXD 5:6a95726e45b0 42 a_control.df.kp = cal_command.kp_df;
WXD 5:6a95726e45b0 43 a_control.df.kd = cal_command.kd_df;
WXD 5:6a95726e45b0 44 a_control.df.t_ff = cal_command.tau_df_ff;
WXD 5:6a95726e45b0 45 }
WXD 5:6a95726e45b0 46
WXD 5:6a95726e45b0 47
WXD 5:6a95726e45b0 48
WXD 5:6a95726e45b0 49
WXD 5:6a95726e45b0 50
WXD 5:6a95726e45b0 51
WXD 5:6a95726e45b0 52
WXD 5:6a95726e45b0 53
WXD 5:6a95726e45b0 54
WXD 5:6a95726e45b0 55
WXD 5:6a95726e45b0 56
WXD 5:6a95726e45b0 57
WXD 5:6a95726e45b0 58
WXD 5:6a95726e45b0 59