897 enabledisable gripper from gripper page#1003
Conversation
…f the gripper tab
- Added controllers for setting GRIP_ENABLE - Think I've wired everything up
|
Does anyone know why this test failed? It appears to me that it's nothing to do with what I changed. |
Flaky copter test |
1Blademaster
left a comment
There was a problem hiding this comment.
Added some comments. Can you also add some tests for the enabling and disabling of the gripper endpoints.
Co-authored-by: Kush Makkapati <kush.makkapati@icloud.com>
Co-authored-by: Kush Makkapati <kush.makkapati@icloud.com>
Co-authored-by: Kush Makkapati <kush.makkapati@icloud.com>
- Added the return of appropriate error message from endpoints and handling in middleware
…/github.com/Avis-Drone-Labs/FGCS into 897-enabledisable-gripper-from-gripper-page
…/github.com/Avis-Drone-Labs/FGCS into 897-enabledisable-gripper-from-gripper-page
…eware - Moved error result from endpoint to controller - Formatted - Added check to be on config.gripper. I'll test this once #1002 is merged
|
Is |
I think it's within the radio folder? Wherever the config file is |
|
All sorted I think! @1Blademaster |
Cool. Will test on one of my drones when I get back 👍 |
|
So on the FC where gripper does not exist, it tries to fetch the ENABLE param, fails, but then it tries to fetch the other params from cache? This is me going to config page, then clicking on gripper tab and that's all; not clicking on the enable gripper button. We don't need to search for those params, even from cache, if gripper enabled cannot be found right? |
|
Ah okay I see, it looks like replying on the gripper enabled parameter is not going to work for this. Do you know if MAVlink has a way of getting if the gripper exists at all? I'll need to add this to the controller so we can turn off these checks when the gripper is not found. Currently, it needs to check GRIPPER_ENABLED to decide whether to show the enable or disable button, but we really need a third option to say no gripper found. |
|
There's not any other way to check if gripper exists. We can still show the button even if gripper does note exist and let it timeout as it would. |
|
I don't see a way of avoiding the error of fetching GRIPPER_ENABLED then, there's no way to distinguish between a real erroneous interaction and the gripper not existing. GetSingleParam is setup to error if the parameter is not found. What should I do? |
|
We can't avoid gripper enable; that's fine. But we can avoid the rest of the params, even from the cache (shown in log in earlier comment). |
…/github.com/Avis-Drone-Labs/FGCS into 897-enabledisable-gripper-from-gripper-page
|
I think I've found the source of what you're encountering, lmk if this fixes it. |
|
You'll need to add getGripperEnabled to the dependency list of the use effect. |
|
Oh okay - how come? |
…/github.com/Avis-Drone-Labs/FGCS into 897-enabledisable-gripper-from-gripper-page
|
Any variables used within a use effect should be in the dependency array, e.g. if getGripperEnabled get's updated then the use effect won't re-execute. |
|
Ah I see the confusion - I have added middleware so that when the "set_gripper_enabled_result" is emitted, emitGetGripperConfig() is automatically run, so I didn't expect that the dispatch in the component would have to be run again. One of these is probably unnecessary then - lmk if strange things are still happening. Here's the middleware which I added to do this. socket.socket.on(
ConfigSpecificSocketEvents.onSetGripperEnabledResult,
(result) => {
if (result.success) {
store.dispatch(setGetGripperEnabled(true))
store.dispatch(emitGetGripperConfig())
showSuccessNotification(result.message)
} else {
showErrorNotification(result.message)
}
},
)
socket.socket.on(
ConfigSpecificSocketEvents.onSetGripperDisabledResult,
(result) => {
if (result.success) {
store.dispatch(setGetGripperEnabled(false))
store.dispatch(emitGetGripperConfig())
showSuccessNotification(result.message)
} else {
showErrorNotification(result.message)
}
},
) |
|
Almost there; if I enable gripper through params then go back to config page; it doesn't update/fetch the gripper enabled param? |
|
I can certainly remove the |
Yeah probably good idea. |
Hmm it should do, the change in UI is controlled by the store, which I assume is working correctly on the params page. I'll have a look. |
|
Hmm, I've got a solution but I'm not sure if you'll be happy. |
|
I've done some rooting around and found this: updateParamValue: (state, action) => {
state.params = state.params.map((item) =>
item.param_id === action.payload.param_id
? { ...item, param_value: action.payload.param_value }
: item,
)
},which looks like it does what I was talking about in the prior message. This does indeed set What is the best solution here? The above solution works. I don't see any other way to easily make this an automatic thing, the config state simply needs to constantly observe the params slice in order to keep these things in sync. |
|
Yeah I was thinking that we need to probably refactor the config pages so they align with the params page better (in terms of params etc). For now though, having a small loading screen is fine; it's what we do on other pages atm as well. We'll make it automatic in another PR with the params link. |
|
Okay, sounds good. Write params now updates the gripper enabled state. Changing the gripper enabled state on the gripper page does not change the parameter value on the params page however, without a manual "refresh params". Is this normal? |
|
Yes that's normal.. for now. Will fix once we refactor. |
- Dispatched emitGetGripperEnabled when gripper page is opened
|
This was working on mine - hopefully on yours too |
1Blademaster
left a comment
There was a problem hiding this comment.
Got there finally, seems to be working for me on my two FCs.
|
Finally 🤣 |
Think I've wired everything up correctly here.
First time touching the backend and I don't have much experience doing backend in general, so a thorough check would be appreciated! Lmk if anything needs changing.