Body.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 // includes
8 // std
9 #include <string>
10 
11 // SpaceVecAlg
12 #include <SpaceVecAlg/SpaceVecAlg>
13 
14 namespace rbd
15 {
16 
20 class Body
21 {
22 public:
23  Body() {}
24 
29  Body(const sva::RBInertiad & rbInertia, std::string name) : inertia_(rbInertia), name_(std::move(name)) {}
30 
37  Body(double mass, const Eigen::Vector3d & com, const Eigen::Matrix3d & inertia, std::string name)
38  : inertia_(mass, mass * com, inertia), name_(std::move(name))
39  {
40  }
41 
43  const std::string & name() const
44  {
45  return name_;
46  }
47 
49  const sva::RBInertiad & inertia() const
50  {
51  return inertia_;
52  }
53 
54  bool operator==(const Body & b) const
55  {
56  return name_ == b.name_;
57  }
58 
59  bool operator!=(const Body & b) const
60  {
61  return name_ != b.name_;
62  }
63 
64 private:
65  sva::RBInertiad inertia_;
66  std::string name_;
67 };
68 
69 inline std::ostream & operator<<(std::ostream & out, const Body & b)
70 {
71  out << "Body: " << b.name();
72  return out;
73 }
74 
75 } // namespace rbd
rbd::Body::operator==
bool operator==(const Body &b) const
Definition: Body.h:54
rbd::Body::Body
Body(double mass, const Eigen::Vector3d &com, const Eigen::Matrix3d &inertia, std::string name)
Definition: Body.h:37
rbd::operator<<
std::ostream & operator<<(std::ostream &out, const Body &b)
Definition: Body.h:69
rbd::Body::inertia
const sva::RBInertiad & inertia() const
Definition: Body.h:49
rbd
Definition: common.h:20
rbd::Body::name
const std::string & name() const
Definition: Body.h:43
rbd::Body
Definition: Body.h:20
rbd::Body::operator!=
bool operator!=(const Body &b) const
Definition: Body.h:59
rbd::Body::Body
Body(const sva::RBInertiad &rbInertia, std::string name)
Definition: Body.h:29
rbd::Body::Body
Body()
Definition: Body.h:23