autonomous mode problem on field

At our practice rounds today, we had a bit of an issue with some of our autonomous mode code working, and I’m wondering if maybe any of you can help me out with how this could be happening.

OK, here goes. Our robot has the capability to do two different things during autonomous mode. It can either seek boxes, for which it uses light sensors and a thing we made to count wheel rotations, or go up the ramp, which is based entirely on wheel rotations. There are two on/off switches on the robot that tell it what to do during autonomous mode. These switches are set by the people who put the robot on the field at the start of the match. One switch (rc_sw10) tells the robot which side of the field it is on, and the other (rc_sw14) tells the robot which program to use (Go up ramp when 0, seek boxes when 1). Now, both of these modes worked fine when we practiced at Rockwell Automation, where we work on the robot.

We got to competition today, and during practice had 3 chances to test out autonomous mode. We tried box seeking mode 3 times, and it successfully knocked down the opponent’s big stacks, but when we had the switch flipped to try going up the ramp, nothing happened at all during autonomous mode. After this, back in the pits, I sat the robot on a box and used our autonomous mode dongle to test these modes. Both appeared to be cause motion when using the dongle on the competition port, but for some reason, the robot did not do anything when it was told to use the ramp program and was in an actual practice round connected through FIRST’s radios, instead of a tether. So, my question is what could be causing one of these two parts of autonomous mode not to be working? Is there something different about the way a competition port dongle and tells the robot through the tether that we are in autonomous mode than when we hook up to the FIRST competition port on the field tells the robot through the radio? I spoke with Eric Rasmussen from FIRST about this at the event, and he thought maybe it could have to do with the fact that on the field, the competition port also enables and disables the robot in addition to changing the autonomous mode state, and that the order that this happens in could be messing it up, but, after looking at my code, I don’t really think that is it, though I may be just missing something (It happens a lot :slight_smile: ). here is some of the code:

OK, first we have the section that tells the robot whether or not to do box seeking, then the section that tells it whether or not to go up the ramp. here is what it looks like:

If auton_mode = 0 or rc_sw14 = 0 then skip_box_seek:
(box seeking code here)

If auton_mode = 0 or rc_sw14 = 1 then skip_up_ramp:
(code to drive up the ramp here)

I don’t think those middle parts should matter too much, since really the problem seems to be with how the robot enters autonomous mode, and since the program is actually on another computer next to me that I am looking at and then retyping here, it’s not worth the time to retype all of it. At any rate, none of that stuff considers the auton_mode bit at all anyway. I’m pretty stumped at what could be causing this (though I really can’t claim to be any type of a programming god), so please let me know if you have any idea. Also, please forgive the length of this post :). Thanks.

–Chris C.

have u tried running the auto code on the ground? it might be that after the robot has sat in a box for a few weeks the drive train isnt as smoothe as it was before, so it might be that your values for turing are too low, therefore when its sitting ontop of the box the wheels turn, but when you put it on the ground the power isnt there to get the bot to move. Try running the program tethered up in the pits in a nice open area.

Could it be a timer problem? (See my post in this “RoboEmu 1.11beta1”]( thread.)

Yeah, I think it’s a timer problem, as said above. The code begins executing as soon as the robot controller gets contact with the OI. The master processor just doesn’t allow anything to be output to the speed controllers. Your timer is probabaly expiring before your robot gets a chance to do anything.

If you look at Team Update 11 it shows how the bits are for the phases of the match. Whenever autonomous mode is set to 1, all operator interface feedback will be overridden.

When comp_mode is 0, your robot is active. Basically, make your if statements to read:

If auton_mode = 0 or comp_mode = 1 or rc_sw14 = 0 then skip_Blah

Well, I don’t consider time in my program, only wheel rotations, and these only get counted when there is motion in the wheel, so unless I am misreading this, I don’t think that is the problem. I’ll try out your ideas though and see if they help. Thanks.

You can’t test your controls during autonomous control, because they default to 0/127. Instead you must test any autonomous selection switch in your non-autonomous code and then save this value in a “dummy variable” for the autonomous period.

if automode =0
if switch = 0
dummyvar = 0
dummyvar = 1

