YARP CiA-402 EtherCAT Device 0.6.0
YARP device plugin for EtherCAT CiA-402 drives
Loading...
Searching...
No Matches
CheckEncoderCalibration.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Generative Bionics
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef CHECK_ENCODER_CALIBRATION_H
5#define CHECK_ENCODER_CALIBRATION_H
6
7#include <cstdint>
8#include <memory>
9#include <string>
10
11#include <yarp/os/ResourceFinder.h>
12
13namespace CiA402
14{
15
16/**
17 * @brief Encoder calibration checker: compare live encoder readings against a reference TOML file.
18 *
19 * This utility connects to all EtherCAT slaves on the specified network interface using SDO
20 * communication and reads back the current encoder positions (raw and adjusted) and resolutions
21 * for both encoder channels. It then compares these live values against a reference TOML file
22 * previously written by @ref CiA402::StoreHome37 (store-home-position application) immediately after calibration.
23 *
24 * The result is a human-readable Markdown report containing one table per slave, showing:
25 * - The reference value from the TOML file.
26 * - The current live value read from the drive.
27 * - The difference (delta) between the two.
28 *
29 * This allows an operator to quickly verify whether the encoder state has drifted since the last
30 * calibration, without re-running the full homing procedure.
31 *
32 * @note Only SDO communication is used; the ring stays in SAFE-OP/PRE-OP throughout.
33 * @note SOEM uses 1-based slave indices; the TOML file must follow the same convention
34 * (@c slave_1, @c slave_2, …).
35 */
37{
38public:
39 /**
40 * @brief Default constructor.
41 *
42 * Allocates the internal implementation object. No EtherCAT communication is started.
43 */
45
46 /**
47 * @brief Destructor.
48 *
49 * Releases all resources owned by the implementation. If the EtherCAT master was
50 * initialised, it is cleanly shut down.
51 */
53
54 /// @cond — non-copyable
56 CheckEncoderCalibration& operator=(const CheckEncoderCalibration&) = delete;
57 /// @endcond
58
59 /**
60 * @brief Run the full encoder check and produce a Markdown report.
61 *
62 * Reads configuration from the provided ResourceFinder, discovers all EtherCAT slaves on
63 * the specified network interface, reads each slave's encoder data, compares it against
64 * the reference TOML file, and writes a Markdown report to disk.
65 *
66 * @param rf ResourceFinder populated with the parameters listed below.
67 * @return @c true if the check completed successfully and the report was written;
68 * @c false on any error (initialisation failure, TOML parse error, SDO read failure,
69 * file I/O error).
70 *
71 * @note Expected keys in the ResourceFinder:
72 * | Key | Type | Description | Default |
73 * |:----------------:|:-----------:|-------------------------------------------------------|:--------------------------:|
74 * | ifname | string | Network interface name (e.g. @c "eth0") | @c "eth0" |
75 * | toml-input | string | Path of the reference TOML file (from StoreHome37) | *(required)* |
76 * | report-output | string | Path of the Markdown report to write | @c "encoder_calibration_check_YYYY_MM_DD_HH_MM_SS.md" |
77 */
78 bool run(yarp::os::ResourceFinder& rf);
79
80private:
81 class Impl;
82 std::unique_ptr<Impl> m_impl; ///< Opaque implementation (PIMPL idiom).
83};
84
85} // namespace CiA402
86
87#endif // CHECK_ENCODER_CALIBRATION_H
bool run(yarp::os::ResourceFinder &rf)
Run the full encoder check and produce a Markdown report.