emuflight / EmuFlight

EmuFlight is flight controller software (firmware) used to fly multi-rotor craft.
GNU General Public License v3.0
451 stars 115 forks source link

Issue:The motor that pushes backwards in 3D flight mode responds incorrectly #873

Closed DiehardFPV closed 2 months ago

DiehardFPV commented 1 year ago

Recently tried the 3D flight mode, using firmware 0.4.1, there was no problem when testing at the configurator (accurate steering And the direction of thrust is correct), and the forward flight was normal, but the reverse flight would immediately roll over(it feels like there is a problem with the rotational logic of the motor when flying backwards);But the same setup flies fine with BF firmware

Flight controller configuration:diff data

# version
# EmuFlight / HOWI_HOBBYWING_XROTORF7CONV (S7X2) 0.4.1 Jul 29 2022 / 13:28:00 (7bac6ddd0) MSP API: 1.51

board_name 
manufacturer_id 

# name
name CIDA_225

# resources

# mixer

# servo

# servo mix

# feature
feature -DYNAMIC_FILTER
feature 3D
feature ESC_SENSOR

# master
set gyro_sync_denom = 2
set gyro_lowpass_hz_roll = 130
set gyro_lowpass_hz_pitch = 130
set gyro_lowpass_hz_yaw = 100
set imuf_roll_q = 7000
set imuf_pitch_q = 7000
set imuf_yaw_q = 7000
set gyro_use_32khz = ON
set dynamic_gyro_notch_count = 1
set smith_predict_filt_hz = 20
set acc_calibration = -40,34,-52
set mag_hardware = NONE
set rssi_channel = 15
set rc_interp = AUTO
set rc_smoothing_input_hz = 0
set rc_smoothing_input_type = PT1
set serialrx_provider = CRSF
set blackbox_device = NONE
set dshot_idle_value = 360
set failsafe_off_delay = 20
set failsafe_throttle = 1300
set vbat_min_cell_voltage = 34
set yaw_motors_reversed = ON
set 3d_deadband_throttle = 20
set deadband = 3
set yaw_deadband = 3
set pid_process_denom = 2
set osd_rssi_pos = 2084
set osd_crsf_tx_pos = 2147
set osd_flymode_pos = 2133
set osd_vtx_channel_pos = 2100
set osd_crosshairs_pos = 2253
set osd_current_pos = 2091
set osd_craft_name_pos = 2506
set osd_altitude_pos = 2115
set osd_warnings_pos = 2441
set osd_avg_cell_voltage_pos = 2434
set osd_core_temp_pos = 2455
set osd_stat_max_spd = OFF
set osd_stat_max_alt = ON
set osd_stat_bb_no = OFF
set debug_mode = GYRO_SCALED
set cpu_overclock = 240MHZ
set vtx_channel = 5
set vtx_power = 4
set vtx_freq = 5820
set camera_control_mode = DAC

# profile
profile 0

set dterm_abg_alpha = 550
set dterm_abg_boost = 650
set dterm_abg_half_life = 250
set dterm_lowpass_hz_roll = 105
set dterm_lowpass_hz_pitch = 105
set dterm_lowpass_hz_yaw = 100
set dterm_lowpass2_hz_roll = 185
set dterm_lowpass2_hz_pitch = 185
set dterm_lowpass2_hz_yaw = 160
set iterm_relax_cutoff = 8
set iterm_relax_cutoff_yaw = 15
set pidsum_limit_yaw = 500
set throttle_boost = 6
set throttle_boost_cutoff = 25
set feathered_pids = 40
set i_decay = 7
set emu_boost = 150
set emu_boost_yaw = 125
set emu_boost_limit = 50
set emu_boost_limit_yaw = 30
set emu_gravity = 70
set axis_lock_multiplier = 7
set axis_lock_hz = 15
set p_pitch = 65
set i_pitch = 115
set d_pitch = 41
set p_roll = 61
set i_roll = 105
set d_roll = 43
set i_yaw = 105
set d_yaw = 3
set df_yaw = 50
set linear_thrust_low_output = 68
set linear_thrust_high_output = 15
set linear_throttle = ON
set mixer_laziness = ON

hardware

Maybe I have some setup errors Thanks for the answer, I really don't want to go back to BF when having 3 drones flashed EMUF

nerdCopter commented 1 year ago

I'll let someone else answer this, but please do set demag-compensation = high for unrelated reasons.

