<commit_before>#include <gazebo/gazebo_config.h>
#include <gazebo/transport/transport.hh>
#include <gazebo/msgs/msgs.hh>

#if GAZEBO_MAJOR_VERSION >= 6
#include <gazebo/gazebo_client.hh>
#else
#include <gazebo/gazebo.hh>
#endif

#include <iostream>
#include <cstring>

static float robot_time;
static float robot_position[3];
static float robot_orientation[4];

void robot_callback(ConstPosesStampedPtr &msg)
{
    for (int index = 0; index < msg->pose_size(); index++) {

        if (msg->pose(index).name() == "robot") {
            robot_time = msg->time().sec() + msg->time().nsec() / 1e9;
            std::cout << "[" << robot_time << "] Robot pose received!" << std::endl;

            robot_position[0] = msg->pose(index).position().x();
            robot_position[1] = msg->pose(index).position().y();
            robot_position[2] = msg->pose(index).position().z();

            robot_orientation[0] = msg->pose(index).orientation().x();
            robot_orientation[1] = msg->pose(index).orientation().y();
            robot_orientation[2] = msg->pose(index).orientation().z();
            robot_orientation[3] = msg->pose(index).orientation().w();
        }
    }
}

int main(int argc, char **argv)
{
#if GAZEBO_MAJOR_VERSION >= 6
    gazebo::client::setup(argc, argv);
#else
    gazebo::setupClient(argc, argv);
#endif

    gazebo::transport::NodePtr node(new gazebo::transport::Node());
    node->Init();

    robot_time = 0.0f;
    memset(robot_position, 0, 3 * sizeof(float));
    memset(robot_orientation, 0, 4 * sizeof(float));

    gazebo::transport::SubscriberPtr robot_sub = node->Subscribe("~/pose/local/info", robot_callback);

    while (true) {
        gazebo::common::Time::MSleep(10);
    }

#if GAZEBO_MAJOR_VERSION >= 6
    gazebo::client::shutdown();
#else
    gazebo::shutdown();
#endif
}<commit_msg>Implement UDP publishing of robot pose<commit_after>#include <gazebo/gazebo_config.h>
#include <gazebo/transport/transport.hh>
#include <gazebo/msgs/msgs.hh>

#if GAZEBO_MAJOR_VERSION >= 6
#include <gazebo/gazebo_client.hh>
#else
#include <gazebo/gazebo.hh>
#endif

#include "UDPClient.hpp"
#include <iostream>
#include <cstring>

UDPClient *client;


void robot_callback(ConstPosesStampedPtr &msg)
{
    float robot_time, robot_pose[7];
    uint8_t udp_msg[7 * sizeof(float)];

    for (int index = 0; index < msg->pose_size(); index++) {
        if (msg->pose(index).name() == "robot") {
            robot_time = msg->time().sec() + msg->time().nsec() / 1e9;

            robot_pose[0] = msg->pose(index).position().x();
            robot_pose[1] = msg->pose(index).position().y();
            robot_pose[2] = msg->pose(index).position().z();

            robot_pose[3] = msg->pose(index).orientation().x();
            robot_pose[4] = msg->pose(index).orientation().y();
            robot_pose[5] = msg->pose(index).orientation().z();
            robot_pose[6] = msg->pose(index).orientation().w();

            std::cout << "[" << robot_time << "] Robot pose" << std::endl;

            memcpy(udp_msg, robot_pose, 7 * sizeof(float));
            client->send(udp_msg, 7 * sizeof(float));
        }
    }
}

int main(int argc, char **argv)
{
    // UDP client
    boost::asio::io_service io_service;
    client = new UDPClient(io_service, "localhost", "9998");

    // Gazebo client
#if GAZEBO_MAJOR_VERSION >= 6
    gazebo::client::setup(argc, argv);
#else
    gazebo::setupClient(argc, argv);
#endif

    gazebo::transport::NodePtr node(new gazebo::transport::Node());
    node->Init();

    gazebo::transport::SubscriberPtr robot_sub = node->Subscribe("~/pose/local/info", robot_callback);

    while (true) {
        gazebo::common::Time::MSleep(10);
    }

#if GAZEBO_MAJOR_VERSION >= 6
    gazebo::client::shutdown();
#else
    gazebo::shutdown();
#endif

    return 0;
}
{'fraction_non_alphanumeric': 0.1789087093389297, 'fraction_numerical': 0.012591815320041973, 'mean_word_length': 3.4964622641509435, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 50, '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': '766191', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1365, 'n_words': 229}