Sumoeyes on EV3 example
 Software and Programming Related   Started by Jimmy Kan   2017-04-16 17:37:03 -04:00   Comments: 13    Viewed: 417

  1. Jimmy Kan
    Jimmy Kan Member

    Hello, I have built a robot with Sumoeyes v2, download it example program it worked but I have added a bumper switch below the eyes sensor but don's know how modify the code if the robot is bump into an object it will back up and continue while using the sumoeyes to detect object.

    SumoEyes EV3 Sample program here




    Jimmy Kan, 2017-04-16 17:37:03 -04:00
  2. setht
    setht Member Staff Member
    Good morning!

    I'm glad you got the example program running. Which of the three examples are you trying to extend? What is the exact behavior of the robot you are hoping to achieve?

    Seth Tenembaum
    setht, 2017-04-17 08:54:13 -04:00
  3. Jimmy Kan
    Jimmy Kan Member
    How do I upload a file here?

    Jimmy Kan, 2017-04-17 23:05:38 -04:00
  4. setht
    setht Member Staff Member
    This forum currently does not offer that option. Screenshots could help if it can't be explained with words. Otherwise if you do wish to share a file I suggest you use a file-sharing site like Google Drive or Dropbox. Thanks!
    setht, 2017-04-18 09:04:14 -04:00
  5. Jimmy Kan
    Jimmy Kan Member
    Jimmy Kan, 2017-04-18 13:39:01 -04:00
  6. setht
    setht Member Staff Member
    So first off you want an infinite loop, which you have! This will keep doing something over and over again. In this case it reads the SumoEyes and moves some distance based on that. In addition to checking the SumoEyes, let's add a check for the touch sensor. If you add another Switch block at the end of your unlimited loop, you can add a motor block to drive backwards if the touch sensor is pressed.

    setht, 2017-04-18 14:27:16 -04:00
  7. Jimmy Kan
    Jimmy Kan Member
    I did try putting that infront and parrale of Sumoeye sensor, it didn's work. Will try this tonigt!

    Thanks for a quick solution!

    Jimmy Kan, 2017-04-18 14:33:19 -04:00
  8. setht
    setht Member Staff Member
    You're welcome! When you tried before and it didn't work, what happened instead? If this program doesn't work for you let me know how it doesn't work and I'll help you through the thinking of how to fix it.
    setht, 2017-04-18 15:08:05 -04:00
  9. Jimmy Kan
    Jimmy Kan Member
    ok, with this updated code, the robot keep rotating and not going forward, the bumper (touch sensor) seems to work but there was a short delay before it backing up.

    Jimmy Kan, 2017-04-18 22:25:35 -04:00
  10. setht
    setht Member Staff Member
    Great! I'm glad you were able to try it out and see what happens. I did expect the delay, let's think about why that happens. Right now, what is the program doing? First it checks the SumoEyes; then it moves forward, left, or right for (about) 1 rotation; and finally it checks the bumper and might move backwards 3 rotations; repeat. Notice what happens when the bumper is not hit: the robot will move for about 1 rotation in some direction. During this time, it is not checking the touch sensor. This is because it is waiting for the motor block to finish its movement before continuing with the program.

    How can we fix this? One way would be to make it move less than 1 rotation, maybe, say, 1/4 rotation, each time. This way it will move a small distance, then check the touch sensor, move a little bit more, check again, etc. Or, even better, why not constantly check‽

    Think about the overall structure of the program. First, check the touch sensor. If it is pressed, move backwards, otherwise go ahead and check the SumoEyes. Notice it will move backwards a set distance once it bumps in to something. However, if it isn't, there is no set amount for how long it will move in any direction. It will read the SumoEyes, start moving, for example, left, after then right away check again. It might continue moving left, change directions, or move backwards a set distance to get away from the obsticle it ran in to.

    I'm not quite sure what you had in mind when an obsticle is detected in the front zone, sorry if I made a mistake with any of the directions for those motor blocks. I hope this helps you learn to think like a programmer! You may also want to add a wait block so it waits maybe a quarter of a second before checking again. I left it out because I was running out of space on my monitor and wanted to fit it all in one screenshot, but you probably don't want to check too quickly. Happy coding!
    setht, 2017-04-19 11:01:29 -04:00
  11. Jimmy Kan
    Jimmy Kan Member
    Hi Setht, I am not new to programming but just a hobby, have been working on Arduino for awhile, Lego EV3 is new to me, started to play with it just a couple weeks after someone gave it to me. I have been working on this example by placing the touch sensor block in many different ways but no suceess. Will try this latest code of yours.

    Thanks for helpping!

    Jimmy Kan, 2017-04-19 13:41:46 -04:00
  12. setht
    setht Member Staff Member
    Oh I'm so sorry, I certainly did not mean to offend you! I'm glad you've seen what a joy programming can be :) This data-flow-based programming language can be quite different from your standard text programming language, bit it is very cool once you get a feel for how it works.
    setht, 2017-04-19 13:51:36 -04:00
  13. Jimmy Kan
    Jimmy Kan Member
    Hi Setht,
    This latest code worked perfectly, I thought I had setup the same way before but didn't work.
    It's interesting doing program this way, good way to help kids learn how to code.

    Thank You!

    Jimmy Kan, 2017-04-19 22:34:16 -04:00
  14. (You must log in or sign up to post here)

Log in | Sign up
Tems & Conditions!