diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61b22ab..fa442f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: if ${{matrix.yarp}}; then # yarp cd ${GITHUB_WORKSPACE} - git clone https://github.com/robotology/yarp.git --depth 1 --branch yarp-3.4 + git clone https://github.com/robotology/yarp.git --depth 1 --branch yarp-3.6 cd yarp && mkdir -p build && cd build cmake -DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} .. @@ -110,7 +110,7 @@ jobs: if ${{matrix.yarp}}; then # yarp cd ${GITHUB_WORKSPACE} - git clone https://github.com/robotology/yarp.git --depth 1 --branch yarp-3.4 + git clone https://github.com/robotology/yarp.git --depth 1 --branch yarp-3.6 cd yarp && mkdir -p build && cd build cmake -A x64 -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROBOTOLOGY_ROOT}/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install .. cmake --build . --config ${{ matrix.build_type }} --target INSTALL diff --git a/CHANGELOG.md b/CHANGELOG.md index e716019..643e9ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added the possibility to have channels with different types (including custom structs) in a single ``BufferManager``. - Fixed a bug preventing a log file to be saved when multiple channels are empty. - YARP is now an optional dependency +- Added `yarp_robot_name` in `telemetryDeviceDumper`. +- Refactored variables names in `telemetryDeviceDumper` in a more hierarchical structure. ## [0.4.0] - 2022-02-22 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff46dd..443c1c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(FeatureSummary) find_package(YCM 0.12 REQUIRED) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -set(YARP_REQUIRED_VERSION 3.4.0) +set(YARP_REQUIRED_VERSION 3.5.0) # Control where libraries and executables are placed during the build. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") diff --git a/README.md b/README.md index 36ae15f..02d0eae 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,9 @@ The dependencies are: - [matio-cpp](https://github.com/dic-iit/matio-cpp#installation) (minimum version 0.1.1) - [nlohmann_json](https://github.com/nlohmann/json#integration) (minimum version 3.10.0) - [Catch2](https://github.com/catchorg/Catch2.git) (v2.13.1, for the unit tests) + The optional dependencies are: -- [YARP](https://www.yarp.it/git-master/install.html) (minimum version 3.4.0) +- [YARP](https://www.yarp.it/git-master/install.html) (minimum version 3.5.0) ### Linux/macOS ``` @@ -466,16 +467,16 @@ The `telemetryDeviceDumper` is a [yarp device](http://yarp.it/git-master/note_de | `axesNames` | List of strings | - | - | Yes | The axes contained in the axesNames parameter are then mapped to the wrapped controlboard in the attachAll method, using controlBoardRemapper class. | | `logJointVelocity` (DEPRECATED) | bool | - | false | No | Enable the log of joint velocities. | | `logJointAcceleration` (DEPRECATED) | bool | - | false | No | Enable the log of joint accelerations. | -| `logIEncoders` | bool | - | true | No | Enable the log of `encoders`, `velocity` and `acceleration` (http://yarp.it/git-master/classyarp_1_1dev_1_1IEncoders.html) | -| `logITorqueControl` | bool | - | false | No | Enable the log of `torque`(http://yarp.it/git-master/classyarp_1_1dev_1_1ITorqueControl.html). | -| `logIMotorEncoders` | bool | - | false | No | Enable the log of `motor_encoders`, `motor_velocity` and `motor_acceleration` (http://yarp.it/git-master/classyarp_1_1dev_1_1IMotorEncoders.html). | -| `logIControlMode` | bool | - | false | No | Enable the log of `control_mode` (http://yarp.it/git-master/classyarp_1_1dev_1_1IControlMode.html. | -| `logIInteractionMode` | bool | - | false | No | Enable the log of `interaction_modes` (http://yarp.it/git-master/classyarp_1_1dev_1_1IInteractionMode.html. | -| `logIPidControl` | bool | - | false | No | Enable the log of `position_error`, `position_reference`, `torque_error`, `torque_reference`(http://yarp.it/git-master/classyarp_1_1dev_1_1IPidControl.html).| -| `logIAmplifierControl` | bool | - | false | No | Enable the log of `pwm` and `current` (http://yarp.it/git-master/classyarp_1_1dev_1_1IAmplifierControl.html). | +| `logIEncoders` | bool | - | true | No | Enable the log of `joints_state::positions`, `joints_state::velocities` and `joints_state::accelerations` (http://yarp.it/git-master/classyarp_1_1dev_1_1IEncoders.html) | +| `logITorqueControl` | bool | - | false | No | Enable the log of `joints_state::torques`(http://yarp.it/git-master/classyarp_1_1dev_1_1ITorqueControl.html). | +| `logIMotorEncoders` | bool | - | false | No | Enable the log of `motors_state::positions`, `motors_state::velocities` and `motors_state::accelerations` (http://yarp.it/git-master/classyarp_1_1dev_1_1IMotorEncoders.html). | +| `logIControlMode` | bool | - | false | No | Enable the log of `joints_state::control_mode` (http://yarp.it/git-master/classyarp_1_1dev_1_1IControlMode.html. | +| `logIInteractionMode` | bool | - | false | No | Enable the log of `joints_state::interaction_mode` (http://yarp.it/git-master/classyarp_1_1dev_1_1IInteractionMode.html. | +| `logIPidControl` | bool | - | false | No | Enable the log of `PIDs::position_error`, `PIDs::position_reference`, `PIDs::torque_error`, `PIDs::torque_reference`(http://yarp.it/git-master/classyarp_1_1dev_1_1IPidControl.html).| +| `logIAmplifierControl` | bool | - | false | No | Enable the log of `motors_state::pwm` and `motors_state::currents` (http://yarp.it/git-master/classyarp_1_1dev_1_1IAmplifierControl.html). | | `logAllQuantities` (DEPRECATED) | bool | - | false | No | Enable the log all quantities described above. | | `logControlBoardQuantities` | bool | - | false | No | Enable the log of all the quantities that requires the attach to a control board (`logIEncoders`, `logITorqueControl`, `logIMotorEncoders`, `logIControlMode`, `logIInteractionMode`, `logIPidControl`, `logIAmplifierControl`). | -| `logILocalization2D` | bool | - | false | No | Enable the log of `odometry_data` (http://yarp.it/git-master/classyarp_1_1dev_1_1Nav2D_1_1ILocalization2D.html). For properly logging the odometry data [this patch](https://github.com/robotology/yarp/pull/2602) is needed on YARP side | +| `logILocalization2D` | bool | - | false | No | Enable the log of `odometry_data` (http://yarp.it/git-master/classyarp_1_1dev_1_1Nav2D_1_1ILocalization2D.html). | | `saveBufferManagerConfiguration` | bool | - | false | No | Enable the save of the configuration of the BufferManager into `path`+ `"bufferConfig"` + `experimentName` + `".json"` | | `json_file` | string | - | - | No | Configure the `yarp::telemetry::experimental::BufferManager`s reading from a json file like [in Example configuration file](#example-configuration-file). Note that this configuration will overwrite the parameter-by-parameter configuration | | `experimentName` | string | - | - | Yes | Prefix of the files that will be saved. The files will be named: `experimentName`+`timestamp`+ `".mat"`. | @@ -485,6 +486,7 @@ The `telemetryDeviceDumper` is a [yarp device](http://yarp.it/git-master/note_de | `save_period` | double | seconds | - | Yes(if `save_periodically` is set to true) | The period in seconds of the save thread | | `data_threshold` | size_t | - | 0 | No | The save thread saves to a file if there are at least `data_threshold` samples | | `auto_save` | bool | - | false | No(but it has to be set to true if `save_periodically` is set to false) | the flag for enabling the save in the destructor of the `yarp::telemetry::experimental::BufferManager` | +| `yarp_robot_name` | string | - | "" | No | Name of the robot used during the experiment. | ### Mapping .mat variables -> YARP interfaces diff --git a/src/telemetryDeviceDumper/TelemetryDeviceDumper.cpp b/src/telemetryDeviceDumper/TelemetryDeviceDumper.cpp index 8eef859..be0438d 100644 --- a/src/telemetryDeviceDumper/TelemetryDeviceDumper.cpp +++ b/src/telemetryDeviceDumper/TelemetryDeviceDumper.cpp @@ -208,8 +208,15 @@ bool TelemetryDeviceDumper::loadSettingsFromConfig(yarp::os::Searchable& config) m_bufferConfig.auto_save = prop.find(auto_save.c_str()).asBool(); } + std::string yarp_robot_name = "yarp_robot_name"; + if (prop.check(yarp_robot_name.c_str()) && prop.find(yarp_robot_name.c_str()).isString()) { + m_bufferConfig.yarp_robot_name = prop.find(yarp_robot_name.c_str()).asString(); + } + } + m_bufferConfig.mat_file_version = matioCpp::FileVersion::MAT7_3; + if (!(m_bufferConfig.auto_save || m_bufferConfig.save_periodically)) { yError() << "TelemetryDeviceDumper: both auto_save and save_periodically are set to false, nothing will be saved."; return false; @@ -378,46 +385,46 @@ bool TelemetryDeviceDumper::configBufferManager(yarp::os::Searchable& conf) { bool ok{ true }; if (ok && (settings.logIEncoders || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "encoders", {jointPos.size(), 1} }); + ok = ok && bufferManager.addChannel({ "joints_state::positions", {jointPos.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logJointVelocity || settings.logIEncoders || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "velocity", {jointVel.size(), 1} }); + ok = ok && bufferManager.addChannel({ "joints_state::velocities", {jointVel.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logJointAcceleration || settings.logIEncoders || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "acceleration", {jointAcc.size(), 1} }); + ok = ok && bufferManager.addChannel({ "joints_state::accelerations", {jointAcc.size(), 1}, m_bufferConfig.description_list }); } // TODO check if it is more convenient having more BM if (ok && (settings.logIPidControl || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "position_error", {jointPosErr.size(), 1} }); - ok = ok && bufferManager.addChannel({ "position_reference", {jointPosRef.size(), 1} }); - ok = ok && bufferManager.addChannel({ "torque_error", {jointTrqErr.size(), 1} }); - ok = ok && bufferManager.addChannel({ "torque_reference", {jointTrqRef.size(), 1} }); + ok = ok && bufferManager.addChannel({ "PIDs::position_error", {jointPosErr.size(), 1}, m_bufferConfig.description_list }); + ok = ok && bufferManager.addChannel({ "PIDs::position_reference", {jointPosRef.size(), 1}, m_bufferConfig.description_list }); + ok = ok && bufferManager.addChannel({ "PIDs::torque_error", {jointTrqErr.size(), 1}, m_bufferConfig.description_list }); + ok = ok && bufferManager.addChannel({ "PIDs::torque_reference", {jointTrqRef.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logIAmplifierControl || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "pwm", {jointPWM.size(), 1} }); - ok = ok && bufferManager.addChannel({ "current", {jointCurr.size(), 1} }); + ok = ok && bufferManager.addChannel({ "motors_state::PWM", {jointPWM.size(), 1}, m_bufferConfig.description_list }); + ok = ok && bufferManager.addChannel({ "motors_state::currents", {jointCurr.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logITorqueControl || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "torque", {jointTrq.size(), 1} }); + ok = ok && bufferManager.addChannel({ "joints_state::torques", {jointTrq.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logIMotorEncoders || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "motor_encoder", {motorEnc.size(), 1} }); - ok = ok && bufferManager.addChannel({ "motor_velocity", {motorVel.size(), 1} }); - ok = ok && bufferManager.addChannel({ "motor_acceleration", {motorAcc.size(), 1} }); + ok = ok && bufferManager.addChannel({ "motors_state::positions", {motorEnc.size(), 1}, m_bufferConfig.description_list }); + ok = ok && bufferManager.addChannel({ "motors_state::velocities", {motorVel.size(), 1}, m_bufferConfig.description_list }); + ok = ok && bufferManager.addChannel({ "motors_state::accelerations", {motorAcc.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logIControlMode || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "control_mode", {controlModes.size(), 1} }); + ok = ok && bufferManager.addChannel({ "joints_state::control_mode", {controlModes.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logIInteractionMode || settings.logControlBoardQuantities)) { - ok = ok && bufferManager.addChannel({ "interaction_mode", {interactionModes.size(), 1} }); + ok = ok && bufferManager.addChannel({ "joints_state::interaction_mode", {interactionModes.size(), 1}, m_bufferConfig.description_list }); } if (ok && (settings.logILocalization2D)) { - ok = ok && bufferManager.addChannel({ "odometry_data", {odometryData.size(), 1} }); + ok = ok && bufferManager.addChannel({ "odometry_data", {odometryData.size(), 1}, m_bufferConfig.description_list }); } ok = ok && bufferManager.configure(m_bufferConfig); @@ -480,7 +487,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointPos, "encoders"); + bufferManager.push_back(jointPos, "joints_state::positions"); } } @@ -496,7 +503,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointVel , "velocity"); + bufferManager.push_back(jointVel , "joints_state::velocities"); } } @@ -511,7 +518,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointAcc, "acceleration"); + bufferManager.push_back(jointAcc, "joints_state::accelerations"); } @@ -527,7 +534,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointPosErr, "position_error"); + bufferManager.push_back(jointPosErr, "PIDs::position_error"); } ok = remappedControlBoardInterfaces.pid->getPidReferences(VOCAB_PIDTYPE_POSITION, jointPosRef.data()); @@ -538,7 +545,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointPosRef, "position_reference"); + bufferManager.push_back(jointPosRef, "PIDs::position_reference"); } @@ -550,7 +557,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointPosErr, "torque_error"); + bufferManager.push_back(jointPosErr, "PIDs::torque_error"); } ok = remappedControlBoardInterfaces.pid->getPidReferences(VOCAB_PIDTYPE_TORQUE, jointTrqRef.data()); @@ -561,7 +568,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointTrqRef, "torque_reference"); + bufferManager.push_back(jointTrqRef, "PIDs::torque_reference"); } } // Read amplifier @@ -577,7 +584,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointPWM, "pwm"); + bufferManager.push_back(jointPWM, "motors_state::PWM"); } ok = remappedControlBoardInterfaces.amp->getCurrents(jointCurr.data()); @@ -588,7 +595,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointCurr, "current"); + bufferManager.push_back(jointCurr, "motors_state::currents"); } } // Read torque @@ -601,7 +608,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(jointTrq, "torque"); + bufferManager.push_back(jointTrq, "joints_state::torques"); } } @@ -615,7 +622,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(motorEnc, "motor_encoder"); + bufferManager.push_back(motorEnc, "motors_state::positions"); } ok = remappedControlBoardInterfaces.imotenc->getMotorEncoderSpeeds(motorVel.data()); @@ -626,7 +633,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(motorVel, "motor_velocity"); + bufferManager.push_back(motorVel, "motors_state::velocities"); } ok = remappedControlBoardInterfaces.imotenc->getMotorEncoderAccelerations(motorAcc.data()); @@ -637,7 +644,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(motorAcc, "motor_acceleration"); + bufferManager.push_back(motorAcc, "motors_state::accelerations"); } } @@ -656,7 +663,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(controlModes, "control_mode"); + bufferManager.push_back(controlModes, "joints_state::control_mode"); } } @@ -679,7 +686,7 @@ void TelemetryDeviceDumper::readSensors() } else { - bufferManager.push_back(interactionModes, "interaction_mode"); + bufferManager.push_back(interactionModes, "joints_state::interaction_mode"); } }