purduesigbots / libblrs Goto Github PK
View Code? Open in Web Editor NEWUseful utilities made by Purdue's VEX U BLRS team for PROS 2
Useful utilities made by Purdue's VEX U BLRS team for PROS 2
I rewrote some of my code to include libmtrmgr, and noticed that my lift was moving incredibly slowly.
So I got my trusty LCD and printed out the values with motorGet, and noticed that the motor was only getting 29 power when it should've gone up to 127.
So here's the recalculate function I was using with a slew rate of 3.0:
int applyLinearMotor(int input) {
static const unsigned int trueSpeed[128] =
{ 0,6,7,7,8,8,8,9,9,9,
10,10,10,10,11,11,11,11,11,11,
12,12,12,12,12,12,12,13,13,13,
13,13,13,13,14,14,14,14,14,15,
15,15,15,16,16,16,16,17,17,17,
17,18,18,18,19,19,19,19,20,20,
20,21,21,21,21,22,22,22,23,23,
23,23,24,24,24,25,25,25,26,26,
26,26,27,27,27,28,28,28,29,29,
30,30,31,31,32,32,33,33,34,35,
36,36,37,38,39,40,41,43,44,45,
47,48,50,52,54,56,58,60,63,66,
68,71,74,78,81,85,127,127 };
int output = trueSpeed[abs(input)] * sgn(input);
return output;
}
The reason this happens is that motorGet returns 29, it adds slewRate * dT = 3.0 * 20, which is 89, and the 89th value in my array also happens to be 29, so the output never increases. The same collision problem happens with a slew rate of 1.0. when it gets to 13. As 13 + 1.0*20 = 33, the 33rd index of my array is 13.
Demonstration here: http://tpcg.io/woTx2I
What I did to circumvent this (this is an imperfect solution), is I removed the recalculate on line 68
libblrs/libmtrmgr/src/mtrmgr.c
Line 68 in c2ac60d
And added the recalculate to line 133, as seen here:
https://i.imgur.com/wTmkNru.png
This way, the recalculation is done once, when you request the value.
However, this solution only gives you the advantage of linear speed control, the slewing is not linear.
I'm unsure of what the "perfect" fix would be to get a linear slew increase.
Hope this helped.
It would be ideal to have the makefiles update automatically to reflect changes in the library's version on Github releases, as is currently done with the PROS kernel.
In the method (which is in chassis.c in the mtrmgr project), the return statement is return (cmd > 0 ? TrueSpeed[cmd] : (-1 * TrueSpeed[cmd]));
. If cmd
is less than 0, then returning (-1 * TrueSpeed[cmd]));
would throw an exception since the index is less than 0.
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.