<commit_before>#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

MPU6050 mpu;
const int MPU=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
int16_t accel_X_reading = 0; //lpf of AcX
int enA = 6;
int in1 = 4;
int in2 = 5;
int enB = 10;
int in3 = 8;
int in4 = 9;
int test = 12;
int current_angle = 0;
int target_angle = 0;
bool flipper = false;
int Kp = 3;

// Infomation from glove
enum state {idle,forward_drive, backup, left_turn,right_turn};
state gesture_state = idle;
uint8_t turning_speed;
bool should_catapult;



void setup(){
  Wire.begin();
  mpu.initialize();
  mpu.dmpInitialize();
  mpu.setIntMotionEnabled(1);
  mpu.setMotionDetectionThreshold(2);
  mpu.setMotionDetectionDuration(1);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(test, OUTPUT);
  Serial.begin(9600);
}

void receive_info() {
   String command1 =  Serial.readStringUntil('#');
   String combine_string = NULL;
   String string1;
   String string2;
   String string3;
   int int_command1;
   int int_command2;
   int int_command3;
   int pos = 0;
   int pre_pos = 0;
   for (int i = 0; i < string.length(command1);i++){
     pos++;
     if (command1.substring(i,i+1) == " "){
        string1 = command1.substring(pos-i,i-1);
          
     } 
     
    }
    

   
   //int int_command1 = command1.toInt();
   //String command2 = Serial.readStringUntil(' ');
   //int int_command2 = command2.toInt();
   //String command3 = Serial.readStringUntil('#');
   //int int_command3 = command3.toInt();
   //Serial.println("Command: ");
   //Serial.println(int_command1);
   //Serial.println(int_command2);
   //Serial.println(int_command3);
   
  
}

void motorControl(int pwm1, int pwm2, int dir1, int dir2) {
  int p1, p2;
  if (pwm1 >= 255) {p1 = 255;}
  else {p1 = pwm1;}
  if (pwm2 >= 255) {p2 = 255;}
  else {p2 = pwm2;}
  if (dir1 == 0) {
    digitalWrite(in1, LOW);
    digitalWrite(in2, LOW);<commit_msg>using strtok function<commit_after>#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

MPU6050 mpu;
const int MPU=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
int16_t accel_X_reading = 0; //lpf of AcX
int enA = 6;
int in1 = 4;
int in2 = 5;
int enB = 10;
int in3 = 8;
int in4 = 9;
int test = 12;
int current_angle = 0;
int target_angle = 0;
bool flipper = false;
int Kp = 3;

// Infomation from glove
enum state {idle,forward_drive, backup, left_turn,right_turn};
state gesture_state = idle;
int turning_speed;
bool should_catapult;



void setup(){
  Wire.begin();
  mpu.initialize();
  mpu.dmpInitialize();
  mpu.setIntMotionEnabled(1);
  mpu.setMotionDetectionThreshold(2);
  mpu.setMotionDetectionDuration(1);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(test, OUTPUT);
  Serial.begin(9600);
}

void receive_info() {
  int intState;
   String command1 =  Serial.readStringUntil('#');
   char command[30];
   command1.toCharArray(command, 30);
   char *parseChar;
   parseChar = strtok(command, " ");
   
   intState = atoi(parseChar);
   //todo map interger state to enum
   parseChar = strtok(NULL, " ");
   turning_speed = atoi(parseChar);
   parseChar = strtok(NULL, " ");
   should_catapult = (atoi(parseChar) > 0);
   Serial.println(command1);
   Serial.println(command);
   
    

   
   //int int_command1 = command1.toInt();
   //String command2 = Serial.readStringUntil(' ');
   //int int_command2 = command2.toInt();
   //String command3 = Serial.readStringUntil('#');
   //int int_command3 = command3.toInt();
   //Serial.println("Command: ");
   //Serial.println(int_command1);
   //Serial.println(int_command2);
   //Serial.println(int_command3);
   
  
}

void motorControl(int pwm1, int pwm2, int dir1, int dir2) {
  int p1, p2;
  if (pwm1 >= 255) {p1 = 255;}
  else {p1 = pwm1;}
  if (pwm2 >= 255) {p2 = 255;}
  else {p2 = pwm2;}
  if (dir1 == 0) {
    digitalWrite(in1, LOW);
    digitalWrite(in2, LOW);
{'fraction_non_alphanumeric': 0.14463489081944117, 'fraction_numerical': 0.05048133364639587, 'mean_word_length': 3.676180021953897, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '4909391', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1695, 'n_words': 378}