|
@@ -234,42 +234,17 @@ void AP_Motors6DOF::output_min()
|
|
|
#define MAXDUTY 88000
|
|
|
int32_t AP_Motors6DOF::calc_thrust_to_motor(float thrust_in,int8_t i)
|
|
|
{
|
|
|
- int16_t thrust = 0;
|
|
|
+ int32_t thrust32b = 0;
|
|
|
|
|
|
|
|
|
//int16_t stephv = 500;
|
|
|
- thrust = (int32_t)(thrust_in* ThrustScale);
|
|
|
- /*
|
|
|
-
|
|
|
- if (thrust>=last_thrust_Dhot[i] - stephv && thrust<=last_thrust_Dhot[i] + stephv){
|
|
|
-
|
|
|
- last_thrust_Dhot[i] = thrust;
|
|
|
- }else if (thrust >= last_thrust_Dhot[i] + stephv)
|
|
|
- {//新的Dshot >当前的Dshot + 步长
|
|
|
- last_thrust_Dhot[i] += stephv;
|
|
|
- }
|
|
|
- else if(thrust <= last_thrust_Dhot[i] -stephv)
|
|
|
- {//新的Dshot < 当前的Dshot -步长
|
|
|
- last_thrust_Dhot[i] -= stephv;
|
|
|
- }
|
|
|
-
|
|
|
- if (last_thrust_Dhot[i]< stephv && last_thrust_Dhot[i]> -stephv)
|
|
|
- {
|
|
|
- last_thrust_Dhot[i] =0;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- static int k = 0;
|
|
|
- k++;
|
|
|
- if(k>400)
|
|
|
- {
|
|
|
-
|
|
|
- //gcs().send_text(MAV_SEVERITY_INFO, "_thrust_rpyt_out %d %d ,%d \n",(int)last_thrust_Dhot[2],(int)last_thrust_Dhot[3],(int)last_thrust_Dhot[4]);
|
|
|
- }
|
|
|
- //int16_t speedref = last_thrust_Dhot[i]*hv_max/1000;
|
|
|
- //return constrain_int16(speedref,-hv_max, hv_max);
|
|
|
- */
|
|
|
- int16_t speedref = thrust;//last_thrust_Dhot[i];
|
|
|
+ thrust32b = (int32_t)(thrust_in* ThrustScale);
|
|
|
+
|
|
|
+ int32_t speedref = thrust32b;//last_thrust_Dhot[i];
|
|
|
+ if (speedref>-10000 && speedref<10000)
|
|
|
+ {
|
|
|
+ speedref = 0;
|
|
|
+ }
|
|
|
return constrain_int32(speedref,-MAXDUTY, MAXDUTY);
|
|
|
|
|
|
|
|
@@ -322,8 +297,8 @@ void AP_Motors6DOF::output_to_Dshot()
|
|
|
//将上位机转发过来的,转换成Dshot协议并使用CAN 转发
|
|
|
if(mav_motor_speed.motorTest == 1)
|
|
|
{//测试模式上位机直接控制 仅仅控制6个推进器
|
|
|
- motor_to_can[0] =(int32_t)mav_motor_speed.motor1*ThrustScale;//230 才启动
|
|
|
- motor_to_can[1] =(int32_t)mav_motor_speed.motor2*ThrustScale;
|
|
|
+ motor_to_can[0] =(int32_t)(mav_motor_speed.motor1*ThrustScale);//230 才启动
|
|
|
+ motor_to_can[1] =(int32_t)(mav_motor_speed.motor2*ThrustScale);
|
|
|
motor_to_can[2] = (int32_t)mav_motor_speed.motor3*ThrustScale/2000;
|
|
|
motor_to_can[3] = (int32_t)mav_motor_speed.motor4*ThrustScale/2000;//大于100能动
|
|
|
motor_to_can[4] = (int32_t)mav_motor_speed.motor5*ThrustScale/2000;
|
|
@@ -354,8 +329,9 @@ void AP_Motors6DOF::output_to_Dshot()
|
|
|
k++;
|
|
|
if(k>400)
|
|
|
{
|
|
|
-
|
|
|
- //gcs().send_text(MAV_SEVERITY_INFO, "motor_out %d %d %d %d\n", (int)mav_motor_speed.motorTest,(int)motor_to_can[2],(int)motor_to_can[3], (int)motor_to_can[4]);
|
|
|
+ //gcs().send_text(MAV_SEVERITY_INFO, "motor_out1 %f %f %f \n", (float)motor_to_can[0],(float)motor_to_can[1],(float)motor_to_can[2]);
|
|
|
+
|
|
|
+ //gcs().send_text(MAV_SEVERITY_INFO, "motor_out %f %f %d \f", (float)motor_to_can[3],(float)motor_to_can[4], (float)motor_to_can[5]);
|
|
|
k=0;
|
|
|
}
|
|
|
}
|
|
@@ -365,24 +341,26 @@ int16_t AP_Motors6DOF::calc_thrust_to_pwm(float thrust_in) const
|
|
|
return constrain_int16(1500 + thrust_in * 500, _throttle_radio_min, _throttle_radio_max);
|
|
|
}
|
|
|
void AP_Motors6DOF::output_motor8_and_motor9(){
|
|
|
- int8_t i;
|
|
|
+
|
|
|
if(mav_motor_speed.motorTest == 1)
|
|
|
{
|
|
|
|
|
|
rc_write(6, calc_thrust_to_pwm((float)mav_motor_speed.Ltrack/260));;//切换成上位机控制 左履带
|
|
|
rc_write(7, calc_thrust_to_pwm((float)mav_motor_speed.Rtrack/260));;//切换成上位机控制 右履带
|
|
|
}else{
|
|
|
- for (i=6; i<8; i++) {
|
|
|
+
|
|
|
|
|
|
- rc_write(i, pwm_track[i-6]);
|
|
|
- }
|
|
|
+ rc_write(6, pwm_track[0]);
|
|
|
+ rc_write(7, pwm_track[1]);
|
|
|
+
|
|
|
}
|
|
|
static int k = 0;
|
|
|
k++;
|
|
|
if(k>400)
|
|
|
{
|
|
|
|
|
|
- gcs().send_text(MAV_SEVERITY_INFO, "mav_motor_speed %d %f %f \n", (int)mav_motor_speed.motorTest,(float)mav_motor_speed.Ltrack/260,(float)mav_motor_speed.Rtrack/260);
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, "motor_speed %d %d \n", pwm_track[0],pwm_track[1]);
|
|
|
+ gcs().send_text(MAV_SEVERITY_INFO, "motor_speed %d %d %d \n", (int)mav_motor_speed.motorTest,calc_thrust_to_pwm((float)mav_motor_speed.Ltrack/260),calc_thrust_to_pwm((float)mav_motor_speed.Rtrack/260));
|
|
|
k=0;
|
|
|
}
|
|
|
|