DiehardFPV commented 1 year ago

Thank you so much

BeauBrewski commented 1 year ago

Have you tested it on the bench (no props please, unless you ratchet strap that sucker down and test at a safe distance)? This will give a better understanding if its all motors, certain motors, etc.

Edit: Reading through old discord chat. This is a known issue and will work fine on bench then flip out in air. I believe it came about with introduction of 0.4.0. However your FC doesn't have a 0.3.x firmware version (@nerdCopter how hard would it be to get an 0.3.x version ported?). As far as I can see, there were attempts to fix, but not enough consistent feedback from test pilots to ever get it figured out.

nerdCopter commented 1 year ago

@Quick-Flash thinks it logic bug, but did not yet reply. we briefly discussed in discord.

DiehardFPV commented 1 year ago

Have you tested it on the bench (no props please, ~unless you ratchet strap that sucker down and test at a safe distance~)? This will give a better understanding if its all motors, certain motors, etc.

Edit: Reading through old discord chat. This is a known issue and will work fine on bench then flip out in air. I believe it came about with introduction of 0.4.0. However your FC doesn't have a 0.3.x firmware version (@nerdCopter how hard would it be to get an 0.3.x version ported?). As far as I can see, there were attempts to fix, but not enough consistent feedback from test pilots to ever get it figured out.

Yes, I started testing at the configurator(props off), the motors are spinning normally and the response is correct, but it seems that when I pick up the drone, the yaw axis will twitch left and right,. I will try to find a FC that can flash 0.3.x firmware, thanks for your reply~

Quick-Flash commented 1 year ago

Have you tested it on the bench (no props please, ~unless you ratchet strap that sucker down and test at a safe distance~)? This will give a better understanding if its all motors, certain motors, etc.

Edit: Reading through old discord chat. This is a known issue and will work fine on bench then flip out in air. I believe it came about with introduction of 0.4.0. However your FC doesn't have a 0.3.x firmware version (@nerdCopter how hard would it be to get an 0.3.x version ported?). As far as I can see, there were attempts to fix, but not enough consistent feedback from test pilots to ever get it figured out.

Yes, I started testing at the configurator(props off), the motors are spinning normally and the response is correct, but it seems that when I pick up the drone, the yaw axis will twitch left and right,. I will try to find a FC that can flash 0.3.x firmware, thanks for your reply~

It is just the yaw direction that is wrong?

DiehardFPV commented 1 year ago

The loss of control came too quickly for me to see clearly,so i grabbed the drone with Props off to find out issues, when the drone was turned upside down, if I were to roll to the right, it should be motors 1 and 2 that spined faster, but in fact it seemed to be motors 4 and 3. My friend also had the same problem in 0.4.x, then he tested 0.3.x and flew well.

nerdCopter commented 1 year ago

@DiehardFPV , @BeauBrewski suggested i port the HOWI_HOBBYWING_XROTORF7CONV to version 0.3.4 so i did (today). you can now flash that version if it's the only option for now.

BeauBrewski commented 1 year ago

@DiehardFPV its a temporary fix for now, but hopefully will get you flying. Confirmed its showing up in configurator. 👏 image

DiehardFPV commented 1 year ago

Thank you guys so much!

nerdCopter commented 1 year ago

:thinking: , I'd be curious if 0.4.1 with Legacy motor-output-mixer, bypasses this bug.

set mixer_impl = LEGACY, & save. or image

DiehardFPV commented 1 year ago

🤔 , I'd be curious if 0.4.1 with motor-output-mixer, bypasses this bug.Legacy

I've tried it but it still doesn't work

nerdCopter commented 1 year ago

@DiehardFPV , was this fixed with newer (maybe even beta) BlueJay firmware? or still seemingly an EmuFlight bug?

nerdCopter commented 6 months ago

curious for any further news. otherwise will close this ticket soon.

nerdCopter commented 5 months ago

another report of broken 3D mode: https://github.com/emuflight/EmuConfigurator/issues/523 would love a fix. dislike releasing 0.4.3 knowing this exists. cc: @Quick-Flash

clsfpv commented 5 months ago

对任何进一步的消息感到好奇。否则将很快关闭此票证。

Yes, my question is the same as DiehardFPV's, forgive me for not articulating it clearly. I've tried 0.4.1 and 0.4.0 and both have the same problem, but 0.4.2 and 0.3.4 still haven't tried, due to academic issues I may test it out next week when I have time, and hopefully it can be fixed, because EMU is my favorite open source firmware, and its flight feel is something BF can't bring me!

