bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
contact_counter.h
Go to the documentation of this file.
1#ifndef BITSIM_RIGID_BODIES_CHRONO_ROBOTS_CONTACT_COUNTER_H
2#define BITSIM_RIGID_BODIES_CHRONO_ROBOTS_CONTACT_COUNTER_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/ChContactContainer.h>
12#include <chrono/physics/ChSystem.h>
13
14#include <memory>
15#include <vector>
16
17namespace bitsim
18{
19namespace rb::bitsim_chrono
20{
21
31class ContactCounter : public chrono::ChContactContainer::ReportContactCallback
32{
33 public:
34 explicit ContactCounter(std::vector<std::shared_ptr<chrono::ChBody>> bodies);
35
39 uint_t count(chrono::ChSystem &system);
40
41 bool OnReportContact(const chrono::ChVector3d &, const chrono::ChVector3d &,
42 const chrono::ChMatrix33<> &, double distance, double,
43 const chrono::ChVector3d &, const chrono::ChVector3d &,
44 chrono::ChContactable *a, chrono::ChContactable *b, int) override;
45
46 private:
47 bool is_watched_(const chrono::ChContactable *c) const;
48
49 std::vector<std::shared_ptr<chrono::ChBody>> bodies_;
50 uint_t n_contacts_{0};
51};
52
53} // namespace rb::bitsim_chrono
54} // namespace bitsim
55
56#endif // BITSIM_CHRONO
57#endif // BITSIM_RIGID_BODIES_CHRONO_ROBOTS_CONTACT_COUNTER_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
ContactCounter(std::vector< std::shared_ptr< chrono::ChBody > > bodies)
Definition contact_counter.cpp:12
bool OnReportContact(const chrono::ChVector3d &, const chrono::ChVector3d &, const chrono::ChMatrix33<> &, double distance, double, const chrono::ChVector3d &, const chrono::ChVector3d &, chrono::ChContactable *a, chrono::ChContactable *b, int) override
Definition contact_counter.cpp:26
uint_t count(chrono::ChSystem &system)
The contacts of the system that touch one of the bodies now.
Definition contact_counter.cpp:17
Definition chrono_robot_pose.h:11
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40