2828#ifndef UR_CLIENT_LIBRARY_UR_CALIBRATION_CHECKER_H_INCLUDED
2929#define UR_CLIENT_LIBRARY_UR_CALIBRATION_CHECKER_H_INCLUDED
3030
31- #include < ur_client_library/comm/pipeline.h>
32-
31+ #include < ur_client_library/primary/primary_package_handler.h>
3332#include < ur_client_library/primary/robot_state/kinematics_info.h>
3433
3534namespace urcl
3635{
3736/* !
38- * \brief The CalibrationChecker class consumes primary packages ignoring all but KinematicsInfo
39- * packages. These are then checked against the used kinematics to see if the correct calibration
40- * is used .
37+ * \brief The CalibrationChecker checks a received KinematicsInfo package against a registered calibration hash
38+ * value. This way we know whether the robot that sent the KinematicsInfo package matches the
39+ * expected calibration .
4140 */
42- class CalibrationChecker : public comm ::IConsumer <primary_interface::PrimaryPackage >
41+ class CalibrationChecker : public primary_interface ::IPrimaryPackageHandler <primary_interface::KinematicsInfo >
4342{
4443public:
4544 /* !
@@ -51,40 +50,15 @@ class CalibrationChecker : public comm::IConsumer<primary_interface::PrimaryPack
5150 CalibrationChecker (const std::string& expected_hash);
5251 virtual ~CalibrationChecker () = default ;
5352
54- /* !
55- * \brief Empty setup function, as no setup is needed.
56- */
57- virtual void setupConsumer ()
58- {
59- }
60- /* !
61- * \brief Tears down the consumer.
62- */
63- virtual void teardownConsumer ()
64- {
65- }
66- /* !
67- * \brief Stops the consumer.
68- */
69- virtual void stopConsumer ()
70- {
71- }
72- /* !
73- * \brief Handles timeouts.
74- */
75- virtual void onTimeout ()
76- {
77- }
78-
7953 /* !
8054 * \brief Consumes a package, checking its hash if it is a KinematicsInfo package. If the hash
8155 * does not match the expected hash, an error is logged.
8256 *
83- * \param product The package to consume
57+ * \param kin_info The package to consume
8458 *
8559 * \returns True, if the package was consumed correctly
8660 */
87- virtual bool consume (std::shared_ptr< primary_interface::PrimaryPackage> product) ;
61+ virtual void handle ( primary_interface::KinematicsInfo& kin_info) override ;
8862
8963 /* !
9064 * \brief Used to make sure the calibration check is not performed several times.
@@ -107,10 +81,33 @@ class CalibrationChecker : public comm::IConsumer<primary_interface::PrimaryPack
10781 return matches_;
10882 }
10983
84+ /* !
85+ * \brief Get latest KinematicsInfo
86+ *
87+ * \return latest KinematicsInfo
88+ */
89+ virtual std::shared_ptr<primary_interface::KinematicsInfo> getData ()
90+ {
91+ if (data_ == nullptr )
92+ throw UrException (" A KinematicsInfo package has not been received yet" );
93+ return data_;
94+ }
95+
96+ /* !
97+ * \brief Returns whether the calibration check was successful.
98+ *
99+ * \param expected_hash The hash expected to match the hash on the robot
100+ *
101+ * \returns True if the robot's expected_hash matches the one given to the checker. False
102+ * if it doesn't match or the check was not yet performed.
103+ */
104+ bool checkCalibration (const std::string& expected_hash);
105+
110106private:
111107 std::string expected_hash_;
112108 bool checked_;
113109 bool matches_;
110+ std::shared_ptr<primary_interface::KinematicsInfo> data_;
114111};
115112} // namespace urcl
116113
0 commit comments