0

I'm not usually one to ask for help, but after weeks of trying to get this to work, I'm reaching out for help as a ditch attempt.

I've been having trouble with programming my LEGO Sumo bot. Because of this, I started to learn the program more and more. I've still had this one problem though. How would I program my sumo bot to utilize opposite facing ultrasonic sensors? The closest I've gotten was having two normal 'spin seek destroy back up' loops running in parallel with another loop of the same idea only with opposite directions and the other sensor ports.

The problem with that is the robot seems to want to do each seek and destroy loop in a pattern. Front, back, front, back, and so on. This presents problems and negates the entire purpose of having both sensors. The other problem is when the back ultrasonic sensor is triggered first, the robot wants to spin in circles to seek and move the direction of the back ultrasonic at the same time. So it will jump backwards and turn back and forth in a stuttering motion.

My hopes is to have the robot spin and move toward an object that the ultrasonic sensor sees. Regardless of which ultrasonic sensor is triggered. After the target is seen the robot will move until the light sensor sees white, and move in the opposite direction.

I can provide more information if necessary.

I hope I'm okay in asking this here, it really is my last effort.

This is the full code: full code

This is the code inside each loop: inside each loop

amo
  • 4,082
  • 5
  • 28
  • 42
  • Can you provide the code? – drum Jul 13 '14 at 04:23
  • NXT-G, RobotC, or what other language are you using? – Andrew Jul 13 '14 at 04:46
  • It sounds like you need to check both sensors in one "spin seek destroy back up" loop. – Andrew Jul 13 '14 at 04:48
  • @SantaClaus I'm not sure what you mean by checking both sensors in one loop. Would that not make it impossible to tell the robot which direction to move if both sensors are getting checked in one loop? – Brandon Sidoti Jul 13 '14 at 05:27
  • Can you rather update your question with these pictures? – drum Jul 13 '14 at 05:28
  • @drum I tried, but it says I need 10 reputation to post pictures. Here is the code I currently have working. Well, sort of working. The second picture is what is on the top and bottom of the split. (The outside loop seemed to cut it off) ![full code](http://i750.photobucket.com/albums/xx145/Sodizzle3113/Screenshot3.png) ![inside each loop](http://i750.photobucket.com/albums/xx145/Sodizzle3113/Screenshot4.png) – Brandon Sidoti Jul 13 '14 at 05:37

1 Answers1

0

Check both sensors in a loop and use the output of both sensors to decide which action to take.

iheanyi
  • 3,107
  • 2
  • 23
  • 22