OCCRA
Go to Post They knew that the number of gracious, professional, make-your-grandmother-so-proud-she-will-puke moments of exemplary behavior by the teams would far outshine any minor mistakes or incidents of less-than-perfect decorum. - dlavery [more]
Home
Go Back   Chief Delphi > CD-Media > White Papers
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

photos

papers

everything



Bronc Botz (3481): LUA script support for Wind River

JamesTerm

By: JamesTerm
New: 05-18-2012 09:37 AM
Updated: 05-18-2012 09:37 AM
Total downloads: 60 times


This archive contains the ability to read LUA script files and integrate into Wind River for properties to tweak for calibration.

These files allow you to use LUA script as your configuration file. I've included how we used it in the Admiral II... The LUA is wrapped with c++ classes for ease of use. (Yes the LUA is 11,000 lines of painful arduous labor of love).

Here is an example of how to use it:

Code:
		void ResetPos() 
		{	
			//TODO scope this within __DebugLUA__
			#ifdef  __DebugLUA__
			{
				Framework::Scripting::Script script;
				script.LoadScript("/FRC2012Robot.lua",true);
				script.NameMap["EXISTING_ENTITIES"] = "EXISTING_SHIPS";

				m_RobotProps.SetUpGlobalTable(script);
				m_RobotProps.LoadFromScript(script);
				m_pRobot->Initialize(m_EventMap,&m_RobotProps);
			}
			#endif
			m_pRobot->ResetPos();
			m_Control.ResetPos();
		}

Attached Files

  • zip LUA Script and with LUA examples

    Script.zip

    downloaddownload file

    uploaded: 05-18-2012 09:37 AM
    filetype: zip
    filesize: 88.52kb
    downloads: 58



Recent Downloaders

Discussion

view entire thread

Reply

05-18-2012 09:46 AM

JamesTerm


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

This allows the c++ code to be finished and delegate the task of calibration to other team members. LUA is a beautiful scripting language that is easy to pick up, and powerful enough to capture OOP concepts as well as write out your math constants (e.g. RPM Radians measurement conversions etc). It is also friendly to the OOP workflow in c++. For example I grouped out a whole section for low gear as it was able to reuse the same code used in high gear... we tweaked the properties of all the ramping times here. (No preset trapazoid ramping, its done with force restraint limits). LUA makes it easy to show one object against another to handle a task like this.

I hope at least one other team will use this code... as it was a lot of effort to make it work. I encourage everyone to consider it.



05-18-2012 10:04 AM

JamesTerm


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

I needed to add one more thing of how to use it... here is more example code:

Code:
  /***********************************************************************************************************************************/
 /*													FRC_2012_Robot_Properties														*/
/***********************************************************************************************************************************/

const double c_WheelDiameter=Inches2Meters(6);
const double c_MotorToWheelGearRatio=12.0/36.0;

