senseigia / hero_testexamples Goto Github PK
View Code? Open in Web Editor NEWExamples used when testing Phoenix
Examples used when testing Phoenix
/* Update motion profile status after every loop */
Hardware._rightTalon.GetMotionProfileStatus(_motionProfileStatus);
/* May have to move this out one level */
Hardware._rightTalon.ProcessMotionProfileBuffer();
Currently, we always pass in 0 for PIDid, need to check other functions....
Learn from playing with this one.
Issue
When using ConfigSetParameter/ConfigOpenloopRamp to configure the ramp rate, it appears that we always return an integer. When using ConfigSetParameter with the value of 2.25, we get the value of 2; when using ConfigOpenloopRamp with the value of 2.25, we get the value of 4. Both configSetParameter and ConfigOpenloopRamp scale the value to int losing the float precesion, do we care about this?
Test Code
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using CTRE.Phoenix.MotorControl.CAN;
using CTRE.Phoenix.MotorControl;
using CTRE.Phoenix.Controller;
using CTRE.Gadgeteer.Module;
using CTRE.Phoenix;
/* Jacob's test upadated to Phoenix Framwork */
namespace GeneralPCMTest
{
public class Program
{
/* Hardware */
static TalonSRX _talon = new TalonSRX(0);
static GameController _gamepad = new GameController(UsbHostDevice.GetInstance());
/* All buttons */
static bool[] _currentBtns = new bool[13];
static bool[] _previousBtns = new bool[13];
public static void Main()
{
/* Enable the status frame used to test configFactorDefault */
_talon.SetStatusFramePeriod(StatusFrameEnhanced.Status_7_CommStatus, 10, 10);
while (true)
{
/* Always enable actuators during this test */
CTRE.Phoenix.Watchdog.Feed();
/* Just get all buttons */
_gamepad.GetButtons(_currentBtns);
CTRE.ErrorCode _error;
bool errorState = false;
if(_currentBtns[2] && !_previousBtns[2]){
Debug.Print("Peforming random sets...");
/* Do a bunch of sets */
_error = _talon.ConfigSetParameter(CTRE.Phoenix.LowLevel.ParamEnum.eContinuousCurrentLimitAmps, 10, 0, 0, 10);
if (_error != 0)
errorState = true;
//Thread.Sleep(1000);
_error = _talon.ConfigSetParameter(CTRE.Phoenix.LowLevel.ParamEnum.ePeakCurrentLimitAmps, 17, 0, 0, 10);
if (_error != 0)
errorState = true;
//Thread.Sleep(1000);
_error = _talon.ConfigOpenloopRamp(0.25f, 10);
//_error = _talon.ConfigSetParameter(CTRE.Phoenix.LowLevel.ParamEnum.eOpenloopRamp, 2.25f, 0, 0, 10);
if (_error != 0)
errorState = true;
//Thread.Sleep(1000);
_error = _talon.ConfigSetParameter(CTRE.Phoenix.LowLevel.ParamEnum.ePeakCurrentLimitMs, 100, 0, 0, 10);
if (_error != 0)
errorState = true;
//Thread.Sleep(1000);
_error = _talon.ConfigSetParameter(CTRE.Phoenix.LowLevel.ParamEnum.eMotMag_VelCruise, 1000, 0, 0, 10);
if (_error != 0)
errorState = true;
//Thread.Sleep(1000);
Debug.Print("Sets completed: " + (errorState ? "Error Somewhere" : "No Errors"));
}else if (_currentBtns[4] && !_previousBtns[4])
{
Debug.Print("All configurations cleared");
/* Need to add to param enum to higher level cs files */
_talon.ConfigSetParameter((CTRE.Phoenix.LowLevel.ParamEnum)500, 0xA5A5, 0, 0, 10);
}else if (_currentBtns[6] && !_previousBtns[6])
{
Debug.Print("Reading all configurations");
float[] Configurations = new float[5];
_talon.ConfigGetParameter(CTRE.Phoenix.LowLevel.ParamEnum.eContinuousCurrentLimitAmps, out Configurations[0]);
_talon.ConfigGetParameter(CTRE.Phoenix.LowLevel.ParamEnum.ePeakCurrentLimitAmps, out Configurations[1]);
_talon.ConfigGetParameter(CTRE.Phoenix.LowLevel.ParamEnum.eOpenloopRamp, out Configurations[2]);
_talon.ConfigGetParameter(CTRE.Phoenix.LowLevel.ParamEnum.ePeakCurrentLimitMs, out Configurations[3]);
_talon.ConfigGetParameter(CTRE.Phoenix.LowLevel.ParamEnum.eMotMag_VelCruise, out Configurations[4]);
Debug.Print("CCLA: " + Configurations[0] + " PCLA: " + Configurations[1] + " OLR: " + Configurations[2] + " PCLM: " + Configurations[3] + " MMVC: " + Configurations[4]);
}
System.Array.Copy(_currentBtns, _previousBtns, _currentBtns.Length);
Thread.Sleep(5);
}
}
}
}
The Asus Laptop
It would appear that SetValueMotionProfie.Hold provides a different result form ....Enable. Using Vehicle SPY, it would appear that the HoldHeading Signal in the General Control frame is set to false sporadically.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.