<commit_before>//
// Created by andrea on 05/04/16.
//

#include <lcm/lcm-cpp.hpp>
#include "PositionDispatcher.h"
#include <QApplication>
#include <iostream>
#include "QDebug"


class callbackHandler
{
public:
    ~callbackHandler() {}

    geometry::pose _vision_pos;
    geometry::pose _position_sp;
    int count = 0;

    bool _estimate_ready = false;
    bool _position_sp_ready = false;

    void callback(const lcm::ReceiveBuffer* rbuf, const std::string& chan, const geometry::pose* msg){



        for (int i = 0; i < 3; ++i) {
            _vision_pos.position[i] = msg->position[i];
        }

        for (int j = 0; j < 4; ++j) {
            _vision_pos.orientation[j] = msg->orientation[j];
        }
        _estimate_ready = true;

    }

    void callback2(const lcm::ReceiveBuffer* rbuf, const std::string& chan, const geometry::pose* msg){

        for (int i = 0; i < 3; ++i) {
            _position_sp.position[i] = msg->position[i];
        }

        for (int j = 0; j < 4; ++j) {
            _position_sp.orientation[j] = msg->orientation[j];
        }
        _position_sp.yaw = msg->yaw;
        _position_sp_ready = true;

    }

};


int main(int argc, char** argv){

    lcm::LCM handler;

    if (!handler.good())
        return 1;

    QApplication a(argc, argv);

    PositionDispatcher p;

    callbackHandler call;

    handler.subscribe("vision_position_estimate", &callbackHandler::callback, &call);
    handler.subscribe("local_position_sp", &callbackHandler::callback2, &call); // Do we need to bufferize sp messages?

    while(0==handler.handle()){

        p.sendPosition(call._vision_pos.timestamp, call._vision_pos, call._position_sp, call._estimate_ready, call._position_sp_ready);

        if(call._estimate_ready)    call._estimate_ready = false;
        //if(call._position_sp_ready) call._position_sp_ready = false;

        if (call._vision_pos.isValid == 0)
        std::cout<<"The rigid body has gone out from mocap"<<std::endl;

    }

    return 0;

}<commit_msg>add polling for position setpoint<commit_after>//
// Created by andrea on 05/04/16.
//

#include <lcm/lcm-cpp.hpp>
#include "PositionDispatcher.h"
#include <QApplication>
#include <iostream>
#include "QDebug"
#include <poll.h>


class callbackHandler
{
public:
    ~callbackHandler() {}

    geometry::pose _vision_pos;
    geometry::pose _position_sp;
    int count = 0;

    bool _estimate_ready = false;
    bool _position_sp_ready = false;

    void callback(const lcm::ReceiveBuffer* rbuf, const std::string& chan, const geometry::pose* msg){



        for (int i = 0; i < 3; ++i) {
            _vision_pos.position[i] = msg->position[i];
        }

        for (int j = 0; j < 4; ++j) {
            _vision_pos.orientation[j] = msg->orientation[j];
        }
        _estimate_ready = true;

    }

    void callback2(const lcm::ReceiveBuffer* rbuf, const std::string& chan, const geometry::pose* msg){

        for (int i = 0; i < 3; ++i) {
            _position_sp.position[i] = msg->position[i];
        }

        for (int j = 0; j < 4; ++j) {
            _position_sp.orientation[j] = msg->orientation[j];
        }
        _position_sp.yaw = msg->yaw;


    }

};


int main(int argc, char** argv){

    lcm::LCM handler, handler2;

    if (!handler.good())
        return 1;

    QApplication a(argc, argv);

    PositionDispatcher p;

    callbackHandler call;

    lcm::Subscription *sub  = handler.subscribe("vision_position_estimate", &callbackHandler::callback, &call);
    lcm::Subscription *sub2 = handler2.subscribe("local_position_sp", &callbackHandler::callback2, &call);

    sub->setQueueCapacity(1);
    sub2->setQueueCapacity(1);

    struct pollfd fds[1];

    fds[0].fd = handler2.getFileno();
    fds[0].events = POLLIN;



    while(0==handler.handle()){

        int ret = poll(fds,1,0);


        if (fds[0].revents & POLLIN){

            call._position_sp_ready = true;
            handler2.handle();

        }

        p.sendPosition(call._vision_pos.timestamp, call._vision_pos, call._position_sp, call._estimate_ready, call._position_sp_ready);

        if(call._estimate_ready)    call._estimate_ready = false;


        if (call._vision_pos.isValid == 0)
            std::cout<<"The rigid body has gone out from mocap"<<std::endl;

    }

    return 0;

}
{'fraction_non_alphanumeric': 0.13699582753824757, 'fraction_numerical': 0.012980992118683357, 'mean_word_length': 2.7294727744165947, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1168298', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1400, 'n_words': 319}