<commit_before>#include "Manager.h"

Manager::Manager(DataLake *lake, 
                                   ComponentConfig &config, 
                                   string &name) : 
                                   Component(lake, config, name) {
	fid = -1;
	joystickInput = lake->readyReading("JoystickDrop");
	controlOutput = lake->readyWriting("CritterControlDrop");
	thinks = 0;
	speed = 25;
	newData = false;
	
}

Manager::~Manager() {
	//might want to make an array of these and just iterate?
	lake -> stopReading(joystickInput);
	lake -> stopWriting(controlOutput);
}

int Manager::loadConfig(ComponentConfig *config) {
  // see FakeLaser.cpp for ideas about how to read the config
	// file once we have some things that need to be configured
  

  return 1; 
}

int Manager::init(USeconds &wokeAt) {
	// why would I do things in init rather than the constructor?
  return 1; 
}

int Manager::think(USeconds &wokeAt) {
	//do we need to wait and think and all that?

	// read in the Joystick Control Drop
	joystickDrop = ((JoystickDrop*)lake->readHead(joystickInput));

	// translate the joystick controls into robot commands
	// write the robot commands to the drop
	if(joystickDrop) {

		//translate commands
		// buttons 1-4 control the percentage speed
		// button 7 toggles through led settings
		if(joystickDrop->buttons.somethingSet()) {
			if(joystickDrop->buttons.isSet(0))
				speed = 25;
			else if(joystickDrop->buttons.isSet(1))
				speed = 50;
			else if(joystickDrop->buttons.isSet(2))
				speed = 75;
			else if(joystickDrop->buttons.isSet(3))
				speed = 100;
			else if(joystickDrop->buttons.isSet(6))
			{
				// how do we toggle through led settings?
			}
		}
		// the right analog button moves linearly, the left analog button
		// controls the turning
		// these are set to a valid between -100 and 100 ?
		controlDrop.motor_mode = CritterControlDrop::XYTHETA_SPACE;
		controlDrop.x_vel = speed*(joystickDrop->rightAnalogX)/JOY_AXIS_MAX;
		controlDrop.y_vel = (joystickDrop->rightAnalogY/JOY_AXIS_MAX)*speed;
		controlDrop.theta_vel = (joystickDrop->leftAnalogX/JOY_AXIS_MAX)*speed;
		
		//copying James
		(*(CritterControlDrop*)lake->startWriteHead(controlOutput)) = controlDrop;
		lake ->doneWriteHead(controlOutput);
	}
	lake ->doneRead(joystickInput);<commit_msg>Got rid of a compiler warning. Velocities are ints<commit_after>#include "Manager.h"

Manager::Manager(DataLake *lake, 
                                   ComponentConfig &config, 
                                   string &name) : 
                                   Component(lake, config, name) {
	fid = -1;
	joystickInput = lake->readyReading("JoystickDrop");
	controlOutput = lake->readyWriting("CritterControlDrop");
	thinks = 0;
	speed = 25;
	newData = false;
	
}

Manager::~Manager() {
	//might want to make an array of these and just iterate?
	lake -> stopReading(joystickInput);
	lake -> stopWriting(controlOutput);
}

int Manager::loadConfig(ComponentConfig *config) {
  // see FakeLaser.cpp for ideas about how to read the config
	// file once we have some things that need to be configured
  

  return 1; 
}

int Manager::init(USeconds &wokeAt) {
	// why would I do things in init rather than the constructor?
  return 1; 
}

int Manager::think(USeconds &wokeAt) {
	//do we need to wait and think and all that?

	// read in the Joystick Control Drop
	joystickDrop = ((JoystickDrop*)lake->readHead(joystickInput));

	// translate the joystick controls into robot commands
	// write the robot commands to the drop
	if(joystickDrop) {

		//translate commands
		// buttons 1-4 control the percentage speed
		// button 7 toggles through led settings
		if(joystickDrop->buttons.somethingSet()) {
			if(joystickDrop->buttons.isSet(0))
				speed = 25;
			else if(joystickDrop->buttons.isSet(1))
				speed = 50;
			else if(joystickDrop->buttons.isSet(2))
				speed = 75;
			else if(joystickDrop->buttons.isSet(3))
				speed = 100;
			else if(joystickDrop->buttons.isSet(6))
			{
				// how do we toggle through led settings?
			}
		}
		// the right analog button moves linearly, the left analog button
		// controls the turning
		// these are set to a valid between -100 and 100 ?
		controlDrop.motor_mode = CritterControlDrop::XYTHETA_SPACE;
		controlDrop.x_vel = (int)speed*(joystickDrop->rightAnalogX)/JOY_AXIS_MAX;
		controlDrop.y_vel = (int)speed*(joystickDrop->rightAnalogY)/JOY_AXIS_MAX;
		controlDrop.theta_vel = (int)speed*(joystickDrop->leftAnalogX)/JOY_AXIS_MAX;
		
		//copying James
		(*(CritterControlDrop*)lake->startWriteHead(controlOutput)) = controlDrop;
		lake ->doneWriteHead(controlOutput);
	}
	lake ->doneRead(joystickInput);
{'fraction_non_alphanumeric': 0.10946236559139785, 'fraction_numerical': 0.012473118279569893, 'mean_word_length': 3.3386194029850746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7620314', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1431, 'n_words': 397}