tesseract_urdf_calibration_unit.cpp
Go to the documentation of this file.
3 #include <gtest/gtest.h>
4 #include <Eigen/Geometry>
6 
10 
11 TEST(TesseractURDFUnit, parse_calibration) // NOLINT
12 {
13  {
14  std::string str = R"(<calibration rising="1" falling="2" extra="0 0 0"/>)";
16  EXPECT_TRUE(runTest<tesseract_scene_graph::JointCalibration::Ptr>(
18  EXPECT_NEAR(elem->rising, 1, 1e-8);
19  EXPECT_NEAR(elem->falling, 2, 1e-8);
20  }
21 
22  {
23  std::string str = R"(<calibration rising="1"/>)";
25  EXPECT_TRUE(runTest<tesseract_scene_graph::JointCalibration::Ptr>(
27  EXPECT_NEAR(elem->rising, 1, 1e-8);
28  EXPECT_NEAR(elem->falling, 0, 1e-8);
29  }
30 
31  {
32  std::string str = R"(<calibration falling="2"/>)";
34  EXPECT_TRUE(runTest<tesseract_scene_graph::JointCalibration::Ptr>(
36  EXPECT_NEAR(elem->rising, 0, 1e-8);
37  EXPECT_NEAR(elem->falling, 2, 1e-8);
38  }
39 
40  {
41  std::string str = R"(<calibration rising="a" falling="2"/>)";
43  EXPECT_FALSE(runTest<tesseract_scene_graph::JointCalibration::Ptr>(
45  }
46 
47  {
48  std::string str = R"(<calibration rising="1" falling="b"/>)";
50  EXPECT_FALSE(runTest<tesseract_scene_graph::JointCalibration::Ptr>(
52  }
53 
54  {
55  std::string str = "<calibration/>";
57  EXPECT_FALSE(runTest<tesseract_scene_graph::JointCalibration::Ptr>(
59  }
60 }
61 
62 TEST(TesseractURDFUnit, write_calibration) // NOLINT
63 {
64  {
65  tesseract_scene_graph::JointCalibration::Ptr cal = std::make_shared<tesseract_scene_graph::JointCalibration>();
66  cal->rising = 5.0;
67  cal->falling = 3.0;
68  std::string text;
69  EXPECT_EQ(0, writeTest<tesseract_scene_graph::JointCalibration::Ptr>(cal, &tesseract_urdf::writeCalibration, text));
70  EXPECT_NE(text, "");
71  }
72 
73  {
75  std::string text;
76  EXPECT_EQ(1, writeTest<tesseract_scene_graph::JointCalibration::Ptr>(cal, &tesseract_urdf::writeCalibration, text));
77  EXPECT_EQ(text, "");
78  }
79 }
tesseract_urdf::CALIBRATION_ELEMENT_NAME
static constexpr std::string_view CALIBRATION_ELEMENT_NAME
Definition: calibration.h:45
joint.h
tesseract_scene_graph::JointCalibration::Ptr
std::shared_ptr< JointCalibration > Ptr
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
EXPECT_TRUE
#define EXPECT_TRUE(args)
tesseract_urdf::parseCalibration
std::shared_ptr< tesseract_scene_graph::JointCalibration > parseCalibration(const tinyxml2::XMLElement *xml_element)
Parse a xml calibration element.
Definition: calibration.cpp:41
tesseract_urdf_common_unit.h
EXPECT_NEAR
#define EXPECT_NEAR(a, b, prec)
TESSERACT_COMMON_IGNORE_WARNINGS_POP
TEST
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH TESSERACT_COMMON_IGNORE_WARNINGS_POP TEST(TesseractURDFUnit, parse_calibration)
Definition: tesseract_urdf_calibration_unit.cpp:11
macros.h
calibration.h
Parse calibration from xml string.
tesseract_urdf::writeCalibration
tinyxml2::XMLElement * writeCalibration(const std::shared_ptr< const tesseract_scene_graph::JointCalibration > &calibration, tinyxml2::XMLDocument &doc)
Definition: calibration.cpp:66
EXPECT_EQ
#define EXPECT_EQ(a, b)
EXPECT_FALSE
#define EXPECT_FALSE(args)


tesseract_urdf
Author(s): Levi Armstrong
autogenerated on Thu Apr 24 2025 03:10:44