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"
Go to the source code of this file.
Test the actuator model of the mini cheetah and cheetah 3 robots.
Definition in file test_actuatorModel.cpp.
Definition at line 15 of file test_actuatorModel.cpp.
References Quadruped< T >::buildActuatorModels(), and fpEqual().
18 auto& hipModel = actuatorModels[1];
21 hipModel.setFriction(
false);
23 double tauMaxPositive = 0, tauMaxNegative = 0;
24 double maxQdMaxTorque = 0, qdMax = 0;
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;
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;
43 for (
double qd = 0; qd < 40; qd += .01) {
44 double tauAct = hipModel.getTorque(18, qd);
45 if (!
fpEqual(18., tauAct, .0001)) {
51 for (
double qd = 0; qd < 60; qd += .01) {
52 double tauAct = hipModel.getTorque(18, qd);
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));
bool fpEqual(T a, T b, T tol)
std::vector< ActuatorModel< T > > buildActuatorModels()
Definition at line 65 of file test_actuatorModel.cpp.
References Quadruped< T >::buildActuatorModels(), and fpEqual().
68 auto& hipModel = actuatorModels[1];
71 hipModel.setFriction(
false);
73 double tauMaxPositive = 0, tauMaxNegative = 0;
74 double maxQdMaxTorque = 0, qdMax = 0;
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;
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;
93 for (
double qd = 0; qd < 40; qd += .01) {
94 double tauAct = hipModel.getTorque(208, qd);
95 if (!
fpEqual(208., tauAct, .0001)) {
101 for (
double qd = 0; qd < 60; qd += .01) {
102 double tauAct = hipModel.getTorque(208, qd);
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)
std::vector< ActuatorModel< T > > buildActuatorModels()