if automode = 1
if dummyvar = 0
'Box mode
if dummyvar = 1
'Ramp Mode

Something like this should solve the problem

*Originally posted by K. Skontrianos *
**You can’t test your controls during autonomous control, because they default to 0/127. Instead you must test any autonomous selection switch in your non-autonomous code and then save this value in a “dummy variable” for the autonomous period.

That’s true of the switches that connect to the OI, but the ones on the RC should still work fine. (ie you can’t use p1_sw_trig, but you can use rc_sw1).

that was the glitch we had when we were first testing. We don’t use the default names, so rc_sw14 means little to me.

Anyways, i’d make sure that the robot was tested properly. Did you use both the disable and autonomous switches to test the machine? FIRST disables the robot then starts autonomous mode and enables the machine. Could this make a difference in your code? It may be possible to get a different response if you tested the robot by turing on autonomous mode while enabled… although I don’t think we encountered such a difficulty. Never hurts to check though.

I found that with the new dongle, when the “kill” switch was on, even if the auton_mode switch was demanding auton_mode be set (= 1), the auton_mode bit was in fact reset (= 0). When the “kill” switch was flipped to “Operate”, auton_mode then set itself, until the auton_mode switch was flipped. The kill switch affects the state of the comp_mode bit, in case you were wondering.

…Auton_mode bit state:

Kill ON…0…0
Kill OFF…0…1

I wouldn’t imagine there is a different way to do the disable and auto functions via the comp-port.

BTW - does anyone know if the user_mode bit affects the other two ? (And if, then how ?)

We had some problems early on with debug statements that seemed to cause a similar sounding problem. I removed them and then it worked on radio. After that, I only used dashboard.

Chris, Good idea to use the switch to choose sides! Some made multiple programs. We used a switch because I figured edits would kill us if they were separate programs.

– I was just happy my auto-code didn’t lose us any matches!


Update number 11 has the bit sequence of comp_mode and auton_mode for the match. Its supposed to go like this:

Before the match: comp_mode = 1, auton_mode = 0
Autonomous: comp_mode = 0, auton_mode = 1
Teleoperation: comp_mode = 0, auton_mode = 0
After the match: comp_mode = 1, auton_mode = 0

We have a thumbwheel switch on the OI to select the autonomous program, so its important to make sure we grab the value before autonomous starts or it will be overridden to 0. We wrote the initialization program with the following conditions:

IF comp_mode = 0 AND auton_mode = 0 THEN RUN 1

IF comp_mode = 0 AND auton_mode = 1 THEN 
   SELECT ProgramNumber
      CASE 0
            RUN 2
      CASE 1
            RUN 3
      CASE 2
            RUN 4

Slot 1 holds the teleoperation code and slots 2 - 5 hold autonomous programs. During testing with the dongle it worked fine, but on the field it kept running slot 1. We didn’t realize right away what was wrong, but you cannot depend on the bits flipping in the order they tell you. I think they drop comp_mode low before raising auton_mode, which is what messed us up. Its fixed now, but it was very frustrating.

we had that problem alittle too

if you’re sitting still at the beggining of the match its possibly because your human player didnt get off the feild in time, not nessisaraly the auton code. make sure that they get off in the oloted time

You should cycle the robot power before starting an autonomous mode match. This way you will be sure all of you variables (flags, states, etc.) are reset to their default state.

If you do not, the processor is still running in your main loop after the match. When the competion controller disables the robot, it disables the inputs and the outputs but does not force a controller reset. When re-enabled, the controller picks up where it left off.

When the second match starts, the processor continues to run but the initialization section is not executed thus any variables remain at the same value as at the end of the previous match.

The effect can be:
Let’s say your dead reckoning code has a timeout so your robot doesn’t run after it knocks over the boxes. You use that value to stop the motors. When you start the next match, that variable has not been reset and your code will think it is still at the end of the previous autonomous mode session.

By doing a power off and power on (POPO)before the match, you are assured of a proper controller reset and thus the initialization code will be executed properly.

We had this happen in our first practice round in the regional and didn’t have a problem since doing to “POPO”.

Redukes has the correct answer here.

We experienced the same problem, which you would only encounter during the practice matches.

