Any Coding Tips? VexIQ VexCodeIQ ShootingRobot

I am trying to code a shooting robot for state. We have the event on Saturday (2/19/22) and would like some tips that will help us out. We have a vertical collection mechanism and a dual motor and firing choo-choo mechanism. We will use a distance sensor to tell when the catapult is down and maybe(?) 1 or 2 bump switches to detect the balls in the slots. Just respond if you want any information you think is necessary.

Not sure if that was just a typo, but I wouldn’t recommend the distance sensor to stop your catapult. Use the color sensor. And whatever you DON’T use the bumper. We tried that at first with great failure. I’m not sure how helpful this video is, but it talks about this shirt of thing. I would also suggest having the color sensor sense white and sticking a blank license plate on the side. I’m not certain, but I think all the holes in a normal beam could through it off.

You’ve also waited a REALLY long time to start coding. Good luck.

3 Likes

Thank you so much! :grinning_face_with_smiling_eyes:

In our driver program, we have a when started block and then a forever loop with a bunch of ifs inside it to check all our buttons. I’ll put in the code we have for our color sensor. (It’s called catapultResetter.) You can find these commands as blocks in the menu. If you don’t know what a block does, you can click the question mark in the top right and click the block.
Screenshot 2022-02-16 10.50.54 AM

when started:
catapult.setVelocity(150, rpm); // I wouldn't recommend this since the motors aren't that fast
while (true) { // This is a forever loop
  catapultResetter.setLight(75, percent);
  if (catapultResetter.brightness() > 75) {
    wait(2.05, seconds); // You'll have to adjust this. 
  // You know you have the right number when you can power off your brain and your catapult stays down.
    catapult.stop();
  }
  if (Controller.ButtonLDown.pressing()) {
    catapult.spin(forward);
  }
}

Here’s the same code in blocks:
Screenshot 2022-02-16 10.50.32 AM

1 Like

Your best sensor is the motor encoders. If your chochoo is a 2:1 ratio, just have a button spin the motor(s) 2*360. That will shoot and reset the motors to the exact same position. Have one more button for adjusting it to the right position.

1 Like

I wouldn’t recomend those.

  • We often store our robot with the catapult up, to keep the rubber bands from getting stretched out as quickly. Then you turn on your robot and push shoot and it goes down and back up, so it’s always up and you can’t load.
  • What if you get some fluke during a match where the catapult goes up when you don’t want it to? It happens to us about every fifteenth match and when our battery starts to die. Then you push shoot and your catapult goes down and back up and you can’t load.
  • For us, the command for LDown is catapult.spin(forward), which is supposed to make it spin forever, but about 2/3 of the time it only goes up. The jolt of hitting the hard stop seems to make the spin command cut out. If the same thing happens when you say spin catapult 0.5 turns and it cuts out after going up, pushing shoot will make it go down and back up.

In all of these situations, if you had a color sensor, you could just push shoot and the catapult would spin until it got to the color sensor, which would stop it in the down position.

(By the way, if you had a 2:1 gear ratio, one full turn of your driven gear is spin 0.5 turns or 180 degrees. If you had a 1:2 ratio, one full turn of your driven gear would be spin 2 turns or 720 degrees, which is 2*360.)

1 Like

Yup, I switched it!

I have about 10 teams that used a chochoo. The students will generally have three bottons. One to move it down, one to move it up, one to shoot and return. So, yes, they need to put it in the down position at the beginning of the match. There’s a button for that.

This isn’t a problem with using the motor encoders. You can just have it in the non-stretched position or remove the rubber bands.

Curious, how does your battery being low make it shoot? Sometimes they shoot if the catapult is set too close to the “shooting” position. If you have a sensor installed, it would take reinstalling the sensor to adjust how far down it’s being pulled. With the encoders, it’s just a matter of raising it up a smidge.

This sounds like you have a different problem???

Yes I agree.

But if the students don’t have good knowledge and experience with those sensors I wouldn’t go there. What if the lighting in a new venue causes a problem? Yes, experienced teams can account for that, but for most teams the motor encoder is the simplest solution. I’ve watched them shoot probably over a thousand times, it’s very reliable and super easy to code and for students to understand how it works. For most groups it’s 2 blocks, and nothing to add.

1 Like

Then you’ve used three of your eight buttons, and you’re running out of buttons for other things, like what about stopping the catapult, hanging, combine in, out, stop. You’ve used up all your buttons.

The problem is when it’s in the non-streched position, you can’t load it. Removing the rubber bands doesn’t reset the catapult, and you can’t remove the rubber bands in the middle of a match. So your catapult is up, you push shoot, and your catapult completes one full revolution, down, shoot, and it’s up again.

No, the battery being low sometimes lets the catapult slide and it slides up backwards, it doesn’t spin and shoot. It more like releases.

It might be a different problem, but you still have the problem anyhow. If it’s the same with spin # of turns, it could cut out after going up, and now you have to manually reset it again.

We have been in a dark basement and a sun-in-your-eyes gym and have never had that problem. Have you?

1 Like

I don’t have a group that has run out of buttons.

The catapults start the match in the pulled down position to load the balls. Then, spinning the motor the correct number of rotations always brings it back to the right place to reload. This is the second time you’ve said this is a problem, but it’s not. If you still think it’s a problem, tell me why.

I have had students having trouble with line followers as they went to other places. I guess it’s always something to consider. I’m glad you haven’t had any issues with it. OP doesn’t really have time to troubleshoot. Tournament is on Saturday.

You do have a great solution that works for a lot of teams.

Using the motor encoders is also a great solution that works for a lot of teams. I had two teams clear the field and hang today using the motor encoders to shoot. They done it hundreds of times and it works great. You keep saying it’s going to cause all of these problems, but you clearly haven’t tried it. It works great.

So, OP has about 72 hours until the competition. The fastest way for them to get the code working and the robot working and the team practicing is to add three blocks using the already installed motor encoders.

OP should then take some time after the tournament, and try to code it to load down using a variety of methods to see which one they like best.

1 Like

I am curious about the great failure with a bumper switch. I have a team using it with much success.

Either our bumper sensor was defective or we couldn’t position it perfectly. We had endless trouble with positioning the bumper perfectly so the catapult didn’t slide back up when the bumper stopped it or shoot before it stopped. We switched to a new robot and switched to a color sensor, because we could say, if color sensor brightness > 75 {wait x msec and then stop the catapult}. And it works because the color sensor still senses the > 75 brightness after x msec. If you can position a bumper perfectly, though, it might work. Then you’re barred from making any changes, too, because you’d have to reposition your bumper. With the color sensor, you just change x.

1 Like