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

uORB::Publication improvements and cleanup #14784

Merged
merged 4 commits into from
May 4, 2020
Merged

Conversation

dagar
Copy link
Member

@dagar dagar commented Apr 29, 2020

  • common PublicationBase
  • PublicationQueued types are now type aliases
  • ORB_PRIO use type everywhere
  • drivers (PX4Accelerometer/PX4Gyroscope/etc) advertise publications in constructor along with driver registration
nsh> listener sensor_accel

TOPIC: sensor_accel 3 instances

Instance 0:
 sensor_accel_s
        timestamp: 387779742  (0.004361 seconds ago)
        timestamp_sample: 387779442
        device_id: 3670026 (Type: 0x38, SPI:1 (0x00)) 
        x: 0.1801
        y: -0.3445
        z: -9.8220
        temperature: 39.7980

Instance 1:
 sensor_accel_s
        timestamp: 387781322  (0.004360 seconds ago)
        timestamp_sample: 387781109
        device_id: 3932170 (Type: 0x3C, SPI:1 (0x00)) 
        x: 0.3177
        y: -0.4816
        z: -9.7533
        temperature: 39.3941

Instance 2:
 sensor_accel_s
        timestamp: 387783231  (0.003559 seconds ago)
        timestamp_sample: 387783205
        device_id: 4259850 (Type: 0x41, SPI:1 (0x00)) 
        x: 0.3552
        y: -0.2759
        z: -9.8567
        temperature: 35.0000


nsh> listener sensor_accel_integrated

TOPIC: sensor_accel_integrated 3 instances

Instance 0:
 sensor_accel_integrated_s
        timestamp: 399876375  (0.003065 seconds ago)
        timestamp_sample: 399875924
        error_count: 0
        device_id: 3670026 (Type: 0x38, SPI:1 (0x00)) 
        delta_velocity: [0.0003, -0.0008, -0.0245]
        dt: 2500
        samples: 10
        clip_counter: [0, 0, 0]

Instance 1:
 sensor_accel_integrated_s
        timestamp: 399878665  (0.002044 seconds ago)
        timestamp_sample: 399878352
        error_count: 0
        device_id: 3932170 (Type: 0x3C, SPI:1 (0x00)) 
        delta_velocity: [0.0007, -0.0010, -0.0244]
        dt: 2500
        samples: 10
        clip_counter: [0, 0, 0]

Instance 2:
 sensor_accel_integrated_s
        timestamp: 399882702  (0.000389 seconds ago)
        timestamp_sample: 399882671
        error_count: 0
        device_id: 4259850 (Type: 0x41, SPI:1 (0x00)) 
        delta_velocity: [0.0007, -0.0009, -0.0245]
        dt: 2509
        samples: 2
        clip_counter: [0, 0, 0]



nsh> listener sensor_accel_status

TOPIC: sensor_accel_status 3 instances

Instance 0:
 sensor_accel_status_s
        timestamp: 409639646  (0.100235 seconds ago)
        error_count: 0
        device_id: 3670026 (Type: 0x38, SPI:1 (0x00)) 
        temperature: 39.7980
        clipping: [0, 0, 0]
        full_scale_range: 156.9064
        vibration_metric: 0.0001
        measure_rate_hz: 800
        rotation: 2

Instance 1:
 sensor_accel_status_s
        timestamp: 409643983  (0.097395 seconds ago)
        error_count: 0
        device_id: 3932170 (Type: 0x3C, SPI:1 (0x00)) 
        temperature: 39.3941
        clipping: [0, 0, 0]
        full_scale_range: 156.9064
        vibration_metric: 0.0002
        measure_rate_hz: 800
        rotation: 2

Instance 2:
 sensor_accel_status_s
        timestamp: 409696031  (0.046810 seconds ago)
        error_count: 0
        device_id: 4259850 (Type: 0x41, SPI:1 (0x00)) 
        temperature: 35.0000
        clipping: [0, 0, 0]
        full_scale_range: 156.9064
        vibration_metric: 0.0043
        measure_rate_hz: 1000
        rotation: 10

@dagar dagar force-pushed the pr-uorb_publication_cleanup branch from b7556de to 4b6e8ad Compare April 29, 2020 00:51
 - common PublicationBase
 - PublicationQueued types are now type aliases
 - ORB_PRIO use type everywhere
 - drivers advertise on construction
@dagar dagar force-pushed the pr-uorb_publication_cleanup branch from 4b6e8ad to fcf330f Compare April 29, 2020 01:33
@dagar dagar requested a review from bkueng April 29, 2020 01:55
Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the ORB_PRIO uint8_t -> int change noticeable?

