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

Implement VectorsCollectionServer and VectorsCollectionClient classes #767

Merged
merged 3 commits into from
Nov 24, 2023

Conversation

GiulioRomualdi
Copy link
Member

@GiulioRomualdi GiulioRomualdi commented Nov 20, 2023

This PR substitutes #732.

This PR introduces metadata for the VectorsCollection, allowing each component of the vector saved by the logger to have a specific label. This enhancement simplifies data analysis, as it enables the display of associated labels in the robot-log-visualizer, as shown in the following image:

image

To ensure metadata consistency, I've implemented it using the client-server paradigm in YARP. I declared the VectorsCollectionMetadataService in VectorsCollection.thrift. This change enables asynchronous metadata requests for a specific VectorsCollection. This is done thanks to the VectorsCollectionServer and VectorsCollectionClient

In this context, the YarpRobotLoggerDevice functions as a client (VectorsCollectionClient), while the server must be implemented in the application sending the data.

Here's an example of how to use VectorsCollectionServer in your code:

#include <BipedalLocomotion/YarpUtilities/VectorsCollectionServer.h> 

class Module
{
    BipedalLocomotion::YarpUtilities::VectorsCollectionServer m_vectorsCollectionServer; /**< Logger server. */
public:
 // all the other functions you need
}

The m_vectorsCollectionServer helps you to handle the data you want to send and to populate the metadata. To use this functionality, call BipedalLocomotion::YarpUtilities::VectorsCollectionServer::populateMetadata during the configuration phase. Once you have finished populating the metadata you should call BipedalLocomotion::YarpUtilities::VectorsCollectionServer::finalizeMetadata

//This code should go into the configuration phase
auto loggerOption = std::make_shared<BipedalLocomotion::ParametersHandler::YarpImplementation>(rf);
if (!m_vectorsCollectionServer.initialize(loggerOption->getGroup("WALKING_LOGGER")))
{
    log()->error("[WalkingModule::configure] Unable to configure the server.");
    return false;
}
 
m_vectorsCollectionServer.populateMetadata("dcm::position::measured", {"x", "y"});
m_vectorsCollectionServer.populateMetadata("dcm::position::desired", {"x", "y"});

m_vectorsCollectionServer.finalizeMetadata();

In the main loop, add the following code to prepare and populate the data:

m_vectorsCollectionServer.clearData(); // optional see the documentation


// DCM
m_vectorsCollectionServer.populateData("dcm::position::measured", <signal>);
m_vectorsCollectionServer.populateData("dcm::position::desired", <signal>);

m_vectorsCollectionServer.sendData();

⚠️ This PR breaks all the code that uses the YarpRobotLoggerDevice for logging exogenous signals (cc @G-Cervettini @isorrentino)
This is an example of updated application that allows you to correctly fill the metadata: robotology/walking-controllers#158

@GiulioRomualdi GiulioRomualdi changed the title Implement VectorsCollectionServer class Implement VectorsCollectionServer and VectorsCollectionClient classes Nov 22, 2023
@GiulioRomualdi GiulioRomualdi self-assigned this Nov 22, 2023
@GiulioRomualdi GiulioRomualdi marked this pull request as ready for review November 22, 2023 19:59
@GiulioRomualdi
Copy link
Member Author

Hi @S-Dafarra I modified the code as you suggested, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants