9#include <gtest/gtest.h>
15static constexpr double kHomePose[7] = { 0.0, 0.2618, 3.1416, -2.2689, 0.0, 0.9599, 1.5708 };
17namespace fs = std::filesystem;
18static fs::path repo_root() {
return fs::path(__FILE__).parent_path().parent_path(); }
29 fs::path root = repo_root();
30 if (!fs::exists(root /
"third_party/menagerie")) {
31 GTEST_SKIP() <<
"third_party/menagerie/ not found";
35 std::string mjcf = (root /
"third_party/menagerie/kinova_gen3/gen3.xml").
string();
39 r.
path = mjcf.c_str();
44 <<
"init_robot_from_mjcf() returned false";
56 EXPECT_EQ(s.n_joints, 7) <<
"expected 7 KDL joints, got " << s.n_joints;
57 TEST_INFO(
"nq=" << s.model->nq <<
" nv=" << s.model->nv <<
" kdl_joints=" << s.n_joints);
62 unsigned n =
static_cast<unsigned>(s.n_joints);
63 KDL::JntArray q_home(n);
64 for (
unsigned i = 0; i < n; ++i) q_home(i) = kHomePose[i];
66 mj_forward(s.model, s.data);
68 const double t0 = s.data->time;
70 ASSERT_TRUE(s.data->time > t0) <<
"simulation time did not advance after 100 steps";
74int main(
int argc,
char *argv[])
76 testing::InitGoogleTest(&argc, argv);
77 return RUN_ALL_TESTS();
bool init_robot_from_mjcf(Robot *r, mjModel *model, mjData *data, const char *base_body, const char *tip_body, const char *prefix="", const char *tool_body=nullptr)
void step_n(Robot *s, int n)
void set_joint_pos(Robot *r, const KDL::JntArray &q, bool call_forward=true)
bool build_scene(mjModel **out_model, mjData **out_data, const SceneSpec *spec)
void destroy_scene(mjModel *model, mjData *data)
std::vector< RobotSpec > robots
int main(int argc, char *argv[])
TEST_F(InitTest, BasicDOF)