bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
chrono_ghosts.h
Go to the documentation of this file.
1#ifndef BITSIM_DISTRIBUTED_CHRONO_GHOSTS_H
2#define BITSIM_DISTRIBUTED_CHRONO_GHOSTS_H
3
4#include "bitsim/bitsim_config.h"
5
6#ifdef BITSIM_CHRONO
7
9
10#include <chrono/physics/ChBody.h>
11#include <chrono/physics/ChBodyEasy.h>
12#include <chrono/physics/ChSystem.h>
13
14#include <map>
15#include <memory>
16#include <string>
17#include <vector>
18
19namespace bitsim
20{
21namespace distributed
22{
23
28BodyState chrono_body_state(const std::string &name, const chrono::ChBody &body,
29 const std::array<real_t, 3> &size);
30
45{
46 public:
47 explicit CHRONO_Ghosts(chrono::ChSystem &system) : system_(system) {}
48
50
54 void update(const std::vector<PeerState> &peers);
55
59 uint_t size() const noexcept { return static_cast<uint_t>(ghosts_.size()); }
60
64 std::shared_ptr<chrono::ChBody> get(const std::string &participant,
65 const std::string &body) const;
66
67 private:
68 chrono::ChSystem &system_;
69 std::map<std::string, std::shared_ptr<chrono::ChBodyEasyBox>> ghosts_; // participant/body
70};
71
72} // namespace distributed
73} // namespace bitsim
74
75#endif
76#endif // BITSIM_DISTRIBUTED_CHRONO_GHOSTS_H
CHRONO_Ghosts(chrono::ChSystem &system)
Definition chrono_ghosts.h:47
~CHRONO_Ghosts()
Definition chrono_ghosts.cpp:31
std::shared_ptr< chrono::ChBody > get(const std::string &participant, const std::string &body) const
The ghost of a body of a peer, or nullptr.
Definition chrono_ghosts.cpp:39
void update(const std::vector< PeerState > &peers)
Place the ghosts where the peers say their bodies are.
Definition chrono_ghosts.cpp:46
uint_t size() const noexcept
The number of ghosts in the system.
Definition chrono_ghosts.h:59
Definition chrono_ghosts.cpp:12
BodyState chrono_body_state(const std::string &name, const chrono::ChBody &body, const std::array< real_t, 3 > &size)
The state of a Chrono body, to send to the other participants.
Definition chrono_ghosts.cpp:14
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
The state of one body of a participant: where it is, how it moves, and how big it is.
Definition state_message.h:24