FRC_2012_Robot_Properties::FRC_2012_Robot_Properties()  : m_TurretProps(
	"Turret",
	2.0,    //Mass
	0.0,   //Dimension  (this really does not matter for this, there is currently no functionality for this property, although it could impact limits)
	10.0,   //Max Speed
	1.0,1.0, //ACCEL, BRAKE  (These can be ignored)
	10.0,10.0, //Max Acceleration Forward/Reverse 
	Ship_1D_Properties::eSwivel,
	true,	//Using the range
	-Pi,Pi
	),
	m_PitchRampProps(
	"Pitch",
	2.0,    //Mass
	0.0,   //Dimension  (this really does not matter for this, there is currently no functionality for this property, although it could impact limits)
	10.0,   //Max Speed
	1.0,1.0, //ACCEL, BRAKE  (These can be ignored)
	10.0,10.0, //Max Acceleration Forward/Reverse 
	Ship_1D_Properties::eRobotArm,
	true,	//Using the range
	DEG_2_RAD(45-3),DEG_2_RAD(70+3) //add padding for quick response time (as close to limits will slow it down)
	),
	m_PowerWheelProps(
	"PowerWheels",
	2.0,    //Mass
	Inches2Meters(6),   //Dimension  (needed to convert linear to angular velocity)
	(5000.0/60.0) * Pi2,   //Max Speed (This is clocked at 5000 rpm) 
	60.0,60.0, //ACCEL, BRAKE  (These work with the buttons, give max acceleration)
	60.0,60.0, //Max Acceleration Forward/Reverse  these can be real fast about a quarter of a second
	Ship_1D_Properties::eSimpleMotor,
	false,28.0 * Pi2,0.0,	//No limit ever!  (but we are using the min range as a way to set minimum speed)
	true //This is angular
	),
	m_ConveyorProps(
	"Conveyor",
	2.0,    //Mass
	0.0,   //Dimension  (this really does not matter for this, there is currently no functionality for this property, although it could impact limits)
	//RS-550 motor with 64:1 BaneBots transmission, so this is spec at 19300 rpm free, and 17250 peak efficiency
	//17250 / 64 = 287.5 = rps of motor / 64 reduction = 4.492 rps * 2pi = 28.22524
	28,   //Max Speed (rounded as we need not have precision)
	112.0,112.0, //ACCEL, BRAKE  (These work with the buttons, give max acceleration)
	112.0,112.0, //Max Acceleration Forward/Reverse  these can be real fast about a quarter of a second
	Ship_1D_Properties::eSimpleMotor,
	false,0.0,0.0,	//No limit ever!
	true //This is angular
	),
	m_FlipperProps(
	"Flippers",
	2.0,    //Mass
	Inches2Meters(12),   //Dimension  (this should be correct)
	1.4 * Pi2,   //Max Speed  (Parker gave this one, should be good)
	10.0,10.0, //ACCEL, BRAKE  (should be relatively quick)
	10.0,10.0, //Max Acceleration Forward/Reverse 
	Ship_1D_Properties::eRobotArm,
	true,	//Using the range
	-PI_2,PI_2 //TODO
	)
{
	{
		FRC_2012_Robot_Props props;
		const double KeyDistance=Inches2Meters(144);
		const double KeyWidth=Inches2Meters(101);
		//const double KeyDepth=Inches2Meters(48);   //not used (yet)
		const double DefaultY=c_HalfCourtLength-KeyDistance;
		const double HalfKeyWidth=KeyWidth/2.0;
		props.PresetPositions[0]=Vec2D(0.0,DefaultY);
		props.PresetPositions[1]=Vec2D(-HalfKeyWidth,DefaultY);
		props.PresetPositions[2]=Vec2D(HalfKeyWidth,DefaultY);
		props.FireTriggerDelay=0.100;  //e.g. 10 iterations of good tolerance
		props.FireButtonStayOn_Time=0.100; //100 ms
		props.Coordinates_DiplayRow=(size_t)-1;
		props.TargetVars_DisplayRow=(size_t)-1;
		props.PowerVelocity_DisplayRow=(size_t)-1;

		for (size_t row=0;row<3;row++)
		{
			for (size_t column=0;column<3;column++)
			{
				Vec2D &cell=props.KeyGrid[row][column];
				const double spread=Feet2Meters(7.0);
				const double x=spread * ((double)column-1.0);
				const double y=(spread * ((double)row-1.0)) + DefaultY;
				cell=Vec2D(x,y);
				props.KeyCorrections[row][column].PowerCorrection=1.0;
				props.KeyCorrections[row][column].YawCorrection=1.0;
			}
		}

		FRC_2012_Robot_Props::Autonomous_Properties &auton=props.Autonomous_Props;
		auton.MoveForward=0.0;
		auton.TwoShotScaler=1.0;
		auton.RampLeft_ErrorCorrection_Offset=
		auton.RampRight_ErrorCorrection_Offset=
		auton.RampCenter_ErrorCorrection_Offset=Vec2D(0.0,0.0);
		auton.XLeftArc=auton.XRightArc=1.9;
		FRC_2012_Robot_Props::Autonomous_Properties::WaitForBall_Info &ball_1=auton.FirstBall_Wait;
		ball_1.InitialWait=4.0;
		ball_1.TimeOutWait=-1.0;
		ball_1.ToleranceThreshold=0.0;
		FRC_2012_Robot_Props::Autonomous_Properties::WaitForBall_Info &ball_2=auton.SecondBall_Wait;
		ball_2.InitialWait=4.0;
		ball_2.TimeOutWait=-1.0;
		ball_2.ToleranceThreshold=0.0;
		m_FRC2012RobotProps=props;
	}
	{
		Tank_Robot_Props props=m_TankRobotProps; //start with super class settings

		//Late assign this to override the initial default
		//Was originally 0.4953 19.5 width for 2011
		//Now is 0.517652 20.38 according to Parker  (not too worried about the length)
		props.WheelDimensions=Vec2D(0.517652,0.6985); //27.5 x 20.38
		props.WheelDiameter=c_WheelDiameter;
		props.LeftPID[1]=props.RightPID[1]=1.0; //set the I's to one... so it should be 1,1,0
		props.MotorToWheelGearRatio=c_MotorToWheelGearRatio;
		m_TankRobotProps=props;
	}
	{
		Rotary_Props props=m_TurretProps.RoteryProps(); //start with super class settings
		props.PID[0]=1.0;
		props.PrecisionTolerance=0.001; //we need high precision
		m_TurretProps.RoteryProps()=props;
	}
	{
		Rotary_Props props=m_PitchRampProps.RoteryProps(); //start with super class settings
		props.PID[0]=1.0;
		props.PrecisionTolerance=0.001; //we need high precision
		m_PitchRampProps.RoteryProps()=props;
	}
	{
		Rotary_Props props=m_PowerWheelProps.RoteryProps(); //start with super class settings
		props.PID[0]=1.0;
		props.PrecisionTolerance=0.1; //we need decent precision (this will depend on ramp up time too)
		m_PowerWheelProps.RoteryProps()=props;
	}
}

