The students are making a “freeze tag” bot and they have tried using the set drive timeout block and the stop driving block and neither seem to override the joystick to make the robot inoperable… does anyone have a working freeze tag they would like to share for VEXcode IQ?
Post your code please!
Maybe in the forever loop you could say
When bumper is pressed:
Wait 100000 milliseconds or something.
That way it would hold up the forever loop until the count was over. However you’ll have to make sure it’s in the same loop as the drive controls.
Edit: like @sankeydd said, dont forget to stop all motors and other functions otherwise your bot will keep on moving.
Set drive timeout does not make the drive stop. It sets the amount of time before a command can stall and move on. If the timeout is one second and the bot runs into a wall, then it will stop driving into the wall after one second of the wheels stalling.
100000 miliseconds really isn’t that much, it would only be around 100 seconds, since 1000 miliseconds=1 second.
That’s a lot of freeze tag lol. Imagine having to wait an entire vrc driver period
Don’t forget to also stop the motors or it will continue on with whatever it was doing when the trigger was hit!
If you want to play freeze tag with a “healer” system (where the people tagged are frozen indefinitely until another person who isn’t it tags them) then you could set some toggles in your code. If you press the button, it would change a variable from 1 to 0, disabling the driver code using some sort of if statement. Then, when the button is pressed again, switch the number back to 1 and the drive is reenabled. Let me know if that’s what you’re looking for, and if you need any help implementing it.
That moment when the freezer taps a frozen robot.
This was my thinking as well – a toggle switch to either disable or turn off the motors. You can even add a counting line – for example, when pressed 3 times, shut down, etc.
It’s not as easy as it was in Modkit because in Modkit, it seems blocks were “King”. That is to say that if you had a drivetrain configured and set your teleop via the built in config button, the “STOP” command trumped whatever the drivetrain config was telling the motors to do.
In VEXcode Blocks IQ, this doesn’t seem to be the case so you have to move away from using the controller config in devices and move it into your code.
As with any programming, there is a thousand ways to do the same thing but the attached will point you in the right direction (using tank controls)
@tfriez for info, I expected to be able to do the same thing using the drivetrain and in the code, replace the motor spins with drive forward and turn right, then configure the speed by using the velocity commands for drive and turn. However, this is really jittery and doesn’t work in the same way as just setting individual motors.
tag.zip (4.5 KB)
@drow - is there any way to allow the forum to accept .iqblocks files so we don’t have to zip them?
The code generated by the Device’s Controller interface is started as a background thread. An improvement we made from Preview to 1.0 allowed you to control the Drivetrain via blocks and prevented the velocity of the drivetrain from being adjusted unless the Controller was beyond the centering threshold (+/- 5%).
Beyond “Freeze Tag”, I’m not certain where you would want to disable the Controller input ‘forcefully’. You can create semi-autonomous behaviors by using buttons on your IQ Controller, and those commands shouldn’t be interfered with unless you start moving the Controller joysticks mid-movement. Not to say we couldn’t add a “[disable/enable] Controller” block in the future, I’d just want to understand the use case more from the community.
I’m not so interested in the stop command to be honest. If you are making freezetag, just code it and ignore the controller config dialogue box entirely.
However, if you have not configured the controller to specific drivetrain commands in the controller configuration dialog box, I do think that both of these options should work in code:
But only the right one does.
@tfriez would like to see the “[disable/enable] Controller” block… the kids just love the freeze tag as it a way for them to “battle” without us calling it battle bots… it is very engaging for them…The lesson goes deeper than just tag with a bumper… I also introduce the concepts of states with the led showing the state of the robot (tagged or not tagged)… next I introduce variables along with if/ then blocks for “lives” … then we move into gear ratios to you can be faster or stronger… This is the intro project for coding and we had great success with MODKIT. I run a problem/project based class and show them just how to set up the robot using devices and then they figure out the rest with minimal help… Lots of groups here are trying to use the timeout block or stop driving block as it seems like the intuitive choice here… suggestion to add in the help section that this will not override the drivetrain commands… for now we will just use the led as an indicator to tell the driver to stop driving
Or just use code like the one I posted James.
Correct, you’re giving the drivetrain two simultaneous commands there - to move “forward” (assign the velocity to both left/right motors at the same value) and then to immediately “turn right” (assign the positive velocity to the left motor, and the negative velocity to the right motor). Which is why if you want more finite control of your robot, the left makes more sense to control the two motors independently as you want to assign their velocities independently.
Yeah, my bad. That makes perfect sense now. As you were!
So I took one of the Controller example projects (Tank Drive) and augmented it to create the “Freeze Tag” behavior using Boolean variables. Blocks I added to the example are highlighted in Red.
This is the easiest way I have come up with as the program works now… I really like to teach in a discovery style since most have used scratch before… however there is alot going on here… variables… if then else statements…ect…
It’s almost 2 IQ matches