OpenWalker Project
Documentation of the ROS Packages
wrench.h
Go to the documentation of this file.
1 
34 #ifndef OPEN_WALKER_CORE_WRENCH_REF_H
35 #define OPEN_WALKER_CORE_WRENCH_REF_H
36 
37 #include <geometry_msgs/Wrench.h>
38 
39 #include <ow_core/force_ref.h>
40 #include <ow_core/moment_ref.h>
41 
42 namespace ow_core
43 {
55 template <typename _Scalar>
56 class Wrench :
57  public Eigen::Matrix<_Scalar, 6, 1>
58 {
59 public:
60  typedef _Scalar Scalar;
61  typedef Eigen::Matrix<Scalar, 6, 1> Base;
62 
68  static const Wrench& Default()
69  {
70  static const Wrench v = Base::Zero();
71  return v;
72  }
73 
74 public:
78  explicit Wrench()
79  {
80  }
81 
88  template <typename OtherDerived>
89  Wrench(const Eigen::EigenBase<OtherDerived>& other) :
90  Base(other)
91  {
92  }
93 
97  explicit Wrench(const geometry_msgs::Wrench& other)
98  {
99  operator=(other);
100  }
101 
105  using Base::operator=;
106 
111  void operator=(const geometry_msgs::Wrench& W)
112  {
113  force() = W.force;
114  moment() = W.torque;
115  }
116 
122  operator geometry_msgs::Wrench() const
123  {
124  geometry_msgs::Wrench W;
125  W.force = force();
126  W.torque = moment();
127  return W;
128  }
129 
135  geometry_msgs::Wrench toWrenchMsg() const
136  {
137  return static_cast<geometry_msgs::Wrench>(*this);
138  }
139 
144  {
145  return ForceRef<Base>(*this);
146  }
147 
152  {
153  return ForceRef<const Base>(*this);
154  }
155 
160  {
161  return MomentRef<Base>(*this,3);
162  }
163 
168  {
169  return MomentRef<const Base>(*this,3);
170  }
171 
175  std::string toString() const
176  {
177  std::ostringstream out;
178  out << this->transpose();
179  return out.str();
180  }
181 };
182 
183 } // namespace ow_core
184 
185 #endif // OPEN_WALKER_CORE_WRENCH_REF_H
MomentRef< Base > moment()
access to angular part
Definition: wrench.h:159
The MomentRef class.
Definition: moment_ref.h:52
Wrench()
Default Constructor.
Definition: wrench.h:78
geometry_msgs::Wrench toWrenchMsg() const
Conversion to geometry_msgs::Twist.
Definition: wrench.h:135
std::string toString() const
Conversion to std::string.
Definition: wrench.h:175
ForceRef< const Base > force() const
const access to linear part
Definition: wrench.h:151
ForceRef< Base > force()
access to linear part
Definition: wrench.h:143
Wrench(const geometry_msgs::Wrench &other)
Copy constructor form geometry_msgs::Wrench.
Definition: wrench.h:97
The ForceRef class.
Definition: force_ref.h:52
Definition: angular_acceleration.h:39
static const Wrench & Default()
Construct as Default.
Definition: wrench.h:68
void operator=(const geometry_msgs::Wrench &W)
Assignment form geometry_msgs::Wrench.
Definition: wrench.h:111
MomentRef< const Base > moment() const
const access to angular part
Definition: wrench.h:167
Wrench(const Eigen::EigenBase< OtherDerived > &other)
Copy constructor.
Definition: wrench.h:89
The Wrench class.
Definition: wrench.h:56