New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SmartAudio library implementation #15174
Conversation
@wapophis thanks for working on this! The PR will need quite a few changes to be in a mergeable state, here are the high level changes I think are needed - probably not worth getting into the details until we get a bit closer:
I'm happy to help you with this if this does not make sense. |
This comment has been minimized.
This comment has been minimized.
Working with the AP_Vehicle i see that the params root is defined here and not in the Parameters.cpp. Is correct to move the root param definition to the AP_Vehicle ? |
@wapophis - I'm not quite sure what you mean but what you have done is correct - there is no need to modify Parameters.cpp. Yeah VTX is protocol independent and small which is why it is universally enabled. The only implemented protocol so far is CRSF which does have the appropriate ifdef |
I'm thinking about the thread strategy you refer, using the The AP_Scheduler system is the way ? |
This comment has been minimized.
This comment has been minimized.
@wapophis - don't use the scheduler in RCTelemetry, that's to fit telemetry into a limited bandwidth link. The way to create a thread is something like:
but like I said this may not be necessary as you can probably massively reduce the complexity of the implementation without this. Happy for you to propose different semantics for VTX_OPTIONS or create a separate VTX_PITMODE flag if that makes sense. What is the workflow with "in-range" and "out-range"? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
You should set the priority to IO_PRIORITY My doubts about using a thread are that this is only applicable when not armed, but the thread will be active (and most importantly the stack space) when flying. |
That's an important point to be considered, because it will be usefull to setup the vtx power when flying in order to optimize energy waste. Anyway that feature could be discused at future. |
This is the updated status if the overall changes.
Actualized status: need your support. Any example plz?
Actualized status: fixed
Actualized status: in progress
Actualized status: refactored
Actualized status: pending |
|
Integration with AP_VideoTX is almost complete, i'm writing the values directly to the singleton when call get_readings method is called, before i fetch the internal SA values from the buffer, and make any transformación needed in the same method. Because argument to get_readings is a pointer it's support múltiple vtx configuration if needed |
@wapophis great! Just make sure that your code copes with something else writing these values - so for instance we have Spektrum VTX support which will allow these values to be written by the TX in which case your driver should be able to detect the change and send the appropriate SA commands |
@andyp1per good morning, thats the sequence i'm thinking to process external updates from AP_VideoTX, what's your opinion? Keep polling updates on AP_VideoTX seems not good, maybe using #ifdef pointing to spec enabled pej: #ifdef SMARTAUDIO , could trigguers sync tasks from AP_VideoTx to the enabled specs implemented ? As far i can see, if there is desync between the smartaudio because an error it going to be needed to implement sempahores in vtx updates methods to prevent the fight between the third_party access and the smartaudio access. Sure there are other derivates that i'm not having in account yet. |
@wapophis I think this is mostly right. You can avoid polling updates through the cached copies held by AP_VideoTX - this is what CRSF does, it calls have_params_changed() to decide whether an update is necessary and then loops through the settings calling for instance update_power() which returns true if the power needs updating. |
@andyp1per questions about the booting process. When vtx boots, we can query hw-vtx to get his settings, then we can store the settings into ap_vtx, or get the settings from the ap_vtx and update the hw-vtx settings to set the values defined by the user.
Once the user make the first-boot process (which can enabled by user anytime) , the changes flow is AP-VTX -> HW-VTX. |
@wapophis I'm not sure its worth it as its a first time configuration issue. We already have this issue with configuring the UART and making sure the VTX is speaking the right protocol. Better to just doc in the wiki I think rather than adding a new parameter. |
This comment has been minimized.
This comment has been minimized.
@wapophis doesn't look squashed, you still have 166 commits - you need to squash these into 1 commit per module, each commit message starting with the module name, e.g. AP_SmartAudio: do stuff |
30b1be4
to
4dd69b4
Compare
I pulled your branch and built for a Durandal - the code does not build (I had to remove crc8_dvb_s2_update) and when I had it built and loaded I was unable to connect via mission planner - so something is messed up in the serial handling with this change. You'll need to at least get it to a state that you can get some access to the board. |
This comment has been minimized.
This comment has been minimized.
336935a
to
6c08efe
Compare
@@ -36,6 +36,8 @@ const AP_Param::GroupInfo AP_SmartAudio::var_info[] = { | |||
// @User: Advanced | |||
AP_GROUPINFO("DEFAULTS", 3, AP_SmartAudio::configured_smartaudio_params, setup_defaults, 0), | |||
|
|||
AP_GROUPEND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the problem which is not failing using sitl but fails on real fc.
This comment has been minimized.
This comment has been minimized.
@wapophis I'll try it thanks - try and get the CI builds above clean. |
AP_SmartAudio: tidy up debug
Here are a couple of examples:
Notice how the timeout / bytes available / incomplete message are incorporated into the loop |
… permits updates from params changes in gcs.
…n loop removed inncesaries delays.
…nto SmartAudio2
…d max packet response size to 32 bytes.
@andyp1per the splitted reading from response buffer are now working. I'd made some test in 4 bytes packets and after some little rework on the read_response is working now. (fixed on db8526f) I'd detected a problem with the timings in the main loop, which makes laggy the syncing changes with vtx, now it's fixed too, performing well in one loop usually. (fixed on 79ec8d4) Finally the Ap_SmartAudio, is updating the AP_videoTx values when the hot_deploy param is enabled, syncing params persisted in the eprom with the "_current_" style backend params. making the syncing to work without needing to reboot de FC. ( pushed in e8a6300) Other things to reply:
|
With the latest I eventually get this, but it takes a long time - feels like something is not quite right
|
Thanks Andy i take a look |
I've spent a fair bit of time on this today. Fixed a few bugs and restructured a few things that were wrong - not quite working correctly, but closer I think. Will put up a PR shortly. |
Fine, thanks. This night i'll check it |
This is the PR wapophis#4 |
With my change I now get this:
Fairly continuously after it finally communicates. The device also seems to switch into 800mw mode - which is not what is configured, so something not correct as yet. |
I'm checking the pr, one thing that it's seems strange is that the first reading from response buffer seems partial and i dont see the complete response from vtx, and subsequent requests has not been responsed. Other thing i notice is that the pulldown for the requests has been removed. Anyway I'll try with this pr into my FC with sma 2.0 and check if it's already working. |
I think you should put the pulldown back in - I just took it out so I could see the trace properly on the oscilloscope |
There are still some timing things to work out. I suspect the low priority of the thread is contributing to this. |
There is definitely something wrong with the pitmode and power settings. I think I have a fix for the pitmode stuff |
Part of the issue is I have totally toasted the lipo I was testing with, will find another ... |
Ok, you cannot lock/unlock the VTX via SA it seems - at least not on my Evo, you can only query the setting. |
@wapophis I have updated my PR. There are still a fair few bugs in the logic handling of this PR:
I'll do a more detailed review now that it's roughly working for me, out of time for actual testing for now I am afraid |
Hey @wapophis what progress here? |
Yes Andy because of working presure i had not too much time to dev. Next weekend i'll push to the pr. During this dev impass i have been flying whithout any collateral impact. |
Hi @wapophis any movement on this? I'll clone your PR and work on it if you are not going to get to it |
This would be fantastic to merge, currently SmartAudio support is the only thing keeping me from using AP, as the VTX can get very hot if it's always set to the highest power, especially testing on the bench. |
Ok, I have started work on this |
This has been subsumed by #16464 which is now merged |
This is smartaudio protocol implementatation to deal with the vtx directly throught serial port interface.
That's is a wip, is tested with 2.0 spec. The idea behind this PR is continue working with using this PR as a continuous improvement process.
Help debugging in 1.0 and 2.1 vtxs is welcome
The setup is the following:
When the vtx has power on, the sma driver will send to the hw-vtx the commands needed to sincro your vtx params config with the hw-vtx.
Thats all for now.