Remember that robots can only follow the code you provide. For the turning PID to work its best, you’ll have to tune it.
The drive test is dependent on the drive and heading constants, tune them in whatever order you want.
Thank you, i will make sure to try that
Josh, I have used JAR template all season without encountering any problems but now when I try to add tracking wheels I get a Memory Permission Error(03804DEC). After troubleshooting it seems to work as long as I dont put PORT# in the sideways/forward tracker ports it only lets me run code if it is just the #. I am using rotation sensors so this doesn’t make sense to me. Sorry if this is an obvious mistake.
Code:
After your fixes, the code works? If so, I’ll update the instructions accordingly.
Do you think I could use this template for IQ. Of course, I would fix the syntax for the IQ system.
From what I can tell, after much more troubleshooting, this seems to be an error in the JAR template. In line 90 (assuming use of VEXcode Pro V5) if you have a rotation sensor and you write PORT1
or 0
it fails and gives the memory permission error. If instead you write 1
it will run fine. None of this changes if you write brain Brain;
in main.cpp right before Drive chassis()
and it also doesn’t seem to matter what line 102 says.
The bug in the JAR template is because the same variable is used twice.
R_ForwardTracker(ForwardTracker_port),
E_ForwardTracker(ThreeWire.Port[to_port(ForwardTracker_port)]),
once to initialize a rotation sensor and again to initialize a threewire port.
If ForwardTracker_port is PORT1 then the to_port functions returns a bad value as PORT1 is 0. This would be the fix, test for bounds in the to_port function.
int to_port(int port){
if(port>8 || port<1){
return(0);
}
return(port-1);
}
I thought the bounds on threewire ports were [0,7], so 0 maps to port A and 7 maps to port H. Is this wrong? Is it actually [1,8]?
yea, you were returning port-1
so when PORT1 is passed that became -1, an invalid index to the Port array,
ThreeWire.Port[to_port(ForwardTracker_port)]
from comments
Triport A will be a “1”, Triport B will be a “2”, etc.
and 0 had been passed.
Kind of crazy I was the first person to find this, you would think that someone else would have used PORT1 as there forward tracker. Also, I don’t know how you can find one line in hundreds that messes up the whole thing Nice job, jpearman.
When you say PORT1 is 0, what does that mean? Surely PORT1 should be the same as the integer 1?
No, smartports are 0 based (like an array) from the source code.
namespace vex {
const int32_t PORT1 = 0;
const int32_t PORT2 = 1;
const int32_t PORT3 = 2;
const int32_t PORT4 = 3;
const int32_t PORT5 = 4;
const int32_t PORT6 = 5;
const int32_t PORT7 = 6;
const int32_t PORT8 = 7;
const int32_t PORT9 = 8;
// snip
Dang, alright. Thanks for the help.
yea, don’t feel bad, the issue of starting at 0 or 1 has caused problems for what seems like forever. Sometimes programmers will use a more natural way of naming indexes and start from 1, but then, unless you are prepared to just make element 0 of an array unused in C, you tend to always be messing around with adjustments like
x = myarray[index-1];
Much of vexos for V5 was written before we even had names for the smartports, so naturally as C programmers we just started with the first smartport as 0.
Hi
Is JAR working in Visual Studio?
What I did was download JAR template into the outdated vex app and then import that project into visual studio code.
Is JAR Template compatible with encoders. If so, how would you enter the ports in the initialization at the start of the code for tank_two_encoder. As of now it seems as though JAR will only take one triport instead of the two ports necessary for the encoder.