<commit_before>#pragma config(Motor,  motor3,          right,         tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor,  motor4,          left,          tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor,  motor10,         front,         tmotorVexIQ, PIDControl, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//


#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

#define getJoyDriveY() getJoystickValue(ChA)
#define getJoyDriveX() getJoystickValue(ChB)
#define getJoyDriveR() getJoystickValue(ChC)


task main()
{
	const float LeftWheelHeading = degreesToRadians(300);
	const float RightWheelHeading = degreesToRadians(60);
	const float FrontWheelHeading = degreesToRadians(180);

	const float MotorMax = 100.0;
	const float ControllerMax = 127.0;


	while(1){
		int driveY = getJoyDriveY();
		int driveX = getJoyDriveX();
		float driveHeading = atan2(driveY, driveX);
		float driveMagnitude = sqrt( driveX*driveX + driveY*driveY ) / ControllerMax;
		float driveRotation = -getJoyDriveR() / ControllerMax;

		float leftAngle = abs( driveHeading - LeftWheelHeading );
		float rightAngle = abs( driveHeading - RightWheelHeading );
		float frontAngle = abs( driveHeading - FrontWheelHeading );

		float leftSpeed = driveMagnitude * cos(leftAngle) + driveRotation;
		float rightSpeed = driveMagnitude * cos(rightAngle) + driveRotation;
		float frontSpeed = driveMagnitude * cos(frontAngle) + driveRotation;

		float maxSpeed = max(max(leftSpeed, rightSpeed), frontSpeed);
		float speedFactor = MotorMax;
		if( maxSpeed > 1.0 ){
			speedFactor /= maxSpeed;
		}

		setMotorSpeed( left, speedFactor * leftSpeed );
		setMotorSpeed( right, speedFactor * rightSpeed );
		setMotorSpeed( front, speedFactor * frontSpeed );
	}
}
<commit_msg>Generalized holonomic formula<commit_after>#pragma config(Motor,  motor3,          mpDriveA,      tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor,  motor4,          mpDriveC,      tmotorVexIQ, PIDControl, reversed, encoder)
#pragma config(Motor,  motor10,         mpDriveB,      tmotorVexIQ, PIDControl, reversed, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include <CKGeneralUtilities.h>
#include <CKVexControllers.h>


#define JoyChDriveX		JoyChLX
#define JoyChDriveY		JoyChLY
#define JoyChDriveR		JoyChRX


#define getJoyDriveY()	getJoystickValue(JoyChDriveY)
#define getJoyDriveX()	getJoystickValue(JoyChDriveX)
#define getJoyDriveR()	getJoystickValue(JoyChDriveR)


const float MotorMax = 100.0;
const float ControllerMax = 127.0;

const int NWheels = 3;
const float InitialWheelHeadingDeg = 60;
const int MotorPorts[NWheels] = { mpDriveA, mpDriveB, mpDriveC };


task main() {
	float headingIncrement = 360.0 / NWheels;
	float WheelHeadings[NWheels];
	for( int i = 0; i < NWheels; ++i ){
		float h = i * headingIncrement + InitialWheelHeadingDeg;
		WheelHeadings[i] = degreesToRadians(h);
	}

	float wheelSpeeds[NWheels];


	//drawLine(1, 1, 126, 43); // bounds of drawable area are [0,0] to [127, 44] from lower left.

	while(true){
		int driveY = getJoyDriveY();
		int driveX = getJoyDriveX();
		float driveHeading = atan2(driveY, driveX);
		float driveMagnitude = sqrt( driveX*driveX + driveY*driveY ) / ControllerMax;
		float driveRotation = -getJoyDriveR() / ControllerMax;

		for( int i = 0; i < NWheels; ++i ){
			float angleWithTarget = abs( driveHeading - WheelHeadings[i] );
			wheelSpeeds[i] = driveMagnitude * cos(angleWithTarget) + driveRotation;
		}

		float maxSpeed = maxOf(wheelSpeeds, NWheels);
		float speedFactor = MotorMax;
		if( maxSpeed > 1.0 ){
			speedFactor /= maxSpeed;
		}

		for( int i = 0; i < NWheels; ++i ){
			setMotorSpeed( MotorPorts[i], speedFactor * wheelSpeeds[i] );
		}
	}
}

{'fraction_non_alphanumeric': 0.11560542797494781, 'fraction_numerical': 0.016440501043841337, 'mean_word_length': 4.383426966292135, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3896782', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1288, 'n_words': 321}