-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
[WIP] Fix Undercounting of topics in Tools/uorb-graph/create.py
#16995
Conversation
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.
Thanks for looking into this, it's the reason why it was disabled in the docs.
Another part that's currently not handled is pubs/subs in library code.
FYI: the offending SITL Test (the failing CI check, above) passes when I run it locally. So, I'm not sure what the issues is. |
@bkueng
Obviously, I don't expect either of these to be popular methods. |
Yes I agree, I wouldn't go too far either. Using templates has other benefits as well and it's something we might do at some point. There's also a this: https://github.com/PX4/PX4-Autopilot/blob/master/src/modules/commander/Commander.hpp#L428 ( |
This is actually where I'd like to go (for more than just a tool). |
Please take a look at #16059 if you're interested in this. |
Tools/uorb-graph/create.py
Tools/uorb-graph/create.py
@bkueng .Q1. Are pseudo-topics "different" from actual topics?:
I'm not familiar enough with the uORB machinery -- does it make sense to separate out the RHS topic .Q2. Are submodules separateI.e. a module within the directory tree of another module The code currently treats this as a separate module. Is this the desired behavior. |
Result of running script on entire repo: |
Yes they are separate instantiations with a common message type (i.e.
Yes, likely. Which one did you have in mind? |
Oh, there are a dozen or so nested modules. I'm just verifying behavior. A separate issue is how to handle inheriting topics from libraries. (Some of which may be nested) But that is such a big change, I'm not sure it's worth the effort to include -- it involves re-writing a bunch of the parsing code, so It's not clear that it's behaving correctly. |
Yes as I wrote above. I don't think it's much effort if we go about it like this:
And then we can still assign the libs to the used modules at a later point. That said, the PR is already an improvement w/o that, so it's fine if you we keep it as is. |
... Ahhhh, that's not exactly what I was trying to say.... Here's where the PR currently stands:
This commit implements (3). |
CI Tests
|
Ok, that's good. I think we're not very consistent with adding all dependencies.
These are unrelated.
Right, this needs to be updated. Removing that one is fine. |
… expands handled test cases - debug output is now printed & filtered with the python 'logging' standard module - changed 'module whitelist' to 'scope-whitelist' - whitelist may now apply to libraries - libraries are not included by default - may be merged with their depending modules with the `--merge-depends` cli flag - eliminates redundant 'special-case' handling code - greatly expands debugging output - fixes debug output if package dependencies are missing - still crashes on error matches - now warns on ambiguous matches - prints a list of ambiguous source sites (aka warnings) on completion - adds warnings if any of the source paths are invalid - do not emit debug output for modules outside of the module/scope whitelist - Expand script's CLI parameters - added 'none' output options: undocumented debugging option to silence file output while debugging - added the `--merge-depends` cli flag -- merges output of modules & their dependee libraries - Source processing now happens on original source files: - processing to line-by-line - required overhaul of regex match patterns + processing - pros: - enable tracing of ambiguous parsing sites -- reports (module, file, line-number, line-contents) - simplifies code - reduces computational complexity - cons: - certain declarations are harder to parse (multiline arrays) - refactors: - added specific subclasses for each: Publications, Subscriptions, Ambiguities - added a "Scope" class to represent either a module ('ModuleScope') or a library ('LibraryScope')
@bkueng Given all the changes are restricted to a single file, I've squashed to a single commit, with a more detailed commit message. |
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.
Nice work
_, ext = os.path.splitext(file_name) | ||
if ext in ['.cpp', '.c', '.h', '.hpp']: | ||
self._process_source_file(file_name) | ||
# Note: Skip all entries if we're not in a module -- both finding known pubs/subs and emitting warnings |
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.
Is this correct?
What about libraries if we have a scope whitelist?
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.
Okay, (a) outdated comment -- it should actually be if self._in_scope()
.
That compound if statement was actually in error -- we shouldn't be filtering on the whitelist at this point -- just if we're in any scope at all.
Will update this.
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.
Why not keep the existing behavior? Fail if not in a scope.
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.
Per request, the behavior is changed to warn about line if an ORB_ID was found outside of a containing scope (module or library)
But academic anyway, because I couldn't find any examples of this.
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.
It's not academic as it will help to raise issues in future refactorings, instead of silently breaking things. It adds robustness and therefore I wanted it to be an assertion.
Especially since this will run as CI and warnings can go unnoticed for quite some time.
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.
Okay I see your point. I've made this change on #17175 .
Co-authored-by: Beat Küng <beat-kueng@gmx.net>
Co-authored-by: Beat Küng <beat-kueng@gmx.net>
Co-authored-by: Beat Küng <beat-kueng@gmx.net>
Thanks! Let's get this in as a great first step! |
the rework requests have not made it into this PR.... starting new one. |
Problem Description
(updated Sun 14 Mar 2021 10:05:48 AM EDT)
The script at
Tools/uorb_graph/create.py
was undercounting publications and subscriptions -- particularly C++ definitions.This PR overhauls & refactors the script to greatly increase the variety of cases it can handle.
Describe your solution
This adds additional fields to the regexes when scanning source code.
--src-path
argument)--merge-depends
CLI flag.Test data / coverage
This patch only affects a developer documentation script, and has no effect on flight code
During development, all test cases were run from the path:
/home/teyrana/project/px4/Tools/uorb_graph
Before
Run on
master
branch @ 9d47f7eExamples + After Results
Module:
rc_input
src/drivers/rc_input/RCInput.cpp
:264:uORB::Publication<vehicle_command_ack_s> vehicle_command_ack_pub{ORB_ID(vehicle_command_ack)};
src/drivers/rc_input/RCInput.hpp
:146:uORB::Subscription _vehicle_cmd_sub{ORB_ID(vehicle_command)};
src/drivers/rc_input/RCInput.hpp
:155:uORB::PublicationMulti<input_rc_s> _to_input_rc{ORB_ID(input_rc)};
Module:
iridiumsbd
src/drivers/telemetry/iridiumsbd/IridiumSBD.h
:304:uORB::Publication<iridiumsbd_status_s> _iridiumsbd_status_pub{ORB_ID(iridiumsbd_status)};
Module
frsky_telemetry
src/drivers/telemetry/frsky_telemetry/frsky_data.cpp
:69:uORB::SubscriptionData<vehicle_acceleration_s> vehicle_acceleration_sub{ORB_ID(veh...
Module
navigator
src/modules/navigator/geofence.h
:187uORB::SubscriptionData<vehicle_air_data_s> _sub_airdata;
src/modules/navigator/mission_block.h
:155:uORB::Publication<actuator_controls_s> _actuator_pub{ORB_ID(actuator_controls_2)};
src/modules/navigator/navigator_main.cpp
:103:_local_pos_sub = orb_subscribe(ORB_ID(vehicle_local_position));
src/modules/navigator/gpsfailure.h
:79:uORB::Publication<vehicle_attitude_setpoint_s> _fw_virtual_att_sp_pub{ORB_ID(fw_virtual_attitude_setpoint)};
Module:
temperature_compensation
src/modules/temperature_compensation/TemperatureCompensationModule.h
:122:uORB::Subscription _baro_subs[BARO_COUNT_MAX]
Module:
commander
src/modules/commander/Commander.hpp
:428:uORB::SubscriptionMultiArray<battery_status_s, battery_status_s::MAX_INSTANCES> _battery_status_subs{ORB_ID::battery_status};
src/modules/commander/level_calibration.cpp
:85:uORB::SubscriptionBlocking<vehicle_attitude_s> att_sub{ORB_ID(vehicle_attitude)};
Module:
vtol_att_control
src/modules/vtol_att_control/vtol_att_control_main.h
:135:uORB::SubscriptionCallbackWorkItem _actuator_inputs_fw{this, ORB_ID(actuator_controls_virtual_fw)};
src/modules/vtol_att_control/vtol_att_control_main.h
:154:uORB::Publication<actuator_controls_s> _actuators_0_pub{ORB_ID(actuator_controls_0)};
Module (Library):
drivers__hott
src/drivers/telemetry/hott/messages.cpp
:78:_home_sub = orb_subscribe(ORB_ID(home_position));
Module
hott_telemetry
Module Nested in another Modules
After: entire source tree
Modules: all
Modules + Libraries: (w/union):
Modules + Libraries (w/merge):
- Scope count: 139
- Topic count: 171
- Warning count: 201