<commit_before>#include "ros/ros.h"
#include <base_controller/encoders.h>               /* Custom message /encoders */
#include <sensor_msgs/JointState.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>

//int16_t EncoderL;
//int16_t EncoderR;
int16_t previous_EncoderL;
int16_t previous_EncoderR;
double deltaLeft;
double deltaRight;
double meter_per_tick = 0.001;
double x = 0.0;
double y = 0.0;
double th = 0.0;
double vx;
double vy;
double vth;
ros::Time current_time_encoder, last_time_encoder;

void encoderdata_callback(const base_controller::encoders& encoders){
    //EncoderL=encoders.encoder_l;
    //EncoderR=encoders.encoder_r;
    current_time_encoder = ros::Time::now();
    // calculate odomety
    // *****************
    deltaLeft = encoders.encoder_l - previous_EncoderL;
    deltaRight = encoders.encoder_r - previous_EncoderR;

    vx = deltaLeft * meter_per_tick;
    vy = deltaRight * meter_per_tick;

    previous_EncoderL = encoders.encoder_l;
    previous_EncoderR = encoders.encoder_r;
    last_time_encoder = current_time_encoder;
}

int main( int argc, char* argv[] ){
    ros::init(argc, argv, "odometry" );
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("/encoders", 100, encoderdata_callback);
    ros::Publisher odom_pub = n.advertise<nav_msgs::Odometry>("odom", 50);
    tf::TransformBroadcaster odom_broadcaster;

    ros::Time current_time, last_time;
    current_time = ros::Time::now();
    last_time = ros::Time::now();


    ros::Rate loop_rate(10);
    while(n.ok()){

        current_time = ros::Time::now();

        //compute odometry in a typical way given the velocities of the robot
        double dt = (current_time_encoder - last_time_encoder).toSec();<commit_msg>Update code<commit_after>#include "ros/ros.h"
#include <base_controller/encoders.h>               /* Custom message /encoders */
#include <sensor_msgs/JointState.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>

//int16_t EncoderL;
//int16_t EncoderR;
int16_t previous_EncoderL;
int16_t previous_EncoderR;
double deltaLeft;
double deltaRight;
double meter_per_tick = 0.001;
double x = 0.0;
double y = 0.0;
double th = 0.0;
double vx;
double vy;
double vth;
ros::Time current_time_encoder, last_time_encoder;

void encoderdata_callback(const base_controller::encoders& encoders){
    //EncoderL=encoders.encoder_l;
    //EncoderR=encoders.encoder_r;
    current_time_encoder = ros::Time::now();
    // calculate odomety
    // *****************
    deltaLeft = encoders.encoder_l - previous_EncoderL;
    deltaRight = encoders.encoder_r - previous_EncoderR;

    vx = deltaLeft * meter_per_tick;
    vy = deltaRight * meter_per_tick;

    previous_EncoderL = encoders.encoder_l;
    previous_EncoderR = encoders.encoder_r;
    last_time_encoder = current_time_encoder;
}

int main( int argc, char* argv[] ){
    ros::init(argc, argv, "odometry" );
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("/encoders", 100, encoderdata_callback);
    ros::Publisher odom_pub = n.advertise<nav_msgs::Odometry>("odom", 50);
    tf::TransformBroadcaster odom_broadcaster;

    ros::Time current_time, last_time;
    current_time = ros::Time::now();
    last_time = ros::Time::now();


    ros::Rate loop_rate(10);
    while(n.ok()){

        current_time = ros::Time::now();

        //compute odometry in a typical way given the velocities of the robot
        double dt = (current_time - last_time).toSec();
{'fraction_non_alphanumeric': 0.13045977011494253, 'fraction_numerical': 0.014367816091954023, 'mean_word_length': 4.180059523809524, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3827780', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1185, 'n_words': 248}