Hello!
This is Dominic Jakubowski, captain of the Robosapiens, team 4779. After going to our first district event this year at Waterford, we have learned the importance of having diverse abilities in auton. We have decided that sensors and a auton vision system is necessary to compete on a higher level. We have explored different options to step up our game and currently we are looking to use encoders (https://www.andymark.com/encoder-p/am-3314a.htm) and a gyro (KOP) to move our robot in position to place a gear on either outer peg on the airship. Then we would like to adapt our vision system (https://www.logitech.com/en-us/product/hd-webcam-c270) to find the reflective tape on the plexi-glass to hone into the gear lift. We would also like to use an ultrasonic sensor (https://www.sparkfun.com/products/13959) to signal our robot that the gear is on the peg and can release the gear. My question is whether the encoder that I have selected will work with standard spark motor controllers (http://www.revrobotics.com/spark/) ? I have read the manuals and could not find any information on how encoders work with the sparks, but I have found some forum posts on here about TALONS, and how they work with the break out board. I have also read on another thread that two encoders are necessary to be successful and accurate, so would we put two encoders on our back two wheels? We are using the standard Andymark chassis in the square configuration. How would we wire the ultrasonic sensor? We have never had any sensors on our robots except for limit switches so your help will be greatly appreciated.
We used only one encoder on our robot. However, this is because we had an “auto straight” function that always kept our robot straight using the gyro so we didn’t have to worry about two sides. For the encoder itself, we used our CIMCoder through the roboRIO. You can hook it up to like a Talon SRX for faster update rate, but that was overkill for us. If you run through the RIO, you don’t have to worry about what speed controller you have.
For vision, we used a Raspberry Pi 3 and it worked well, getting us over 57FPS.
We also used an ultrasonic sensor for the last part of the autonomous to the peg. That is connected to the DIO on the RIO like the encoder is.
For wiring, you would simply put the VCC to the 5v rail, GND to GND, Trig to a signal pin, and finally Echo to a signal pin. All these pins are on the DIO part of the RIO, not the PWM. Then, you would just use your language of choice and type in what port numbers you have.
Couple of things…
It sounds like your team is getting ready to make a pretty big leap. Going from no sensors to 4 or 5 sensors…
We are currently using a couple of encoders for different reasons. We have 1 encoder on 1 of our drive train gearboxes to control how far we move. We are using a pixi cam to find the vision target. At one point we discussed adding an ultrasonic sensor to determine how far away the peg was.
As for the encoders you listed, make sure you have an output shaft on your drive train to connect them to.
Have a plan for what you want each sensor to detect, and have the people on your team figure out how to incorporate each sensor in your program before you try to implement it.
Finally make sure the sensors are pointed at or actually measuring what you want them to measure.
Hope this helps…
Edoga
Sparks do not have an encoder input as far as I’m aware. You will either need to implement your PID controller in software, or you can use Talon SRX’s to implement PID.
We use Victor SP’s and a software PID controller, works well enough for our needs.
Dominic,
Those are probably not the encoders you want. Do you know the the gearbox your drivetrain is using? You want to mount the encoder on your drivetrain, and get a counts per inch for distance calculations.
We use the kit ultrasonic to gauge the distance from the wall behind the peg.
We also use a gyro to drive straight to the peg in auto. Those are the only two sensors we use to hang peg. I would see if you have a gyro in the KOP too.
Getting vision to work is significantly more tricky, so I would say focus on the ultrasonic and gyro first, and see if you can get the straight auto to work.
We are going to be at our school, 10-3 on Saturday, if you want to come by and we can walk you though any questions.
Sorry I do not remember your bot from last weekend, but do remember the team.
The problem with using a single encoder is that when you perform a turn using a gyro, it’s almost certain that one side of the drivetrain will move more than the other. This results in the robot slightly changing it’s forward/backward position. You can reset your encoders to zero after the turn to remedy that, but then you risk constantly expanding error as each time you reset you ‘include’ your positional error in your next move.
A better option is to have an encoder on each side and average them. It’s also a nice backup - if one dies you can always switch over to using just 1 encoder until you can repair the other.
Sorry to change subjects, but what gyro were you guys using?
After the turn, you don’t need the encoder. This is when the ultrasonic sensor comes it.
if ultrasonicSensor.getInches() < 9:
placeGear()
else:
moveForward()
However, I do agree having two encoders is nice if one fails. We just had one CIMCoder on hand so that is what we used.
NavX. I am sure the KOP Gyro would do just fine as well.
Just remember that doing it that way will get closer than 9 inches - but you really have no idea how much closer. The lag time of the sensor coupled with the momentum of the robot will make it inaccurate.
That 9-inch thing is more of an experimental variable. So really, it releases our gear at about 6 inches. Even if it “crashes” into the peg, it is only going like 30% speed which isn’t that fast for our robot.
Thank you for your help with wiring on the ultrasonic sensor. We found a KOP Ultrasonic sensor (http://www.maxbotix.com/Ultrasonic_Sensors/MB1013.htm0 laying around, so we are going to use that. We are still kind of confused on wiring it. Currently we have a PWM wire (red, black, white) running to it. The black wire runs to GND. The red wire runs to V+. Where does the white wire go? Is there anything else to wire?
The KOP gyro.
How did you wire the ultrasonic sensor?
Sorry, I wrote instructions for an HC-SR04 ultrasonic sensor. For the KOP one, you will use the Analog Input section of the RIO. Red goes to V+, Black goes to ground, and White goes to signal. In the code, you would just read the analog input and multiply by the constant. There may even be a library for MaxBotix sensor in the language that you use.
I figured it out. Pin 3 is signal and Pin 6 and 7 are power.