const char *ProcessVec2D(FRC_2012_Robot_Props &m_FRC2012RobotProps,Scripting::Script& script,Vec2d &Dest)
{
	const char *err;
	typedef FRC_2012_Robot_Properties::Vec2D Vec2D;
	double length, width;	
	//If someone is going through the trouble of providing the dimension field I should expect them to provide all the fields!
	err = script.GetField("y", NULL, NULL,&length);
	if (err)
	{
		err = script.GetField("y_ft", NULL, NULL,&length);
		if (!err)
			length=Feet2Meters(length);
		else
		{
			err = script.GetField("y_in", NULL, NULL,&length);
			if (!err)
				length=Inches2Meters(length);
		}

	}
	ASSERT_MSG(!err, err);
	err = script.GetField("x", NULL, NULL,&width);
	if (err)
	{
		err = script.GetField("x_ft", NULL, NULL,&width);
		if (!err)
			width=Feet2Meters(width);
		else
		{
			err = script.GetField("x_in", NULL, NULL,&width);
			if (!err)
				width=Inches2Meters(width);
		}
	}
	ASSERT_MSG(!err, err);
	Dest=Vec2D(width,length);  //x,y  where x=width
	script.Pop();
	return err;
}

const char *ProcessKey(FRC_2012_Robot_Props &m_FRC2012RobotProps,Scripting::Script& script,size_t index)
{
	const char *err;
	typedef FRC_2012_Robot_Properties::Vec2D Vec2D;
	Vec2D PresetPosition;
	err=ProcessVec2D(m_FRC2012RobotProps,script,PresetPosition);
	ASSERT_MSG(!err, err);
	PresetPosition[1]=c_HalfCourtLength-PresetPosition[1];
	m_FRC2012RobotProps.PresetPositions[index]=PresetPosition;  //x,y  where x=width
	return err;
}

const char *ProcessKeyCorrection(FRC_2012_Robot_Props &m_FRC2012RobotProps,Scripting::Script& script,size_t row,size_t column)
{
	const char* err=NULL;
	char CellName[4];
	CellName[0]='c';
	CellName[1]='1'+row;
	CellName[2]='1'+column;
	CellName[3]=0;
	err = script.GetFieldTable(CellName);

	err = script.GetField("p", NULL, NULL,&m_FRC2012RobotProps.KeyCorrections[row][column].PowerCorrection);
	err = script.GetField("x", NULL, NULL,&m_FRC2012RobotProps.KeyCorrections[row][column].YawCorrection);

	script.Pop();
	return err;
}