clsfpv commented 5 months ago

,这是否使用更新的(甚至可能是测试版)BlueJay 固件修复?还是看似 EmuFlight 错误?

I've tried bluejay and bls and bl32 firmware and can rule out that this is a logical issue with the EMU

clsfpv commented 5 months ago

对任何进一步的消息感到好奇。否则将很快关闭此票证。

In addition, one of my whoops had an issue where arm could not be activated when the angle mode was activated, and the OSD showed "LOAD". (LDARCf411 EMU0.4.1)

nerdCopter commented 5 months ago

0.4.2 will not be fixed, but likely 0.3.4 works. unfortunate that 0.3.4 does not have the modern filters/features.

for LOAD, please set pid denominator to 2 (4k loop)

if the target LDARCF411 does not exist in 0.3.4 releases, then i can create it upon request.

clsfpv commented 5 months ago

0.4.2 不会被修复,但 0.3.4 可能会工作。不幸的是,0.3.4 没有现代过滤器/功能。

对于,请将 PID 分母设置为 2(4K 循环)LOAD

如果目标LDARCF411在 0.3.4 版本中不存在,那么我可以根据要求创建它。

Yes, currently LDARC_F411 only 0.4.1, hope to use 0.3.4, thank you

nerdCopter commented 5 months ago

EmuFlight_0.3.4_LDARC_F411_Build_e248bee9b.hex.zip

i will add to 0.3.4 assets as well for Confiurator to list it.

clsfpv commented 5 months ago

EmuFlight_0.3.4_LDARC_F411_Build_e248bee9b.hex.zip

我还将添加到 0.3.4 资产中,以便 Confiurator 列出它。

Okay, thank you. I will continue to test the firmware of the EMU and provide you with some bug examples

nerdCopter commented 5 months ago

i don't know how to configure a quad for 3D. can someone give me a diff of the 3d-specific settings, and maybe how a TX-model (edgeTX) should be setup? then maybe i could hack around the code. but TBH, i'm not the best for the math stuffs.

nerdCopter commented 4 months ago

@clsfpv did you test 0.3.4?

nerdCopter commented 4 months ago

@ anyone anyone willing to test a bunch of builds so that we can find which PR broke it? (i.e i can start building a bunch of different commits until the breaking merge is found)

clsfpv commented 4 months ago

@clsfpv did you test 0.3.4?

I am sorry, I am studying in the high school in China so I can't take a test until next wednesday

clsfpv commented 4 months ago

@ anyone anyone willing to test a bunch of builds so that we can find which PR broke it? (i.e i can start building a bunch of different commits until the breaking merge is found)

I will test 0.3.4 next Wednesday🤜🏻

clsfpv commented 4 months ago

你测试过 0.3.4 吗?

Hi,I've tested 0.3.4. 3D mode is work well!

tylercorleone commented 3 months ago

Hi guys, I think that this could be the reason: here the controllerMix3DModeSign is applied to the yawMixVal but then it is applied to the rollPitchMixVal AND the yawMixVal again here, after few lines.

In the previous version the sign, that was called motorOutputMixSign, was applied only once to the overall motorMix, here.

The fix COULD be removing the multiplication with the controllerMix3DModeSign from the rollPitchMixVal, that is the first line that I linked.

Could someone thest this hypotesis? I'm sorry but I can't. I hope that this this will fix the problem. Unfortunately at that PR's time we didn't test the 3D feature.

nerdCopter commented 3 months ago

thank you so much @tylercorleone! ii will attempt.

nerdCopter commented 3 months ago

@tylercorleone , would you mind specifying some exact lines [to potentially modify]? the diffs are "noisy" to read.

tylercorleone commented 3 months ago

Of course, this is the line: float yawMixVal = controllerMix3DModeSign * scaledAxisPidYaw * currentMixer[i].yaw;

The differences in the mixer.c are too large and the file is collapsed, that why the links don't work properly.

We can catch up in Discord if this is not gonna work!

nerdCopter commented 3 months ago

maybe modify src/main/flight/mixer.c:868 to this? float yawMixVal = scaledAxisPidYaw * currentMixer[i].yaw; ??

nerdCopter commented 3 months ago

nope, it flips out when inverted. right-side up seems to still work.

nerdCopter commented 3 months ago

