Can some one help pleas I'm I can cant find any sumo robot code for my arduino. I have spent a over a day looking for code and trying to make some my self (:( . I have 2 simple IR sensors that send a high when it sees something and 2 IR sensors that send a high when they se black pleas help.
111swords
You will probably not find it
You are probably not going to find any “universal sumo code” that is going to work. No two robots (unless they are mass-produced) will be constructed the same or wired the same. There is very little chance you can take any “off-the-shelf” code from anywhere, stick it in and have it work. Instead, you can, and should, look at examples of code from folks that have done similar stuff to what you want to do and see if you can use portions of their code and/or get ideas and inspiration from it. In the end, you can’t get away from the fact that you are going to have to write some code here.
I would suggest breaking everything into much smaller steps. First off, write a small sketch that simply runs your motors. Get them to go forward and back and turn. Get that working and solid.
Next, write a small sketch to simply check your sensors. You can use the serial monitor to keep an eye on your tests and simply be sure they are A) working and B) spitting out the data you expect.
Next is to try to code a very simple, small part of the sumo routine. If I understand correctly, there is a white or black ring that the bot needs to stay inside. I would write a sketch that drives around (anywhere) and simply avoids this ring. --Just a simple code to “stay in the circle”.
Next would be to forget about the “stay in the circle” thing and instead work on a sketch to “find the other guy”. Play with this one a while.
When you have all of the above working, you can start to try to put them all together. Its the only way to do it, my friend.
Sumo robot
Thanks for the help but I have the code for staying in the ring and the code for finding the other guy. Now I need to put them together and I find that to be very hard very very hard
Well sorta…
Have you run either of these chunks of code by themselves?
Let’s start with “staying in the ring”. Does that piece of code work? I wonder because there is not a huge chance that the pins used say, to control the motors are the same as the ones used to wire your bot. Either of the motors could be “plugged in” backward and thus, not be going in the right direction. Same goes for the downward-facing sensor. You say it is putting out a HIGH signal --most sensors like this normally put out a LOW signal when “triggered” --Again, it would just be surprising that any off-the-shelf code would work with no modification. I dunno, maybe you have modified it to work --I am not really sure where you are with this bot.
My suggestion again, would be to work from scratch. I have found that I usually spend more time trying to modify then just writing my own.
–What issues are you running into so far in terms of trying to merge what you already have?
Yes my robot stays in the
Yes my robot stays in the circle thats one code and can find the other bot thats another code,this is the type of code I want to use but cant get to work
if (obstacleDetected?)
{
attackRrobot();
}
else
{
stayInTheRing();
}
When I combine the attackRobot(); and stay in the ring together my robot goes crazy.By the way I’m great with the hardware but not so great with the code stuf so I did not mess any of the wires up
Real code
Can I get a look at the actual code? You are showing me “psuedo code” --sorta a outline of how it should work. Where is the “obstacleDetected” routine? Also, can I see the functions attackRobot() and stayInTheRing()?
Again, I feel as though I am missing something --Are you building some kinda “standard” sumo bot? Did you follow a design and are using example code for that design?
Lemme see everything you got.
Here is the thing…You
Here is the thing…
You should do a search not stay in the ring routine if obstacle is not detected. Stay in the ring should be triggered by the floor sensors that have to be monitored at all times. So you kind of do this in the search loop: check all sensors, if floor sensors triggered, call stay in the ring, if obstacle sensors triggered, call attack, else, resume search. The stay in the ring function should check which floor sensor was triggered, check if the obstacle sensor was triggered (just in case you are pushing the oponent out of the ring), if it was, turn towards the edge of the ring until both floor sensors are triggered and only then back up. If obstacle sensor wasn’t triggered, then turn away from the edge. The attack function should monitor the obstacle sensors and push such way that both sensors are triggered at all times. Also monitor the floor sensors to know when you are at the edge and back up. The search function should turn around one way or another looking for the oponent while monitoring all sensors. Does it makes sense?
Cheers!
Wow. That’s really well
Wow. That’s really well thought and explained. I’m impressed!
Thanks. I have a few years
Thanks. I have a few years of Lego Sumo Robot competitions and I won a first place once and several second places. I kind of lost interest in sumo with regular robots, mostly because you have to build a robot that just does sumo and nothing else. To be performant, you need strong and fast motors, good gripping wheels and fast sensors. No delays in the code, has to react quickly to any situation. In theory sounds good, but in practice is hard to tweak it to perfection. Many have built several versions of their sumo robot to get to the result thay wanted.
very well described, shall
very well described, shall use it in the next coming month of building my robot.
thank you