void FRC_2012_Robot_Properties::LoadFromScript(Scripting::Script& script)
{
	const char* err=NULL;
	__super::LoadFromScript(script);
	err = script.GetFieldTable("robot_settings");
	if (!err) 
	{
		err = script.GetFieldTable("turret");
		if (!err)
		{
			m_TurretProps.LoadFromScript(script);
			script.Pop();
		}
		err = script.GetFieldTable("pitch");
		if (!err)
		{
			m_PitchRampProps.LoadFromScript(script);
			script.Pop();
		}
		err = script.GetFieldTable("power");
		if (!err)
		{
			m_PowerWheelProps.LoadFromScript(script);
			script.Pop();
		}
		err = script.GetFieldTable("conveyor");
		if (!err)
		{
			m_ConveyorProps.LoadFromScript(script);
			script.Pop();
		}
		err = script.GetFieldTable("flippers");
		if (!err)
		{
			m_FlipperProps.LoadFromScript(script);
			script.Pop();
		}

		m_LowGearProps=*this;  //copy redundant data first
		err = script.GetFieldTable("low_gear");
		if (!err)
		{
			m_LowGearProps.LoadFromScript(script);
			script.Pop();
		}

		
		err = script.GetFieldTable("key_1");
		if (!err) ProcessKey(m_FRC2012RobotProps,script,0);

		err = script.GetFieldTable("key_2");
		if (!err) ProcessKey(m_FRC2012RobotProps,script,1);

		err = script.GetFieldTable("key_3");
		if (!err) ProcessKey(m_FRC2012RobotProps,script,2);

		double fDisplayRow;
		err=script.GetField("ds_display_row", NULL, NULL, &fDisplayRow);
		if (!err)
			m_FRC2012RobotProps.Coordinates_DiplayRow=(size_t)fDisplayRow;
		err=script.GetField("ds_target_vars_row", NULL, NULL, &fDisplayRow);
		if (!err)
			m_FRC2012RobotProps.TargetVars_DisplayRow=(size_t)fDisplayRow;

		err=script.GetField("ds_power_velocity_row", NULL, NULL, &fDisplayRow);
		if (!err)
			m_FRC2012RobotProps.PowerVelocity_DisplayRow=(size_t)fDisplayRow;

		script.GetField("fire_trigger_delay", NULL, NULL, &m_FRC2012RobotProps.FireTriggerDelay);
		script.GetField("fire_stay_on_time", NULL, NULL, &m_FRC2012RobotProps.FireButtonStayOn_Time);

		err = script.GetFieldTable("grid_corrections");
		if (!err)
		{
			for (size_t row=0;row<3;row++)
			{
				for (size_t column=0;column<3;column++)
				{
					err=ProcessKeyCorrection(m_FRC2012RobotProps,script,row,column);
					assert(!err);
				}
			}
			script.Pop();
		}
		err = script.GetFieldTable("auton");
		if (!err)
		{
			struct FRC_2012_Robot_Props::Autonomous_Properties &auton=m_FRC2012RobotProps.Autonomous_Props;
			{
				double length;
				err = script.GetField("move_forward_ft", NULL, NULL,&length);
				if (!err)
					auton.MoveForward=Feet2Meters(length);
			}
			err = script.GetField("two_shot_scaler", NULL, NULL,&auton.TwoShotScaler);

			err = script.GetFieldTable("ramp_left");
			if (!err)
			{
				Vec2D OffsetPosition;
				err=ProcessVec2D(m_FRC2012RobotProps,script,OffsetPosition);
				ASSERT_MSG(!err, err);
				auton.RampLeft_ErrorCorrection_Offset=OffsetPosition;
			}
			err = script.GetFieldTable("ramp_right");
			if (!err)
			{
				Vec2D OffsetPosition;
				err=ProcessVec2D(m_FRC2012RobotProps,script,OffsetPosition);
				ASSERT_MSG(!err, err);
				auton.RampRight_ErrorCorrection_Offset=OffsetPosition;
			}
			err = script.GetFieldTable("ramp_center");
			if (!err)
			{
				Vec2D OffsetPosition;
				err=ProcessVec2D(m_FRC2012RobotProps,script,OffsetPosition);
				ASSERT_MSG(!err, err);
				auton.RampCenter_ErrorCorrection_Offset=OffsetPosition;
			}
			{
				const char * const fieldTable[]=
				{
					"ball_1","ball_2"
				};
				//You just gotta love pointers to do this!  ;)
				FRC_2012_Robot_Props::Autonomous_Properties::WaitForBall_Info *ballTable[]=
				{
					&auton.FirstBall_Wait,&auton.SecondBall_Wait
				};
				for (size_t i=0;i<2;i++)
				{
					err = script.GetFieldTable(fieldTable[i]);
					if (!err)
					{
						FRC_2012_Robot_Props::Autonomous_Properties::WaitForBall_Info &ball=*ballTable[i];
						err=script.GetField("initial_wait", NULL, NULL, &ball.InitialWait);
						ASSERT_MSG(!err, err);
						err=script.GetField("timeout_wait", NULL, NULL, &ball.TimeOutWait);
						ASSERT_MSG(!err, err);
						err=script.GetField("tolerance", NULL, NULL, &ball.ToleranceThreshold);
						ASSERT_MSG(!err, err);
						script.Pop();
					}
				}
			}

			script.GetField("x_left_arc", NULL, NULL, &auton.XLeftArc);
			script.GetField("x_right_arc", NULL, NULL, &auton.XRightArc);
			script.Pop();
		}
		err = script.GetFieldTable("controls");
		if (!err)
		{
			const char * const Events[] = 
			{
				"Joystick_SetCurrentSpeed_2","Analog_Turn",
				"Turret_SetCurrentVelocity","Turret_SetIntendedPosition","Turret_SetPotentiometerSafety",
				"PitchRamp_SetCurrentVelocity","PitchRamp_SetIntendedPosition","PitchRamp_SetPotentiometerSafety",
				"PowerWheels_SetCurrentVelocity","PowerWheels_SetEncoderSafety","PowerWheels_IsRunning",
				"Ball_SetCurrentVelocity","Ball_Fire","Ball_Squirt","Ball_Grip","Ball_GripL","Ball_GripM","Ball_GripH",
				"Flippers_SetCurrentVelocity","Flippers_SetIntendedPosition","Flippers_SetPotentiometerSafety",
				"Flippers_Advance","Flippers_Retract",
				"Robot_IsTargeting","Robot_SetTargetingOn","Robot_SetTargetingOff","Robot_TurretSetTargetingOff","Robot_SetTargetingValue",
				"Robot_SetLowGear","Robot_SetLowGearOn","Robot_SetLowGearOff","Robot_SetLowGearValue",
				"Robot_SetPreset1","Robot_SetPreset2","Robot_SetPreset3","Robot_SetPresetPOV",
				"Robot_SetDefensiveKeyValue","Robot_SetDefensiveKeyOn","Robot_SetDefensiveKeyOff",
				"Robot_SetCreepMode","Robot_Flippers_Solenoid"
				//AI Tester events only
				#if 1
					,"Ball_SlowWheel"
				#endif
			};

			//TODO we may use actual product names here, but this will be fine for wind river build
			const char * const Controls[] =
			{
				"Joystick_1","Joystick_2","Joystick_3"
			};

			for (size_t i=0;i<_countof(Controls);i++)
			{
				err = script.GetFieldTable(Controls[i]);
				if (!err)
				{
					Control_Props control;
					//Wind River uses generic name, and AI tester uses product name
					//control.Controller=Controls[i];
					err=script.GetField("control", &control.Controller, NULL, NULL);

					for (size_t j=0;j<_countof(Events);j++)
					{
						UI_Controller::Controller_Element_Properties element;
						err=UI_Controller::ExtractControllerElementProperties(element,Events[j],script);
						if (!err)
							control.EventList.push_back(element);
					}
					m_RobotControls.push_back(control);
					script.Pop();
				}
			}
		}
		script.Pop();
	}
}



