Skip to content
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

Topic_listener: allow multi-topic messages #8241

Merged
merged 2 commits into from
Nov 9, 2017

Conversation

jlecoeur
Copy link
Contributor

@jlecoeur jlecoeur commented Nov 6, 2017

This PR allows uORB messages with multi topics (defined with the syntax # TOPICS ...) in topic_listener.

Now it is possible to do:

pxh> listener actuator_controls_0

Here is the list of topics that where not working with topic_listener:

  • actuator_controls_0
  • actuator_controls_1
  • actuator_controls_2
  • actuator_controls_3
  • actuator_controls_virtual_fw
  • actuator_controls_virtual_mc
  • offboard_mission
  • onboard_mission
  • vehicle_attitude_groundtruth
  • vehicle_vision_attitude
  • mc_virtual_attitude_setpoint
  • fw_virtual_attitude_setpoint
  • vehicle_global_position_groundtruth
  • vehicle_local_position_groundtruth
  • vehicle_vision_position
  • mc_virtual_rates_setpoint
  • fw_virtual_rates_setpoint

I also fixed the generated cpp code because the first message in the list (currently commander_state) was not printed by topic_listener.

closes #6607
@mhkabir

@jlecoeur
Copy link
Contributor Author

jlecoeur commented Nov 6, 2017

There are too many topics now ! 🥇

/home/travis/build/PX4/Firmware/build/posix_sitl_default-clang/src/systemcmds/topic_listener
/topic_listener.cpp:164:5: error: function 'listener_main' exceeds recommended 
size/complexity thresholds [google-readability-function-size,-warnings-as-errors]

note: 4143 statements (threshold 4000)
note: 616 branches (threshold 600)

@dagar Can we raise that complexity limit, or white-list the autogenerated files?

@TSC21
Copy link
Member

TSC21 commented Nov 6, 2017

@jlecoeur try to increase it and check for the stack and ram usage to see if it sustainable.

@dagar
Copy link
Member

dagar commented Nov 6, 2017

No problem, the complexity was supposed to be a cap, but doesn't really make sense with generated code like this. You can increase it here https://github.com/PX4/Firmware/blob/master/.clang-tidy

@jlecoeur
Copy link
Contributor Author

jlecoeur commented Nov 6, 2017

In the end I modified the script to generate one short function per topic.
4000 is already way larger than the recommended value

@jlecoeur
Copy link
Contributor Author

jlecoeur commented Nov 6, 2017

Regarding memory usage @TSC21 that should be fine: the structures are allocated on the stack when needed, and they are not larger than before. Also listener subscribes to a single topic, then unsubscribes. I simply expect a bit larger firmware because more code gets generated.

@bkueng
Copy link
Member

bkueng commented Nov 9, 2017

Thanks!
This is the firmware size for v4:

before:
1456420    4133   24972 1485525  16aad5 build/px4fmu-v4_default/nuttx_px4fmu-v4_default.elf
before w/o listener:
1412532    4133   24972 1441637  15ff65 build/px4fmu-v4_default/nuttx_px4fmu-v4_default.elf
this PR:
1466100    4133   24972 1495205  16d0a5 build/px4fmu-v4_default/nuttx_px4fmu-v4_default.elf

So FW size is increased by 9680 bytes, but the listener was already big (43888 bytes).

@bkueng bkueng merged commit 4e7bd57 into PX4:master Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

listener does not work for subtopics
4 participants