Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified HumanLogger to be compatible with robot-log-visualizer #372

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Naming convention from `wrapper`\ `server` to `nws`\ `nwc` (https://github.com/robotology/human-dynamics-estimation/pull/367).
- HumanLogger device to be compatible with the `robot-log-visualizer` (https://github.com/robotology/human-dynamics-estimation/pull/372).

## [2.9.0] - 2023-10-17

Expand Down
23 changes: 19 additions & 4 deletions devices/HumanLogger/HumanLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ void HumanLogger::run()
"human_state::base_velocity");
pImpl->bufferManager.push_back(pImpl->jointPositions,
timeNow,
"human_state::joint_positions");
"joints_state::positions");
pImpl->bufferManager.push_back(pImpl->jointVelocities,
timeNow,
"human_state::joint_velocities");
"joints_state::velocities");
}
}

Expand Down Expand Up @@ -265,6 +265,17 @@ bool HumanLogger::impl::loadSettingsFromConfig(yarp::os::Searchable& config)
bufferConfig.save_periodically = config.find(save_periodically.c_str()).asBool();
}

std::string yarpRobotName = "yarp_robot_name";
std::string defaultYarpRobotName = "human-gazebo";
if (config.check(yarpRobotName.c_str()) && config.find(yarpRobotName.c_str()).isString()) {
bufferConfig.yarp_robot_name = config.find(yarpRobotName.c_str()).asString();
}
else {
bufferConfig.yarp_robot_name = defaultYarpRobotName;
yInfo() << LogPrefix << " missing parameter: " << yarpRobotName
<< " using default value: " << defaultYarpRobotName;
}

if (bufferConfig.save_periodically) {
std::string save_period = "save_period";
if (config.check(save_period.c_str()) && config.find(save_period.c_str()).isFloat64()) {
Expand All @@ -286,6 +297,8 @@ bool HumanLogger::impl::loadSettingsFromConfig(yarp::os::Searchable& config)
bufferConfig.auto_save = config.find(auto_save.c_str()).asBool();
}

bufferConfig.mat_file_version = matioCpp::FileVersion::MAT7_3;

if (!(bufferConfig.auto_save || bufferConfig.save_periodically)) {
yError()
<< LogPrefix
Expand Down Expand Up @@ -332,8 +345,8 @@ bool HumanLogger::impl::configureBufferManager()
ok = ok && bufferManager.addChannel({"human_state::base_position", {3, 1}});
ok = ok && bufferManager.addChannel({"human_state::base_orientation", {4, 1}});
ok = ok && bufferManager.addChannel({"human_state::base_velocity", {6, 1}});
ok = ok && bufferManager.addChannel({"human_state::joint_positions", {jointNamesState.size(), 1}, jointNamesState});
ok = ok && bufferManager.addChannel({"human_state::joint_velocities", {jointNamesState.size(), 1}, jointNamesState});
ok = ok && bufferManager.addChannel({"joints_state::positions", {jointNamesState.size(), 1}, jointNamesState});
ok = ok && bufferManager.addChannel({"joints_state::velocities", {jointNamesState.size(), 1}, jointNamesState});
}
}
if (settings.logHumanDynamics)
Expand Down Expand Up @@ -472,6 +485,8 @@ bool HumanLogger::attachAll(const yarp::dev::PolyDriverList& driverList)
yError() << LogPrefix << "Failed to start the loop.";
return false;
}

pImpl->bufferManager.setDescriptionList(pImpl->jointNamesState);

yInfo() << LogPrefix << "Successfully attached all the required devices";

Expand Down
Loading