src/modules/sensors/voted_sensors_update.cpp Outdated Show resolved Hide resolved
{
if (_handle != nullptr) {
// don't automatically unadvertise queued publications (eg vehicle_command)
if (static_cast<DeviceNode *>(_handle)->get_queue_size() == 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to double-check if that works as expected. No case specifically comes to mind, ulog_stream_ack might be a candidate.

@dagar
Copy link
Member Author

dagar commented Apr 29, 2020

Is the ORB_PRIO uint8_t -> int change noticeable?

Overall we save a small amount with this PR (maybe a few hundred bytes), so it seems uORB::Publication using an ORB_ID class enum (uint8_t) has roughly made up for it.

I didn't necessarily want to use enum ORB_PRIO everywhere, but I was a bit appalled when I saw the error in sf1xx. Longer term we might be able to make it an enum class or quite honestly the entire ORB priority concept might not really make sense to keep in this form.

@dagar dagar added this to the Release v1.11.0 milestone Apr 29, 2020
@dagar dagar changed the title [WIP]: uORB::Publication improvements and cleanup uORB::Publication improvements and cleanup Apr 29, 2020
@dagar
Copy link
Member Author

dagar commented Apr 29, 2020

TODO: manually verify queued publication unadavertise behavior.

@dagar dagar marked this pull request as ready for review April 29, 2020 14:24
@dagar
Copy link
Member Author

dagar commented May 1, 2020

We need to double-check if that works as expected. No case specifically comes to mind, ulog_stream_ack might be a candidate.

I've stepped through this a few times and verified we're unadvertising regular Publications and leaving Queued.

Copy link
Member

@bkueng bkueng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test that log streaming still works by restarting it several times?

@dagar
Copy link
Member Author

dagar commented May 4, 2020

Can you test that log streaming still works by restarting it several times?

Seems to be working.

nsh> logger status
INFO  [logger] Running in mode: all
INFO  [logger] Number of subscriptions: 120 (3840 bytes)
INFO  [logger] Full File Logging Running:
INFO  [logger] Log file: /fs/microsd/log/sess006/log001.ulg
INFO  [logger] Wrote 1.80 MiB (avg 14.51 KiB/s)
INFO  [logger] Since last status: dropouts: 261 (max len: 0.677 s), max used buffer: 13009 / 14336 B


nsh> INFO  [logger] Start mavlink log


nsh>  logger status
INFO  [logger] Running in mode: all
INFO  [logger] Number of subscriptions: 120 (3840 bytes)
INFO  [logger] Full File Logging Running:
INFO  [logger] Log file: /fs/microsd/log/sess006/log001.ulg
INFO  [logger] Wrote 2.70 MiB (avg 14.32 KiB/s)
INFO  [logger] Since last status: dropouts: 1 (max len: 0.517 s), max used buffer: 12723 / 14336 B
INFO  [logger] Mavlink Logging Running (Full log)


nsh> mavlink status

instance #0:
        GCS heartbeat:  269194 us ago
        mavlink chan: #0
        type:           USB CDC
        flow control: OFF
        rates:
          tx: 79.366 kB/s
          txerr: 1.515 kB/s
          tx rate mult: 0.981
          tx rate max: 800000 B/s
          rx: 0.598 kB/s
        ULog rate: 6.7% of max 70.0%
        FTP enabled: YES, TX enabled: YES
        mode: Config
        MAVLink version: 2
        transport protocol: serial (/dev/ttyACM0 @2000000)
        ping statistics:
          last: 6.84 ms
          mean: 7.79 ms
          max: 107.71 ms
          min: 0.27 ms
          dropped packets: 0


nsh> INFO  [logger] Stop mavlink log
nsh> INFO  [logger] Start mavlink log
nsh> logger status
INFO  [logger] Running in mode: all
INFO  [logger] Number of subscriptions: 120 (3840 bytes)
INFO  [logger] Full File Logging Running:
INFO  [logger] Log file: /fs/microsd/log/sess006/log001.ulg
INFO  [logger] Wrote 3.65 MiB (avg 13.85 KiB/s)
INFO  [logger] Since last status: dropouts: 141 (max len: 0.843 s), max used buffer: 0 / 14336 B
INFO  [logger] Mavlink Logging Running (Full log)

nsh> INFO  [logger] Stop mavlink log

nsh> logger status
INFO  [logger] Running in mode: all
INFO  [logger] Number of subscriptions: 120 (3840 bytes)
INFO  [logger] Full File Logging Running:
INFO  [logger] Log file: /fs/microsd/log/sess006/log001.ulg
INFO  [logger] Wrote 3.87 MiB (avg 13.85 KiB/s)
INFO  [logger] Since last status: dropouts: 51 (max len: 0.704 s), max used buffer: 0 / 14336 B

nsh> INFO  [logger] Start mavlink log
nsh> INFO  [logger] Stop mavlink log

https://review.px4.io/plot_app?log=512007ef-4fee-4cd9-8594-d449cccad7f2
https://review.px4.io/plot_app?log=c9799a7d-fe83-475e-95fb-2f8fa78185b1
https://review.px4.io/plot_app?log=469c70b1-8ea4-4d4a-b7b9-857e6338fa62

Side question, is it possible to capture postflight additional data when log streaming is stopped?

@dagar dagar merged commit 466b5db into master May 4, 2020
@dagar dagar deleted the pr-uorb_publication_cleanup branch May 4, 2020 15:09
@bkueng
Copy link
Member

bkueng commented May 5, 2020

Side question, is it possible to capture postflight additional data when log streaming is stopped?

Not easily, as stopping is requested externally.

bkueng pushed a commit that referenced this pull request May 19, 2020
 - create common uORB::PublicationBase
 - uORB::PublicationQueued types are now type aliases
 - ORB_PRIO use enum type everywhere to avoid accidental misuse
 - PX4Accelerometer/PX4Gyroscope/etc driver libs explicitly advertise on construction, unadvertise on destruction. This is a workaround for any potential issues that might appear when accel/gyro cdev and uORB indexing doesn't align.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants