<commit_before>#include <ros/ros.h>                                        /* ROS */
#include <geometry_msgs/Twist.h>                            /* ROS Twist message */
#include <base_controller/encoders.h>                       /* custom message /encoders */
#include <base_controller/md49data.h>                       /* custom message /encoders */
#include <serialport/serialport.h>                          // library for serial communications via UART

#define TIMEOUT 1000                                        // timeout for reading serialport in ms
#define ON true
#define OFF false
#define OR ||
#define NOT !=

void md49_set_speed (void);
void md49_set_mode(int mode);
void md49_set_acceleration(int acceleration);
void md49_enable_timeout(void);
void md49_enable_regulator(void);
void md49_disable_timeout(void);
void md49_disable_regulator(void);
void md49_get_acceleration(void);
void md49_get_mode(void);
void md49_get_encoders(void);
void md49_get_speed(void);
void md49_get_currents(void);
void md49_get_error(void);
void md49_get_volts(void);

base_controller::encoders encoders;                         // topic /encoders
base_controller::md49data md49data;                         // topic /md49data
cereal::CerealPort device;                                  // serialport
std::string serialport;                                     // keeps used serialport on Pi, is read from parameters server
int serialport_bps;                                         // keeps used baudrate, is read from parameters server
int md49_mode;                                              // keeps MD49 Mode, is read from parameters server
int md49_acceleration;                                      // keeps MD49 Acceleration,  is read from parameters server
bool md49_timeout;
bool md49_regulator;
int speed_l, speed_r;                                       // default speed_l and speed_r for MD49
int last_speed_l=128, last_speed_r=128;                     // buffers last set speed_l and speed_r
char reply[8];                                              // max buffersize serial input

void cmd_vel_callback(const geometry_msgs::Twist& vel_cmd){
    if (vel_cmd.linear.x>0){
        //speed_l = 255;
        //speed_r = 255;
        //int delta_l, delta_r;
        //delta_l=
        speed_l = 128+(635*vel_cmd.linear.x);
        speed_r = 128+(635*vel_cmd.linear.x);
    }
    if (vel_cmd.linear.x<0){
        speed_l = 0;
        speed_r = 0;
    }
    if (vel_cmd.linear.x==0 && vel_cmd.angular.z==0){
        speed_l = 128;
        speed_r = 128;
    }<commit_msg>Update analog speed_l and speed_r<commit_after>#include <ros/ros.h>                                        /* ROS */
#include <geometry_msgs/Twist.h>                            /* ROS Twist message */
#include <base_controller/encoders.h>                       /* custom message /encoders */
#include <base_controller/md49data.h>                       /* custom message /encoders */
#include <serialport/serialport.h>                          // library for serial communications via UART

#define TIMEOUT 1000                                        // timeout for reading serialport in ms
#define ON true
#define OFF false
#define OR ||
#define NOT !=

void md49_set_speed (void);
void md49_set_mode(int mode);
void md49_set_acceleration(int acceleration);
void md49_enable_timeout(void);
void md49_enable_regulator(void);
void md49_disable_timeout(void);
void md49_disable_regulator(void);
void md49_get_acceleration(void);
void md49_get_mode(void);
void md49_get_encoders(void);
void md49_get_speed(void);
void md49_get_currents(void);
void md49_get_error(void);
void md49_get_volts(void);

base_controller::encoders encoders;                         // topic /encoders
base_controller::md49data md49data;                         // topic /md49data
cereal::CerealPort device;                                  // serialport
std::string serialport;                                     // keeps used serialport on Pi, is read from parameters server
int serialport_bps;                                         // keeps used baudrate, is read from parameters server
int md49_mode;                                              // keeps MD49 Mode, is read from parameters server
int md49_acceleration;                                      // keeps MD49 Acceleration,  is read from parameters server
bool md49_timeout;
bool md49_regulator;
int speed_l, speed_r;                                       // default speed_l and speed_r for MD49
int last_speed_l=128, last_speed_r=128;                     // buffers last set speed_l and speed_r
char reply[8];                                              // max buffersize serial input

void cmd_vel_callback(const geometry_msgs::Twist& vel_cmd){
    if (vel_cmd.linear.x>0){
        //speed_l = 255;
        //speed_r = 255;
        speed_l = 128+(635*vel_cmd.linear.x);
        speed_r = 128+(635*vel_cmd.linear.x);
    }
    if (vel_cmd.linear.x<0){
        //speed_l = 0;
        //speed_r = 0;
        speed_l = 128+(635*vel_cmd.linear.x);
        speed_r = 128+(635*vel_cmd.linear.x);
    }
    if (vel_cmd.linear.x==0 && vel_cmd.angular.z==0){
        speed_l = 128;
        speed_r = 128;
    }
{'fraction_non_alphanumeric': 0.08909752826211918, 'fraction_numerical': 0.037171872006131444, 'mean_word_length': 1.8446866485013624, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2891925', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1454, 'n_words': 380}