@tylercorleone , i commented in discord. i failed with multiple attempts to different lines of code. not sure what else to try.

nerdCopter commented 3 months ago

[REDACTED -- thinking controllerMixRange = should not have been changed ]

anyone brave enough to test? Please be extra cautious. test no props, then if brave, test props at low altitude. stay clear of danger. i got this to briefly hover on a headless whoop, but lost control quickly.

[[[ firware .zip files deleted ]]]

REQUIRES Configurator: https://github.com/emuflight/dev-master/releases/tag/20240606.193851-cfg

this is the code change that this tries ```diff diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 66d510837..ad4aa6c9b 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -865,13 +865,13 @@ void mixThingsUp(const float scaledAxisPidRoll, const float scaledAxisPidPitch, float controllerMixMin = 0, controllerMixMax = 0; for (int i = 0; i < motorCount; i++) { - float yawMixVal = controllerMix3DModeSign * scaledAxisPidYaw * currentMixer[i].yaw; + float yawMixVal = scaledAxisPidYaw * currentMixer[i].yaw; if (yawMixVal > yawMixMax) { yawMixMax = yawMixVal; } else if (yawMixVal < yawMixMin) { yawMixMin = yawMixVal; } - yawMix[i] = yawMixVal; + yawMix[i] = yawMixVal * controllerMix3DModeSign; float rollPitchMixVal = scaledAxisPidRoll * currentMixer[i].roll + scaledAxisPidPitch * currentMixer[i].pitch; if (rollPitchMixVal > rollPitchMixMax) { @@ -879,15 +879,15 @@ void mixThingsUp(const float scaledAxisPidRoll, const float scaledAxisPidPitch, } else if (rollPitchMixVal < rollPitchMixMin) { rollPitchMixMin = rollPitchMixVal; } - rollPitchMix[i] = rollPitchMixVal; + rollPitchMix[i] = rollPitchMixVal * controllerMix3DModeSign; - float controllerMixVal = controllerMix3DModeSign * (rollPitchMixVal + yawMixVal); + float controllerMixVal = (rollPitchMixVal + yawMixVal); if (controllerMixVal > controllerMixMax) { controllerMixMax = controllerMixVal; } else if (controllerMixVal < controllerMixMin) { controllerMixMin = controllerMixVal; } - controllerMix[i] = controllerMixVal; + controllerMix[i] = controllerMixVal * controllerMix3DModeSign; } controllerMixRange = controllerMixMax - controllerMixMin; // measures how much the controller is trying to compensate ```
nerdCopter commented 3 months ago

I think this fixes it, but it needs real-world testing: https://github.com/emuflight/dev-unstable/releases/tag/20240618.193242-hex Can anyone test???

clsfpv commented 3 months ago

我认为这可以解决它,但它需要实际测试:https://github.com/emuflight/dev-unstable/releases/tag/20240618.193242-hex 任何人都可以测试吗???

I'm still happy to try, but I don't know much about code, and I hope to provide me with a copy of the firmware directly for testing, still LDARC-F411,thanks.

clsfpv commented 3 months ago

我认为这可以解决它,但它需要实际测试:https://github.com/emuflight/dev-unstable/releases/tag/20240618.193242-hex 任何人都可以测试吗???

Sorry I didn't review the firmware carefully, I've found the LDARC-F411 and I'll test it later!

clsfpv commented 3 months ago

我认为这可以解决它,但它需要实际测试:https://github.com/emuflight/dev-unstable/releases/tag/20240618.193242-hex 任何人都可以测试吗???

3D mode works well!Thank you!

nerdCopter commented 3 months ago

3D mode works well!Thank you!

Thank you thank you thank you, i will merge soon!
Can you share DVR?

clsfpv commented 3 months ago

3D模式效果很好!谢谢!

谢谢,我很快就会合并!你能分享DVR吗?

Sure,I will share it to you tomorrow!

clsfpv commented 3 months ago

3D mode works well!Thank you!

Thank you thank you thank you, i will merge soon! Can you share DVR?

Can you odd my friends to discord?I just joined discord,My discord name is Augenstern

nerdCopter commented 3 months ago

New build: fixes both 2PASS and non-2PASS motor-output-mixers: https://github.com/emuflight/dev-unstable/releases/tag/20240709.141832-hex (build of PR: https://github.com/emuflight/EmuFlight/pull/1069)

Please test-fly and report feedback in either the PR Link or Discord.