<commit_before>#include <ros/ros.h>
#include <ros/publisher.h>
#include <sensor_msgs/Imu.h>
#include <igvc/SerialPort.h>
#include <vector>
#include <sstream>
#include <tf/transform_datatypes.h>

using namespace std;

vector<string> split(const string &s, const char &delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        elems.push_back(item);
    }
    return elems;
}

int main(int argc, char** argv)
{
    ros::init(argc, argv, "ardupilot");
    
    ros::NodeHandle nh;
    
    ros::Publisher pub = nh.advertise<sensor_msgs::Imu>("/imu", 1000);
    
    SerialPort port("/dev/igvc_imu", 115200);
    
    while(ros::ok() && port.isOpen())
    {
        ros::spinOnce();
        
        auto line = port.readln();
        
        if(line[0] != 'A') continue;
        
        auto tokens = split(line, ' ');
        
        if(tokens.size() == 7)
        {
            sensor_msgs::Imu msg;
            
            try
            {
                auto roll = stof(tokens[1]);
                auto pitch = stof(tokens[2]);
                auto yaw = stof(tokens[3]);
                
                msg.orientation = tf::createQuaternionMsgFromRollPitchYaw(roll, pitch, yaw);
                
                msg.linear_acceleration.x = stof(tokens[4]);
                msg.linear_acceleration.y = stof(tokens[5]);
                msg.linear_acceleration.z = stof(tokens[6]);
                <commit_msg>Adds frame_id to imu msgs.<commit_after>#include <ros/ros.h>
#include <ros/publisher.h>
#include <sensor_msgs/Imu.h>
#include <igvc/SerialPort.h>
#include <vector>
#include <sstream>
#include <tf/transform_datatypes.h>

using namespace std;

vector<string> split(const string &s, const char &delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        elems.push_back(item);
    }
    return elems;
}

int main(int argc, char** argv)
{
    ros::init(argc, argv, "ardupilot");
    
    ros::NodeHandle nh;
    
    ros::Publisher pub = nh.advertise<sensor_msgs::Imu>("/imu", 1000);
    
    SerialPort port("/dev/igvc_imu", 115200);
    
    while(ros::ok() && port.isOpen())
    {
        ros::spinOnce();
        
        auto line = port.readln();
        
        if(line[0] != 'A') continue;
        
        auto tokens = split(line, ' ');
        
        if(tokens.size() == 7)
        {
            sensor_msgs::Imu msg;
            
            msg.header.frame_id = "/world";
            
            try
            {
                auto roll = stof(tokens[1]);
                auto pitch = stof(tokens[2]);
                auto yaw = stof(tokens[3]);
                
                msg.orientation = tf::createQuaternionMsgFromRollPitchYaw(roll, pitch, yaw);
                
                msg.linear_acceleration.x = stof(tokens[4]);
                msg.linear_acceleration.y = stof(tokens[5]);
                msg.linear_acceleration.z = stof(tokens[6]);
                
{'fraction_non_alphanumeric': 0.1383399209486166, 'fraction_numerical': 0.011857707509881422, 'mean_word_length': 1.8623939679547596, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '2864633', 'n_tokens_mistral': 1052, 'n_tokens_neox': 984, 'n_words': 186}