Question: How does the fact that Boost Statechart is a header only library affect our instrumentation strategy?

SMACC is effectively a ROS Wrapper for Boost Statechart, and the State Machines you write with SMACC (found in SMACC Reference Library) are the source/cpp files.

So does this mean that we don’t need to instrument BSC, and that the tracepoints will either primarily be installed inside SMACC (for common use cases) or in individual State Machines for custom cases?

What do we want to trace?

We want to trace events broadly categorized as…

  • Events Lifecycle: Queue, Transitions, Event creation?..
  • State Lifecycle: States, Client Behaviors…
  • State Machine Lifecycle: Orthogonals, Clients…
  • I/O: Actions, Services, Messages…

Events Lifecycle

To instrument the Event Queue, we need (see below) : a tracepoint for when a message is added to the queue, when it’s dropped from the queue, and when it leaves the queue

  • post_event – Added
  • process_event – Processed
  • forward_event – Processed
  • discard_event
  • transitions
  • threads

Key Files

  • Scheduler
  • Fifo Worker

State Lifecycle

Largely recurring in nature. Crucial for performance.

Items Scoped to the State…

  • State Construction
  • State Destruction
  • runtimeConfigure()
  • onEntry()
  • update()
  • onExit()
  • Creation & Destruction of State Reactor

Items Scoped to the Client Behavior…

  • runtimeConfigure()
  • onEntry()
  • update()
  • onExit()

Key Files

State Machine Lifecycle

Much takes place on start up…

  • Creation of Orthogonals
  • Creation of Clients
  • Creation of Components


We’ll assume, that users who want to trace smacc, will already have ros trace tools (& TraceCompass) installed, so we only care about when “we/SMACC” read the message (in the signal handler) and when “we/SMACC” publish the message.

Key files…


How do we trace it? *Excellent

Existing ROS Packages

LTTng docs

Shell Scripts

After we’ve essentially created our own tracetools package, and followed the LTTng installation instructions, we then either need to use shell scripts…

Tracetool.h Headers & Functions

Tracepoint Events

Tracepoint Provider/TRACEPOINT_EVENT() MACRO Examples

Tracing Event Queues


We also need to build a model of the publisher and subscriber queues. To achieve this, we can leverage the relevant tracepoints. These include a tracepoint for when a message is added to the queue, when it’s dropped from the queue, and when it leaves the queue (either sent over the network to the subscriber, or handed over to a callback). We can therefore visualize the state of a queue over time!

How do we view it?

User Space Analysis –

Kernal Space Analysis –

What else should we trace to make SMACC faster?

Andreas Huber Doenni’s discussion of the performance bottlenecks in Boost Statechart is outstanding…

Here’s a little description of state_cast<>…