05-18-2012 02:33 PM

rsisk


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

I believe 973 used LUA this year



05-18-2012 04:05 PM

R.C.


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Quote:
Originally Posted by rsisk View Post
I believe 973 used LUA this year
Yep and last year!

-RC



05-18-2012 05:01 PM

connor.worley


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Out of curiosity, why did you choose to merge Lua into a single file? The default layout will work without modification.



05-19-2012 07:04 AM

JamesTerm


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Quote:
Originally Posted by connor.worley View Post
Out of curiosity, why did you choose to merge Lua into a single file? The default layout will work without modification.
In short to decrease compile time. We have 54 files (half .h half .cpp) and lua in its original form is 55 files with 23 headers. I have no need to populate the symbol table with any of those headers, and my original goal was to completely eliminate all the symbols from being exported. I was able to take out many of them, but decided to compromise exporting some, so that I wouldn't need to change any functionality. This took a good solid week to achieve. The only symbols I use are written in script.h.

If I left it as it was, EVERY .cpp file would have to access each of the 23 header files, and each file is an I/O operation that costs time. Now then... if anyone knows how to make WindRiver work with precomiled headers, that would change everything, but I've given up trying to figure out if it is even possible. I could then change how I do my includes technique as well.




Oh while I'm here I wanted to post our LUA use case, so that others can see how it works easily. (We use Notepad++ to edit changes on the field):

Here is the LUA configuration used to run on the Admiral II
Code:
Pi=3.14159265358979323846
Pi2=Pi*2
Inches2Meters=0.0254
Feet2Meters=0.3048
Meters2Feet=3.2808399
Meters2Inches=39.3700787

FRC2012_wheel_diameter_in=6   --This will determine the correct distance try to make accurate too
--Parker claimed 20.38, but I've measured 22 5/16
WheelBase_Width_In=22.3125	  --The wheel base will determine the turn rate, must be as accurate as possible!
HighGearSpeed = (427.68 / 60.0) * Pi * FRC2012_wheel_diameter_in * Inches2Meters  --RPM's from Parker
LowGearSpeed  = (167.06 / 60.0) * Pi * FRC2012_wheel_diameter_in * Inches2Meters

KeyDistance_in=144;
KeyWidth_in=101;
KeyDepth_in=48;
HalfKeyWidth_in=KeyWidth_in/2.0;

