Cheetah Software  1.0
test_actuatorModel.cpp File Reference

Test the actuator model of the mini cheetah and cheetah 3 robots. More...

#include "Dynamics/ActuatorModel.h"
#include "Dynamics/Cheetah3.h"
#include "Dynamics/MiniCheetah.h"
#include "Dynamics/Quadruped.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+ Include dependency graph for test_actuatorModel.cpp:

Go to the source code of this file.

Functions

 TEST (ActuatorModel, miniCheetah)
 
 TEST (ActuatorModel, cheetah3)
 

Detailed Description

Test the actuator model of the mini cheetah and cheetah 3 robots.

Definition in file test_actuatorModel.cpp.

Function Documentation

TEST ( ActuatorModel  ,
miniCheetah   
)

Definition at line 15 of file test_actuatorModel.cpp.

References Quadruped< T >::buildActuatorModels(), and fpEqual().

15  {
16  Quadruped<double> quad = buildMiniCheetah<double>();
17  auto actuatorModels = quad.buildActuatorModels();
18  auto& hipModel = actuatorModels[1];
19 
20  // first, disable friction
21  hipModel.setFriction(false);
22 
23  double tauMaxPositive = 0, tauMaxNegative = 0;
24  double maxQdMaxTorque = 0, qdMax = 0;
25 
26  // check our max torque in the positive direction:
27  for (double tau = 0; tau < 200; tau += .1) {
28  double tauAct = hipModel.getTorque(tau, 0);
29  if (!fpEqual(tau, tauAct, .0001)) {
30  tauMaxPositive = tauAct;
31  break;
32  }
33  }
34 
35  for (double tau = 0; tau > -200; tau -= .1) {
36  double tauAct = hipModel.getTorque(tau, 0);
37  if (!fpEqual(tau, tauAct, .0001)) {
38  tauMaxNegative = tauAct;
39  break;
40  }
41  }
42 
43  for (double qd = 0; qd < 40; qd += .01) {
44  double tauAct = hipModel.getTorque(18, qd);
45  if (!fpEqual(18., tauAct, .0001)) {
46  maxQdMaxTorque = qd;
47  break;
48  }
49  }
50 
51  for (double qd = 0; qd < 60; qd += .01) {
52  double tauAct = hipModel.getTorque(18, qd);
53  if (tauAct <= 0) {
54  qdMax = qd;
55  break;
56  }
57  }
58 
59  EXPECT_TRUE(fpEqual(tauMaxPositive, 18., .0001));
60  EXPECT_TRUE(fpEqual(tauMaxNegative, -18., .0001));
61  EXPECT_TRUE(fpEqual(maxQdMaxTorque, 28.47, .02));
62  EXPECT_TRUE(fpEqual(qdMax, 40., .0001));
63 }
bool fpEqual(T a, T b, T tol)
Definition: utilities.h:15
std::vector< ActuatorModel< T > > buildActuatorModels()
Definition: Quadruped.cpp:225

+ Here is the call graph for this function:

TEST ( ActuatorModel  ,
cheetah3   
)

Definition at line 65 of file test_actuatorModel.cpp.

References Quadruped< T >::buildActuatorModels(), and fpEqual().

65  {
66  Quadruped<double> quad = buildCheetah3<double>();
67  auto actuatorModels = quad.buildActuatorModels();
68  auto& hipModel = actuatorModels[1];
69 
70  // first, disable friction
71  hipModel.setFriction(false);
72 
73  double tauMaxPositive = 0, tauMaxNegative = 0;
74  double maxQdMaxTorque = 0, qdMax = 0;
75 
76  // check our max torque in the positive direction:
77  for (double tau = 0; tau < 300; tau += .1) {
78  double tauAct = hipModel.getTorque(tau, 0);
79  if (!fpEqual(tau, tauAct, .0001)) {
80  tauMaxPositive = tauAct;
81  break;
82  }
83  }
84 
85  for (double tau = 0; tau > -300; tau -= .1) {
86  double tauAct = hipModel.getTorque(tau, 0);
87  if (!fpEqual(tau, tauAct, .0001)) {
88  tauMaxNegative = tauAct;
89  break;
90  }
91  }
92 
93  for (double qd = 0; qd < 40; qd += .01) {
94  double tauAct = hipModel.getTorque(208, qd);
95  if (!fpEqual(208., tauAct, .0001)) {
96  maxQdMaxTorque = qd;
97  break;
98  }
99  }
100 
101  for (double qd = 0; qd < 60; qd += .01) {
102  double tauAct = hipModel.getTorque(208, qd);
103  if (tauAct <= 0) {
104  qdMax = qd;
105  break;
106  }
107  }
108 
109  EXPECT_TRUE(fpEqual(tauMaxPositive, 208.6, .1));
110  EXPECT_TRUE(fpEqual(tauMaxNegative, -208.6, .1));
111  EXPECT_TRUE(fpEqual(maxQdMaxTorque, 8.44, .02));
112  EXPECT_TRUE(fpEqual(qdMax, 15.94, .1));
113 }
bool fpEqual(T a, T b, T tol)
Definition: utilities.h:15
std::vector< ActuatorModel< T > > buildActuatorModels()
Definition: Quadruped.cpp:225

+ Here is the call graph for this function: