Biorbd
ActuatorLinear.cpp
1 #define BIORBD_API_EXPORTS
2 #include "Actuators/ActuatorLinear.h"
3 
4 #include "Utils/Error.h"
5 #include "RigidBody/GeneralizedCoordinates.h"
6 
8  Actuator(),
9  m_m(std::make_shared<biorbd::utils::Scalar>(0)),
10  m_b(std::make_shared<biorbd::utils::Scalar>(0))
11 {
12  setType();
13 }
14 
16  const biorbd::actuator::ActuatorLinear &other) :
17  Actuator(other),
18  m_m(other.m_m),
19  m_b(other.m_b)
20 {
21 
22 }
23 
25  int direction,
26  const biorbd::utils::Scalar& T0,
27  const biorbd::utils::Scalar& slope,
28  unsigned int dofIdx) :
29  Actuator(direction, dofIdx),
30  m_m(std::make_shared<biorbd::utils::Scalar>(slope)),
31  m_b(std::make_shared<biorbd::utils::Scalar>(T0))
32 {
33  setType();
34 }
35 
37  int direction,
38  const biorbd::utils::Scalar& T0,
39  const biorbd::utils::Scalar& slope,
40  unsigned int dofIdx,
41  const biorbd::utils::String &jointName) :
42  Actuator(direction, dofIdx, jointName),
43  m_m(std::make_shared<biorbd::utils::Scalar>(slope)),
44  m_b(std::make_shared<biorbd::utils::Scalar>(T0))
45 {
46  setType();
47 }
48 
50 {
51 
52 }
53 
55 {
57  copy.DeepCopy(*this);
58  return copy;
59 }
60 
62 {
64  *m_m = *other.m_m;
65  *m_b = *other.m_b;
66 }
67 
69 {
70  biorbd::utils::Error::raise("torqueMax for ActuatorLinear must be called with Q and Qdot");
71 }
72 
73 
76  return (Q[*m_dofIdx]*180/M_PI) * *m_m + *m_b;
77 }
78 
80 {
81  *m_type = biorbd::actuator::TYPE::LINEAR;
82 }
biorbd::actuator::Actuator
Class Actuator.
Definition: Actuator.h:20
biorbd::actuator::ActuatorLinear::DeepCopy
biorbd::actuator::ActuatorLinear DeepCopy() const
Deep copy of the linear actuator.
Definition: ActuatorLinear.cpp:54
biorbd::rigidbody::GeneralizedCoordinates
Class GeneralizedCoordinates.
Definition: GeneralizedCoordinates.h:15
biorbd::utils::Error::raise
static void raise(const biorbd::utils::String &message)
Throw an error message.
Definition: Error.cpp:4
biorbd::actuator::ActuatorLinear::~ActuatorLinear
virtual ~ActuatorLinear()
Destroy the class properly.
Definition: ActuatorLinear.cpp:49
biorbd::actuator::ActuatorLinear::m_m
std::shared_ptr< biorbd::utils::Scalar > m_m
Slope.
Definition: ActuatorLinear.h:102
biorbd::actuator::ActuatorLinear::torqueMax
virtual biorbd::utils::Scalar torqueMax()
Return the maximal torque (invalid)
Definition: ActuatorLinear.cpp:68
biorbd::actuator::Actuator::DeepCopy
void DeepCopy(const biorbd::actuator::Actuator &other)
Deep copy of actuator.
Definition: Actuator.cpp:55
biorbd::utils::String
Wrapper around the std::string class with augmented functionality.
Definition: String.h:17
biorbd::actuator::ActuatorLinear
Class ActuatorLinear is a joint actuator type that linearly evolves.
Definition: ActuatorLinear.h:18
biorbd::actuator::ActuatorLinear::ActuatorLinear
ActuatorLinear()
Construct a linear actuator.
Definition: ActuatorLinear.cpp:7
biorbd::actuator::ActuatorLinear::m_b
std::shared_ptr< biorbd::utils::Scalar > m_b
Torque at zero.
Definition: ActuatorLinear.h:103
biorbd::actuator::ActuatorLinear::setType
virtual void setType()
Set the type of actuator.
Definition: ActuatorLinear.cpp:79