bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
double_pendulum_system.h
Go to the documentation of this file.
1#ifndef BITSIM_SYSTEMS_DOUBLE_PENDULUM_SYSTEM_H
2#define BITSIM_SYSTEMS_DOUBLE_PENDULUM_SYSTEM_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/ChSystemNSC.h>
12
13#include <array>
14#include <memory>
15
16namespace bitsim
17{
18namespace systems
19{
20
25{
26 real_t l1 = 1.0;
27 real_t l2 = 1.0;
28 real_t m1 = 1.0;
29 real_t m2 = 1.0;
30 real_t width = 0.04;
31};
32
43{
44 public:
50 explicit DoublePendulumSystem(const DoublePendulumProperties &props = {}, real_t theta1 = 0.0,
51 real_t theta2 = 0.0);
52
56 void step(real_t dt);
57
61 std::array<real_t, 2> angles() const;
62
66 std::array<real_t, 2> angular_velocities() const;
67
71 real_t energy() const;
72
73 real_t time() const { return system_.GetChTime(); }
74 const DoublePendulumProperties &properties() const noexcept { return props_; }
75
79 chrono::ChSystemNSC &system() noexcept { return system_; }
80
81 private:
83 chrono::ChSystemNSC system_;
84 std::shared_ptr<chrono::ChBody> link1_;
85 std::shared_ptr<chrono::ChBody> link2_;
86};
87
88} // namespace systems
89} // namespace bitsim
90
91#endif
92
93#endif // BITSIM_SYSTEMS_DOUBLE_PENDULUM_SYSTEM_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
void step(real_t dt)
Advance the simulation by dt [s].
Definition double_pendulum_system.cpp:87
real_t time() const
Definition double_pendulum_system.h:73
const DoublePendulumProperties & properties() const noexcept
Definition double_pendulum_system.h:74
DoublePendulumSystem(const DoublePendulumProperties &props={}, real_t theta1=0.0, real_t theta2=0.0)
Definition double_pendulum_system.cpp:56
chrono::ChSystemNSC & system() noexcept
The Chrono system, to draw it.
Definition double_pendulum_system.h:79
std::array< real_t, 2 > angles() const
Definition double_pendulum_system.cpp:96
std::array< real_t, 2 > angular_velocities() const
Definition double_pendulum_system.cpp:101
real_t energy() const
Definition double_pendulum_system.cpp:107
Definition double_pendulum_system.cpp:18
Definition dc_motor_backend_base.h:9
double real_t
real_t
Definition bitsim_types.h:20
The two links of a double pendulum, each a uniform rod.
Definition double_pendulum_system.h:25
real_t width
the width of the links, as they are drawn [m]
Definition double_pendulum_system.h:30
real_t l2
the length of the lower link [m]
Definition double_pendulum_system.h:27
real_t m2
the mass of the lower link [kg]
Definition double_pendulum_system.h:29
real_t m1
the mass of the upper link [kg]
Definition double_pendulum_system.h:28
real_t l1
the length of the upper link [m]
Definition double_pendulum_system.h:26