Auton mode works the first time, because the RC is in a fresh reset state at the start. However, the field does not reset your robot controller between the two practice runs, so if you counted your auton operation to 400 steps, the step counter is still at 400, and nothing will happen. You can solve this by simply pressing the robot reset switch between the two test runs - or cycling power.

We had the same problem at NASA/VCU during our first two runs - we were going crazy trying to figure out why one of our auton modes wouldn’t work, but it had nothing to do with our coding.

BTW, there is an elegant fix for this in code. Once Auton mode is false - reset you timers, counters, whatever. This makes the robot essentially self-reset the auton variables once driver control is initiated.

*Originally posted by Jnadke *
**When comp_mode is 0, your robot is active. Basically, make your if statements to read:

If auton_mode = 0 or comp_mode = 1 or rc_sw14 = 0 then skip_Blah **

After the initial powerup sequence on the field causing problems with some autonomous programs, FIRST has switched the bit toggle sequence to(If i understood what Eric told me correctly):

Pre Match: auton_mode = 0, comp_mode = 1
Human Player Phase: auton_mode = 1, comp_mode = 1
Autonomous Phase: auton_mode = 1, comp_mode = 0
Remote Control Phase: auton_mode = 0, comp_mode = 0
Post Match: auton_mode = 0, comp_mode = 1

So, what I’m going to recommend is that your code only starts running in autonomous if BOTH auton_mode and comp_mode are in the states described above. As an FYI, FIRST changed this after realizing that with the original field control code, it was possible for one or two program loops at match start that the PBASIC program would think that it was in user control mode, and possibly skip over the auton program entirely(see other threads on this).

Human Player Phase: auton_mode = 1, comp_mode = 1

nope, in human player phase, comp_mode =1 and auton_mode = 0! The reason I know this for a fact is because our bot refused to move in auton period during pratice rounds. If auton =1, our bot would have went into auto mode during the human time and would have waited until it could move. Instead, it went into driver mode right away. We use multilple program slots, so the fix was to have the driver code check for autononymous mode and transfer control to its slot if it was on. However, it sounds like you are using one slot with if statements, so this isn’t likely to be your problem

*Originally posted by Nate Smith *
**Pre Match: auton_mode = 0, comp_mode = 1
Human Player Phase: auton_mode = 1, comp_mode = 1
Autonomous Phase: auton_mode = 1, comp_mode = 0
Remote Control Phase: auton_mode = 0, comp_mode = 0
Post Match: auton_mode = 0, comp_mode = 1

These are probably the signals that the control system is sending to the OIs. However, the OIs themselves will not send down the autonomous bit to the RC unless BOTH autonomous is set AND it’s not disabled.

Originally we had our switch wired up such that by flipping one switch, we grounded the auto pin and un-grounded the disabled pin at the exact same time. When we did it this way, there were 1 or 2 packets that went to the robot that enabled the robot but didn’t have autonomous set. When we instead wired it up with two switches such that we could enable autonomous and then after that enable the robot, it would go straight from disabled with no auto to enabled with auto all at once.

My guess is that this is the same change that IFI made to the arena control system.

See… these comp mode and other crap just confuse everyone… heres what we did:

if auto_button = 1 OR auton_mode = 1 then

select (auto_select)
	case 0 to 2 	'line tracking
		run 6 
	'case 4 to 7	'dead reckoning
		run 7 
	case 8		'joy 1
		run 2
	case 9		'joy 2
		run 3
	case 10		'joy 3
		run 4
	case 11 	'joy 4
		run 5
	case 12 	'joy 5
		run 2
	case 13		'joy 6
		run 3
	case 14		'joy 7
		run 4
	case 15		'joy 8
		run 5

gosub operator_control

When the autonomous program detects that auton_mode = 0 and someone has moved the joystick then it resets all its varibles and returns control to the first slot… like so:

if auton_mode = 0 then

	if p1_x > 142 OR p1_x < 112 OR p1_y > 142 OR p1_y < 112 then
		run 1

This is why multiple slots are so much easier to program with… and by the way, have I mentioned yet that our autonomous mode has worked flawlessly in all of our competition matches?