<commit_before>#include "Intake.h"
#include "Commands/IntakeBall.h"
#include "Commands/PushBall.h"
#include <math.h>

/**
 * Subsystems namespace with implementation
 * of Intake class.
 */
namespace subsystems
{

using IntakeBall = commands::IntakeBall;
using PushBall = commands::PushBall;

// Constructor:
Intake::Intake() : dman::WPISystem("Intake")
{
	roller_ = NULL; // keep null until configure time
	detector_ = new DigitalInput(0);

	// Default values:
	intake_speed_ = 0.8;
	push_speed_ = -1.0;

	state_ = State_t::OFF;
	mode_ = Mode_t::VELOCITY;

	max_velocity_ = 30;
	allowed_error_ = 0.1;
	shoot_velocity_ = 1.0;
}

// Destructor:
Intake::~Intake()
{
	delete roller_;
	delete detector_;
}

// Dalek Manager config functions:
void Intake::doRegister()
{
	// CAN port settings:
	auto& can_ports = GetPortSpace("CAN");
	can_ports("intake_roller").SetDefault(5);

	// Instance variable settings
	auto& settings = GetSettings();
	settings("intake_speed").SetDefault(intake_speed_);
	settings("push_speed").SetDefault(push_speed_);
	settings("max_velocity").SetDefault(max_velocity_);
	settings("allowed_error").SetDefault(allowed_error_);
	settings("shoot_velocity").SetDefault(shoot_velocity_);

	// PID Settings | TODO: Set proper default values
	auto& closed_loop_settings = settings["closed_loop_settings"];
	closed_loop_settings("use").SetDefault(false);
	closed_loop_settings("P").SetDefault(.1);
	closed_loop_settings("I").SetDefault(0.0);
	closed_loop_settings("D").SetDefault(0.0);
	closed_loop_settings("F").SetDefault(1.0);
	closed_loop_settings("I_Zone").SetDefault(2.5);
	closed_loop_settings("ramp_rate").SetDefault(10);

	// Inversion settings
	settings["intake_roller"]("invert_output").SetDefault(false);
	settings["intake_roller"]("invert_sensor").SetDefault(false);
}

bool Intake::doConfigure()
{
	std::cout << "Configuring Intake" << std::endl; // TODO: Change cout to Log

	// Initialize roller to CAN port
	auto& can_ports = GetPortSpace("CAN");
	if (roller_ == NULL)
		roller_ = new CANTalon(can_ports("intake_roller").GetValueOrDefault());

	// Configure variable values
	auto& settings = GetSettings();
	SetIntakeSpeed(settings("intake_speed").GetValueOrDefault());
	SetPushSpeed(settings("push_speed").GetValueOrDefault());
	SetMaxVelocity(settings("max_velocity").GetValueOrDefault());
	SetAllowedError(settings("allowed_error").GetValueOrDefault());
	SetShootVelocity(settings("shoot_velocity").GetValueOrDefault());

	// Configure closed loop settings
	auto& closed_loop_settings = settings["closed_loop_settings"];
	if (closed_loop_settings("use").GetValueOrDefault() == true)
	{
		roller_->SetP(closed_loop_settings("P").GetValueOrDefault());
		roller_->SetI(closed_loop_settings("I").GetValueOrDefault());
		roller_->SetD(closed_loop_settings("D").GetValueOrDefault());
		roller_->SetF(closed_loop_settings("F").GetValueOrDefault());
		roller_->SetIzone(closed_loop_settings("I_Zone").GetValueOrDefault());
		roller_->SetCloseLoopRampRate(closed_loop_settings("ramp_rate").GetValueOrDefault());
	}

	// Configure roller settings
	auto& ports = GetPortSpace("CAN");
	roller_->SetInverted(settings["intake_roller"]("invert_output").GetValueOrDefault());
	roller_->SetSensorDirection(settings["intake_roller"]("invert_sensor").GetValueOrDefault());

	return true;
}

// Main functions:
void Intake::Initialize()<commit_msg>Got rid of useless line. Why did I put that there?<commit_after>#include "Intake.h"
#include "Commands/IntakeBall.h"
#include "Commands/PushBall.h"
#include <math.h>

/**
 * Subsystems namespace with implementation
 * of Intake class.
 */
namespace subsystems
{

using IntakeBall = commands::IntakeBall;
using PushBall = commands::PushBall;

// Constructor:
Intake::Intake() : dman::WPISystem("Intake")
{
	roller_ = NULL; // keep null until configure time
	detector_ = new DigitalInput(0);

	// Default values:
	intake_speed_ = 0.8;
	push_speed_ = -1.0;

	state_ = State_t::OFF;
	mode_ = Mode_t::VELOCITY;

	max_velocity_ = 30;
	allowed_error_ = 0.1;
	shoot_velocity_ = 1.0;
}

// Destructor:
Intake::~Intake()
{
	delete roller_;
	delete detector_;
}

// Dalek Manager config functions:
void Intake::doRegister()
{
	// CAN port settings:
	auto& can_ports = GetPortSpace("CAN");
	can_ports("intake_roller").SetDefault(5);

	// Instance variable settings
	auto& settings = GetSettings();
	settings("intake_speed").SetDefault(intake_speed_);
	settings("push_speed").SetDefault(push_speed_);
	settings("max_velocity").SetDefault(max_velocity_);
	settings("allowed_error").SetDefault(allowed_error_);
	settings("shoot_velocity").SetDefault(shoot_velocity_);

	// PID Settings | TODO: Set proper default values
	auto& closed_loop_settings = settings["closed_loop_settings"];
	closed_loop_settings("use").SetDefault(false);
	closed_loop_settings("P").SetDefault(.1);
	closed_loop_settings("I").SetDefault(0.0);
	closed_loop_settings("D").SetDefault(0.0);
	closed_loop_settings("F").SetDefault(1.0);
	closed_loop_settings("I_Zone").SetDefault(2.5);
	closed_loop_settings("ramp_rate").SetDefault(10);

	// Inversion settings
	settings["intake_roller"]("invert_output").SetDefault(false);
	settings["intake_roller"]("invert_sensor").SetDefault(false);
}

bool Intake::doConfigure()
{
	std::cout << "Configuring Intake" << std::endl; // TODO: Change cout to Log

	// Initialize roller to CAN port
	auto& can_ports = GetPortSpace("CAN");
	if (roller_ == NULL)
		roller_ = new CANTalon(can_ports("intake_roller").GetValueOrDefault());

	// Configure variable values
	auto& settings = GetSettings();
	SetIntakeSpeed(settings("intake_speed").GetValueOrDefault());
	SetPushSpeed(settings("push_speed").GetValueOrDefault());
	SetMaxVelocity(settings("max_velocity").GetValueOrDefault());
	SetAllowedError(settings("allowed_error").GetValueOrDefault());
	SetShootVelocity(settings("shoot_velocity").GetValueOrDefault());

	// Configure closed loop settings
	auto& closed_loop_settings = settings["closed_loop_settings"];
	if (closed_loop_settings("use").GetValueOrDefault() == true)
	{
		roller_->SetP(closed_loop_settings("P").GetValueOrDefault());
		roller_->SetI(closed_loop_settings("I").GetValueOrDefault());
		roller_->SetD(closed_loop_settings("D").GetValueOrDefault());
		roller_->SetF(closed_loop_settings("F").GetValueOrDefault());
		roller_->SetIzone(closed_loop_settings("I_Zone").GetValueOrDefault());
		roller_->SetCloseLoopRampRate(closed_loop_settings("ramp_rate").GetValueOrDefault());
	}

	// Configure roller settings
	roller_->SetInverted(settings["intake_roller"]("invert_output").GetValueOrDefault());
	roller_->SetSensorDirection(settings["intake_roller"]("invert_sensor").GetValueOrDefault());

	return true;
}

// Main functions:
void Intake::Initialize()
{'fraction_non_alphanumeric': 0.15275918488769893, 'fraction_numerical': 0.006842183549010858, 'mean_word_length': 7.332094175960347, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, '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': '88233', 'n_tokens_mistral': 2254, 'n_tokens_neox': 2178, 'n_words': 344}