MainRobot = {
	Mass = 25, -- Weight kg
	MaxAccelLeft = 4, MaxAccelRight = 4, MaxAccelForward = 4, MaxAccelReverse = 4, 
	MaxTorqueYaw = 25, 
	
	MAX_SPEED = HighGearSpeed,
	ACCEL = 10,    -- Thruster Acceleration m/s2 (1g = 9.8)
	BRAKE = ACCEL,
	-- Turn Rates (radians/sec) This is always correct do not change
	heading_rad = (HighGearSpeed / (Pi * WheelBase_Width_In * Inches2Meters)) * Pi2,
	
	Dimensions =
	{ Length=0.9525, Width=0.6477 }, --These are 37.5 x 25.5 inches (This is not used except for UI ignore)
	
	tank_drive =
	{
		is_closed=0,						--This should always be false for high gear
		show_pid_dump='no',
		ds_display_row=-1,
		wheel_base_dimensions =
		{length_in=27.5, width_in=WheelBase_Width_In},	--The length is not used but here for completion
		
		--This encoders/PID will only be used in autonomous if we decide to go steal balls
		wheel_diameter_in = FRC2012_wheel_diameter_in,
		left_pid=
		{p=0, i=0, d=0},					--In FRC 2011 pid was 1,1,0 but lets keep i to zero if we can
		right_pid=
		{p=0, i=0, d=0},					--These should always match, but able to be made different
		
		--This is obtainer from encoder RPM's of 1069.2 and Wheel RPM's 427.68 (both high and low have same ratio)
		encoder_to_wheel_ratio=0.4,			--example if encoder spins at 1069.2 multiply by this to get 427.68 (for the wheel rpm)
		voltage_multiply=1.0,				--May be reversed using -1.0
		reverse_steering='no'
	},
	
	robot_settings =
	{
		key_1 = { x_in=0				, y_in=KeyDistance_in },
		key_2 = { x_in=-HalfKeyWidth_in	, y_in=KeyDistance_in },
		key_3 = { x_in= HalfKeyWidth_in	, y_in=KeyDistance_in },
		ds_display_row=1,					--This will display the coordinates and heading (may want to leave on)
		ds_target_vars_row=-1,				--Only used during keying the grid
		ds_power_velocity_row=3,			--Only used during keying the grid
		--Currently full power gives around 230ish... so 13 iterations at 200 should be duable (was at .130)
		fire_trigger_delay=0.150,			--Used to wait for a stable rate before engaging the conveyor
		fire_stay_on_time=0.500,			--Used to prevent ball from get stuck during a fire operation (keep small)
		
		grid_corrections =
		{
			c11={p=1.7, x=1.0}, c12={p=1.7, x=1.0}, c13={p=1.7, x=1.0},
			c21={p=1.9, x=1.0}, c22={p=1.8, x=1.0}, c23={p=1.9, x=1.0},
			c31={p=1.7, x=1.0}, c32={p=1.7, x=1.0}, c33={p=1.7, x=1.0},
		},
		
		auton =
		{
			move_forward_ft =0.0,
			two_shot_scaler =1.45,
			ramp_left  ={x_in=0, y_in=0 },
			ramp_right ={x_in=0, y_in=0 },
			ramp_center={x_in=0, y_in=0 },
			x_left_arc=1.9,
			x_right_arc=1.9,
			--If you put -1.0 for the timeout wait it will wait infinitely (good for initial testing or if we are not tipping ramps)
			--ball 1 initial wait should be long enough for a good ramp up from zero speed
			--ball_1 ={initial_wait=  2.0, tolerance=75.0, timeout_wait=4.0},
			--ball 2 initial wait should be long enough to recover from dip and short enough to be active during second ball's deployment
			--ball_2 ={initial_wait=0.500, tolerance=75.0, timeout_wait=4.0}
			--panic mode incase the wait ball doesn't work... using zero makes it work like before just pure time
			ball_1 ={initial_wait=  3.5, tolerance=0.0, timeout_wait=-1.0},
			ball_2 ={initial_wait=  3.5, tolerance=0.0, timeout_wait=-1.0}
		},
		
		turret =
		{
			is_closed='yes',				--It is closed loop when feedback has been properly calibrated
			show_pid_dump='no',				--Only turn on if you want to analyze the PID dump (only one at a time, and it must be closed loop)
			ds_display_row=0,				--Assign to a row (e.g. 0-4) when trying to calibrate the potentiometer
			pid=
			{p=25, i=3, d=2},
			tolerance=0.001,				--we need high precision
			encoder_to_wheel_ratio=1.064,     --Just use the gearing ratios here			
			voltage_multiply=1.0,			--May be reversed using -1.0
			max_speed=10,
			accel=10.0,						--These are only needed if we bind keys for turret
			brake=10.0,
			max_accel_forward=20,			--These are in radians, plan on increasing these as much as possible
			max_accel_reverse=20,
			using_range=0,
			min_range_deg=-180,				--These are probably good to go, but may need to be smaller
			max_range_deg= 180
		},
		pitch =
		{
			is_closed='yes',
			show_pid_dump='no',
			ds_display_row=-1,
			pid=
			{p=1, i=0, d=0},
			tolerance=0.001,				--we need high precision

			max_speed=10,
			max_accel_forward=10,			--These are in radians, plan on increasing these as much as possible
			max_accel_reverse=10,
			min_range_deg=45-3,				--These should be good to go
			max_range_deg=70+3
		},
		power =
		{
			is_closed='y',
			show_pid_dump='n',
			ds_display_row=4,				--Use this display to determine max speed (try to get a good match)
			pid=
			--{p=0, i=0, d=0},
			--{p=0.1, i=0.5, d=0},
			--{p=400.0, i=5.0, d=200.0},
			--{p=400.0, i=75.0, d=200.0},
			--{p=250.0, i=10.0, d=250.0},
			--{p=250.0, i=0.0, d=250.0},   --fall back
			{p=700.0, i=0.0, d=400.0},
			tolerance=17.0,					--we need decent precision (this will depend on ramp up time too)
			encoder_to_wheel_ratio=0.85,     --Just use the gearing ratios here
			voltage_multiply=1,
			square_voltage='no',

			length_in=6,					--6 inch diameter (we shouldn't worry about tweaking this just measure it and be done)
			max_speed=(5000.0/60.0) * Pi2,	--(This is clocked at 5000 rpm) in radians
			accel=200.0,						--These are only needed if we bind keys for power in meters per second
			brake=200.0,
			max_accel_forward=200,			--These are in radians, plan on increasing these as much as possible
			max_accel_reverse=200,			--The wheel may some time to ramp up
			min_range=23 * Pi2				--We borrow the min range to represent the min speed (was 17 as of 3:20 PM 4/21, changed for calibrations)
		},
		flippers =
		{
			is_closed=0,				--Not sure yet about this
			show_pid_dump='no',
			ds_display_row=-1,
			pid=
			{p=1, i=0, d=0},
			tolerance=0.01,					--should not matter much
			
			max_speed=1.4 * Pi2,			--(Parker gave this one, should be good)
			accel=10.0,						--We may indeed have a two button solution (match with max accel)
			brake=10.0,
			max_accel_forward=10,			--These are in radians, just go with what feels right
			max_accel_reverse=10,
			using_range=0,					--Warning Only use range if we have a potentiometer!
			min_range_deg=-90,				--TODO find out what these are
			max_range_deg= 90
		},
		conveyor =
		{
			--Note: there are no encoders here so is_closed is ignored
			tolerance=0.01,					--we need good precision
			voltage_multiply=-1.0,			--May be reversed
			
			max_speed=28,
			accel=112,						--These are needed and should be high enough to grip without slip
			brake=112,
			max_accel_forward=112,
			max_accel_reverse=112
		},
		low_gear = 
		{
			--While it is true we have more torque for low gear, we have to be careful that we do not make this too powerful as it could
			--cause slipping if driver "high sticks" to start or stop quickly.
			MaxAccelLeft = 10, MaxAccelRight = 10, MaxAccelForward = 10 * 2, MaxAccelReverse = 10 * 2, 
			MaxTorqueYaw = 25 * 2, 
			
			MAX_SPEED = LowGearSpeed,
			ACCEL = 10*2,    -- Thruster Acceleration m/s2 (1g = 9.8)
			BRAKE = ACCEL, 
			-- Turn Rates (deg/sec) This is always correct do not change
			heading_rad = (LowGearSpeed / (Pi * WheelBase_Width_In * Inches2Meters)) * Pi2,
			
			tank_drive =
			{
				is_closed=0,						--By default false, and can be turned on dynamically
				show_pid_dump='n',
				ds_display_row=-1,
				--We must NOT use I or D for low gear, we must keep it very responsive
				--We are always going to use the encoders in low gear to help assist to fight quickly changing gravity shifts
				left_pid=
				{p=130, i=0, d=180},
				right_pid=
				{p=130, i=0, d=180},					--These should always match, but able to be made different
				
				--I'm explicitly keeping this here to show that we have the same ratio (it is conceivable that this would not always be true)
				--This is obtainer from encoder RPM's of 1069.2 and Wheel RPM's 427.68 (both high and low have same ratio)
				encoder_to_wheel_ratio=0.4,			--example if encoder spins at 1069.2 multiply by this to get 427.68 (for the wheel rpm)
				voltage_multiply=1.0,				--May be reversed using -1.0
				reverse_steering='no'
			}
		},
		controls =
		{
			Joystick_1 =
			{
				control = "CH FLIGHTSTICK PRO",
				Analog_Turn = {type="joystick_analog", key=0, is_flipped=false, multiplier=1.0, filter=0.00, is_squared=false},
				Joystick_SetCurrentSpeed_2 = {type="joystick_analog", key=1, is_flipped=true, multiplier=1.0, filter=0.00, is_squared=false},
				Robot_SetLowGearValue = {type="joystick_analog", key=2, is_flipped=true, multiplier=1.0, filter=0.0, is_squared=false},
				Robot_Flippers_Solenoid = {type="joystick_button", key=3, on_off=true},
				Robot_SetCreepMode = {type="joystick_button", key=1, on_off=true}
			},

			Joystick_2 =
			{
				control = "Logitech Dual Action",
				--scaled down to 0.5 to allow fine tuning and a good top acceleration speed (may change with the lua script tweaks)
				Turret_SetCurrentVelocity = {type="joystick_analog", key=0, is_flipped=false, multiplier=0.5, filter=0.05, is_squared=false},
				--Ball_Grip = {type="joystick_button", key=2, on_off=true},
				Ball_Squirt = {type="joystick_button", key=1, on_off=true},
				--Ball_Fire = {type="joystick_button", key=4, on_off=true},
				--PowerWheels_IsRunning = {type="joystick_button", key=3, on_off=true},
				Robot_TurretSetTargetingOff = {type="joystick_button", key=6, on_off=true},
				Robot_SetPreset1 = {type="joystick_button", key=5, on_off=false},
				Robot_SetPreset2 = {type="joystick_button", key=9, on_off=false},
				Robot_SetPreset3 = {type="joystick_button", key=10, on_off=false},
				
				--Until we have the ball sensors working we'll need to re-assign the aim and fire buttons below to use all three button for the grip
				Ball_Fire = {type="joystick_button", key=8, on_off=true},
				PowerWheels_IsRunning = {type="joystick_button", key=7, on_off=true},
				Ball_GripL = {type="joystick_button", key=2, on_off=true},
				Ball_GripM = {type="joystick_button", key=3, on_off=true},
				Ball_GripH = {type="joystick_button", key=4, on_off=true}
			},

			Joystick_3 =
			{	
				control = "CH THROTTLE QUADRANT",
				PitchRamp_SetIntendedPosition = {type="joystick_analog", key=0, is_flipped=true, multiplier=1.142000, filter=0.0, is_squared=false},
				Robot_SetTargetingValue = {type="joystick_analog", key=0, is_flipped=true, multiplier=1.142000, filter=0.0, is_squared=false},
				PowerWheels_SetCurrentVelocity = {type="joystick_analog", key=1, is_flipped=true, multiplier=1.0000, filter=0.0, is_squared=false},
				--This top one is only for open loop mode, and works like the game pad
				--Turret_SetIntendedPosition = {type="joystick_analog", key=2, is_flipped=true, multiplier=0.5, filter=0.1, is_squared=true},
				--Turret_SetIntendedPosition = {type="joystick_analog", key=2, is_flipped=true, multiplier=1.0, filter=0.1, is_squared=false},
				Robot_SetDefensiveKeyValue = {type="joystick_analog", key=5, is_flipped=true, multiplier=1.0, filter=0.0, is_squared=false},
				
				--Ball_Grip = {type="joystick_button", key=2, on_off=true},
				Ball_Squirt = {type="joystick_button", key=1, on_off=true},
				--Ball_Fire = {type="joystick_button", key=6, on_off=true},
				--PowerWheels_IsRunning = {type="joystick_button", key=4, on_off=true},
				Robot_SetDefensiveKeyOn = {type="joystick_button", key=11, on_off=false},
				Robot_SetDefensiveKeyOff = {type="joystick_button", key=12, on_off=false},
				
				Ball_GripL = {type="joystick_button", key=2, on_off=true},
				Ball_GripM = {type="joystick_button", key=4, on_off=true},
				Ball_GripH = {type="joystick_button", key=6, on_off=true},
				PowerWheels_IsRunning = {type="joystick_button", key=8, on_off=true},
				Ball_Fire = {type="joystick_button", key=10, on_off=true}
			}
		}
	},
	--This is only used in the AI tester, can be ignored
	UI =
	{
		Length=5, Width=5,
		TextImage="(   )n|   |n(   )n|   |n(   )"
	}
}

Robot2012 = MainRobot



05-19-2012 11:14 AM

AdamHeard


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

We get around the compile time by compiling only oncer per season. Zero times this season actually.



05-19-2012 11:43 AM

Michael Blake


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Quote:
Originally Posted by AdamHeard View Post
We get around the compile time by compiling only oncer per season. Zero times this season actually.
Adam, I'm not understanding this post... you run interpreted code, not compiled? THANKS!


P.S. NOT my area of expertise, but it kills me to not at least have a "helicopter-view" understanding of ALL things FRC... ;-)



