bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::distributed::StateMessage Struct Reference

What a participant of a distributed simulation sends: the state of its bodies at one step, or that it leaves. More...

#include <state_message.h>

Public Types

enum class  Kind : uint_t { STATE = 0 , LEAVE = 1 }

Public Member Functions

std::string encode () const
 The message in MessagePack, for a transport.

Static Public Member Functions

static StateMessage decode (const std::string &bytes)
 Read a message that encode() wrote.

Public Attributes

Kind kind {Kind::STATE}
std::string participant
uint_t step {0}
real_t time {0.0}
real_t stamp {0.0}
std::vector< BodyState > bodies
std::vector< real_t > values

Detailed Description

What a participant of a distributed simulation sends: the state of its bodies at one step, or that it leaves.

time is the simulated time of the step; stamp is the wall-clock time it was sent, in seconds since the epoch of std::chrono::system_clock, which a participant in wall-clock mode uses to tell how old the state is. Across machines that needs their clocks in step, with NTP for example.

values carries numbers that are not bodies: the action of an agent whose world every participant simulates, for one, or anything else the participants agree on.

Member Enumeration Documentation

◆ Kind

Enumerator
STATE 

the state of the bodies at step

LEAVE 

the participant stops; its last step was step

Member Function Documentation

◆ decode()

StateMessage bitsim::distributed::StateMessage::decode ( const std::string & bytes)
static

Read a message that encode() wrote.

Exceptions
std::invalid_argumentif bytes is not one

◆ encode()

std::string bitsim::distributed::StateMessage::encode ( ) const

The message in MessagePack, for a transport.

Member Data Documentation

◆ bodies

std::vector<BodyState> bitsim::distributed::StateMessage::bodies

◆ kind

Kind bitsim::distributed::StateMessage::kind {Kind::STATE}

◆ participant

std::string bitsim::distributed::StateMessage::participant

◆ stamp

real_t bitsim::distributed::StateMessage::stamp {0.0}

◆ step

uint_t bitsim::distributed::StateMessage::step {0}

◆ time

real_t bitsim::distributed::StateMessage::time {0.0}

◆ values

std::vector<real_t> bitsim::distributed::StateMessage::values

The documentation for this struct was generated from the following files: