Skip to content

IMU observation in pi3hat interface is not thread-safe #413

Open
@stephane-caron

Description

Bug description

IMU measurements from attitude_ are read in Pi3HatInterface::observe, which is called in step 1 actuation cycles, before step 3 where we wait for a reply. This means the following undesirable execution sequence may happen:

  • Spine thread: Spine::cycle`` calls Pi3HatInterface::observe`
  • CAN thread: Pi3HatInterface::pi3hat_->Cycle(input)`` updates attitude_`
  • Spine thread: reads Pi3HatInterface::attitude_ at the same time: inconsistent reading 💥

Expected property

The data read during observed should not be writable by the CAN thread, as is already the case with servo commands.

Reproduction steps

As far as I know the undesirable execution sequence above has never been observed in practice.

System

  • OS: Ubuntu 22.04
  • Upkie version: 5.1.0

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions