Skip to content

GiulioRomualdi/yarp-telemetry

 
 

Repository files navigation

YARP logo YARP telemetry

⚠️ LIBRARY UNDER DEVELOPMENT ⚠️

Continuous Integration

YARP homepage

This is the telemetry component for YARP.

Installation

Dependencies

The depencies are:

Linux/macOS

git clone https://github.com/robotology-playground/yarp-telemetry
cd yarp-telemetry
mkdir build && cd build
cmake ../
make
[sudo] make install

Notice: sudo is not necessary if you specify the CMAKE_INSTALL_PREFIX. In this case it is necessary to add in the .bashrc or .bash_profile the following lines:

export YARP_telemetry_DIR=/path/where/you/installed/

Windows

With IDE build tool facilities, such as Visual Studio:

git clone https://github.com/robotology-playground/yarp-telemetry
cd yarp-telemetry
mkdir build && cd build
cmake ..
cmake --build . --target ALL_BUILD --config Release
cmake --build . --target INSTALL --config Release

In order to allow CMake finding yarp-telemetry, you have to specify the path where you installed in the CMAKE_PREFIX_PATH or exporting the YARP_telemetry_DIR env variable pointing to the same path.

Usage

In order to use this library in your own appliction add this lines in your CMakeLists.txt

find_package(YARP COMPONENTS telemetry)

add_executable(myApp)
target_link_libraries(myApp YARP::YARP_telemetry)

Example scalar variable

Here is the code snippet for dumping in a .mat file 3 samples of the scalar varibles "one" and "two".

    yarp::telemetry::BufferManager<int32_t> bm(n_samples);
    bm.setFileName("buffer_manager_test.mat");
    yarp::telemetry::ChannelInfo var_one{ "one", {1,1} };
    yarp::telemetry::ChannelInfo var_two{ "two", {1,1} };

    auto ok = bm.addChannel(var_one);
    ok = ok && bm.addChannel(var_two);
    if (!ok) {
        std::cout << "Problem adding variables...."<<std::endl;
        return 1;
    }

    for (int i = 0; i < 10; i++) {
        bm.push_back({ i }, "one");
        yarp::os::Time::delay(0.2);
        bm.push_back({ i + 1 }, "two");
    }

    if (bm.saveToFile())
        std::cout << "File saved correctly!" << std::endl;
    else
        std::cout << "Something went wrong..." << std::endl;

And here is the resulting .mat file:

buffer_manager_test = 

  struct with fields:

    one: [1×1 struct]
    two: [1×1 struct]


buffer_manager_test.one

ans = 

  struct with fields:

          data: [1×1×3 int32]
    dimensions: [1 1 3]
          name: 'one'
    timestamps: [523132.9969457 523133.1979436 523133.3988861]

Example vector variable

It is possible to save and dump also vector variables. Here is the code snippet for dumping in a .mat file 3 samples of the 4x1 vector variables "one" and "two".

    yarp::telemetry::BufferManager<double> bm_v({ {"one",{4,1}},
                                                  {"two",{4,1}} }, 3);

    for (int i = 0; i < 10; i++) {
        bm_v.push_back({ i+1.0, i+2.0, i+3.0, i+4.0  }, "one");
        yarp::os::Time::delay(0.2);
        bm_v.push_back({ (double)i, i*2.0, i*3.0, i*4.0 }, "two");
    }

    if (bm_v.saveToFile("buffer_manager_test_vector.mat"))
        std::cout << "File saved correctly!" << std::endl;
    else
        std::cout << "Something went wrong..." << std::endl;
buffer_manager_test_vector = 

  struct with fields:

    one: [1×1 struct]
    two: [1×1 struct]

>> buffer_manager_test_vector.one

ans = 

  struct with fields:

          data: [4×1×3 double]
    dimensions: [4 1 3]
          name: 'one'
    timestamps: [523135.0186688 523135.219639 523135.4203739]

Example matrix variable

Here is the code snippet for dumping in a .mat file 3 samples of the 2x3 matrix variable"one" and of the 3x2 matrix variable "two".

    yarp::telemetry::BufferManager<int32_t> bm_m(n_samples, true);
    bm_m.setFileName("buffer_manager_test_matrix.mat");
    std::vector<yarp::telemetry::ChannelInfo> vars{ { "one",{2,3} },
                                   { "two",{3,2} } };

    ok = bm_m.addChannels(vars);
    if (!ok) {
        std::cout << "Problem adding variables...."<<std::endl;
        return 1;
    }

    for (int i = 0; i < 10; i++) {
        bm_m.push_back({ i + 1, i + 2, i + 3, i + 4, i + 5, i + 6 }, "one");
        yarp::os::Time::delay(0.2);
        bm_m.push_back({ i * 1, i * 2, i * 3, i * 4, i * 5, i * 6 }, "two");
    }
>> buffer_manager_test_matrix.one

ans = 

  struct with fields:

          data: [2×3×3 int32]
    dimensions: [2 3 3]
          name: 'one'
    timestamps: [112104.7605783 112104.9608881 112105.1611651]
    

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

See License

About

YARP telemetry component

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 75.9%
  • CMake 22.6%
  • C 1.5%