05-19-2012 01:28 PM

JamesTerm


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Quote:
Originally Posted by AdamHeard View Post
We get around the compile time by compiling only oncer per season. Zero times this season actually.
"by compiling once"... does that mean the LUA code exclusively? Please share us your workflow as we would be eternally grateful. Thanks.

I'd like to see how you guys are using LUA... it seems like we are the only two teams that are using it.



05-19-2012 01:39 PM

Joe Ross


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Two threads for your reading pleasure:

http://www.chiefdelphi.com/forums/sh...ad.php?t=87185
http://www.chiefdelphi.com/forums/sh...ad.php?t=88373



05-19-2012 02:17 PM

JamesTerm


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Quote:
Originally Posted by Joe Ross View Post

Thanks Joe... these threads answer all the questions, and is amazing that 973 took lua to the next level as the language to use. It is interesting how we are using the same tool so differently, as we use LUA as a configuration file and c++ as our primary (and only) language.



05-19-2012 03:33 PM

Michael Blake


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Quote:
Originally Posted by Joe Ross View Post
Ahhh... NOW I get it... THANKS Joe for pointing us to this great info... MUCH APPRECIATED!!



05-20-2012 04:10 AM

JamesTerm


Unread Re: paper: Bronc Botz (3481): LUA script support for Wind River

Ok now that we have figured out the solution 973 offers... I am pleased to say what we offer still has merit as I want to throw some terms out there:

Team 973- Offers LUA as a Programming Language solution
Team 3481- Offers LUA as a Data Format solution for c++

This means teams like 254 who use configuration files may find this useful, as we present LUA as virtually a "one file" solution that is easy and friendly to the c++ workflow.



view entire thread

Reply

Tags

loading ...



All times are GMT -5. The time now is 05:29 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi