GLOBAL SITE AUSTRALIAN SITE

[SOLVED] Obstacle detection help | EdWare graphical programming | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic3
[SOLVED] Obstacle detection help
October 20, 2016
2:56 pm
Caleb
Member
Members
Forum Posts: 12
Member Since:
September 5, 2016
sp_UserOfflineSmall Offline

I’m trying to learn how to do IR object detection.

I keep getting duplicate events triggered by my If Else blocks.

my goal is to have the robot travel forward until it encounters an object, then beep and turn around 180 degrees, pause for a second or two, then travel back the way it came.  

This code results in the robot beeping, spinning, pausing facing away from the object, then beeping and spinning back toward the object.

I’ve tried this with both the web version and the chromebook app version with both V1 and V2 robots.

any insights on what I might be doing wrong?

(image removed, broken link)

October 20, 2016
3:16 pm
Caleb
Member
Members
Forum Posts: 12
Member Since:
September 5, 2016
sp_UserOfflineSmall Offline

I just tried the example program “Watch out! There is an Obstacle!” with an added beep and a longer wait time for the turn…

I’m getting the same double firing effect…the IF statement is being read as positive twice, even when there is no obstacle the second time.

This happens with both V1 and V2 robots.

I am at a loss here

Caleb

October 21, 2016
10:04 am
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOnlineSmall Online

Hi!

This is to do with how Edison senses the world.

While Edison is running, all of Edisons sensors (that have been turned on, some are always on) are constantly looking for a change in environment.

When a change in environment is detected Edison sets a value in memory, called a flag.

The if statements and the wait events look at these flags rather than looking directly at the sensor.

Everytime a flag is looked at, it gets cleared

In your case, milliseconds after the if statement has started running the positive line, Edisons obstacle detectors reset the flag to “seen” because Edison has not had enough time to turn away from the obstacle. Now that the flag is set, it will stay set until read again, which in your program is the next if statement.

To fix this, simply add a new variable, called junk (or whatever you like), type: 0-255

and right after the stop in the if statement place down a blue “Detect obstacle” block. This block will read the obstacle detection flag, store it into the otherwise unused variable and clear the flag.

October 21, 2016
3:37 pm
Caleb
Member
Members
Forum Posts: 12
Member Since:
September 5, 2016
sp_UserOfflineSmall Offline

Thanks Ben!

That works perfectly…and it makes sense to boot!

You sir have restored my faith in our cute little orange overlords.

Keep up the good work!

Caleb

October 21, 2016
8:51 pm
arvin-edison
Member
Members
Forum Posts: 12
Member Since:
October 9, 2016
sp_UserOfflineSmall Offline

Caleb said
Thanks Ben!

That works perfectly…and it makes sense to boot!

You sir have restored my faith in our cute little orange overlords.

Keep up the good work!

Caleb  

Hi Caleb. I hope you don’t mind posting a photo of your new codes. I’ll just show it to my students as an example. Thank you.

October 22, 2016
6:41 am
Caleb
Member
Members
Forum Posts: 12
Member Since:
September 5, 2016
sp_UserOfflineSmall Offline

No problem

I’ve found that a dual drive right spin at speed 5 with a 0.5 second timer works well for a 180 turn on the V2 – FYI.  The V1 is a little slower…so you’d have to tweak the timing a bit.

best of luck with your students.

I’m still figuring out my curriculum.  I’ll post ideas as I work them out.

(image removed, broken link)

June 22, 2017
4:12 am
Bill
Member
Members
Forum Posts: 4
Member Since:
June 22, 2017
sp_UserOfflineSmall Offline

Why doesn’t it work to add a blue “detect obstacle” block right in front of the “if” block???

It kind of works.  It just pushes up against the obstacle for quite a while and then turns around.  Why does it push against the wall for a longer time than the solution picture program does?

So when does the flag get changed?  Does it only change after being looked at by an if block or blue detect obstacle block?  

So how do I go about telling it exactly when I want it to look for an object, and can I store the result of the flag #and use the flag # 0,64,72,80,96 for later use in a variable?  In the programming app online, it does not let me store the results of the blue “detect obstacle” block as 96 into a variable.

June 22, 2017
4:28 am
Bill
Member
Members
Forum Posts: 4
Member Since:
June 22, 2017
sp_UserOfflineSmall Offline

I am trying to code the edison to solve a maze of books on the floor by following the left wall.  All angles will be 90 degrees.  There is no where that I can find a place to see other programs others have shared or made.  This would be an nice feature.

Could you post your programming for “clap controlled driving” in the tutorial on page 6.  What would it look like if done using the app with blocks?

I have read your replay about flags many times above about flags, but for some reason I am not understanding it.

I don’t understand what you are saying when you said this —–>>>>>

When a change in environment is detected Edison sets a value in memory, called a flag.

The if statements and the wait events look at these flags rather than looking directly at the sensor.

Everytime a flag is looked at, it gets cleared

In your case, milliseconds after the if statement has started running the positive line, Edisons obstacle detectors reset the flag to “seen” because Edison has not had enough time to turn away from the obstacle. Now that the flag is set, it will stay set until read again, which in your program is the next if statement.

To fix this, simply add a new variable, called junk (or whatever you like), type: 0-255

and right after the stop in the if statement place down a blue “Detect obstacle” block. This block will read the obstacle detection flag, store it into the otherwise unused variable and clear the flag.

June 22, 2017
12:04 pm
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOnlineSmall Online

Hi Bill

There seems to be a little confusion here, firstly, Flags and Variables are different things:

A Flag is a section of memory that only Edison has direct access to. 

A Variable is a section of memory that a user can use to store any data

While Edison is running a program, the instant Edison see’s an obstacle, Edison sets the “Obstacle Flag” to “Seen an Obstacle” then if the program has an IF block, a WAIT EVENT block or a LOOP that uses “Event: Any Obstacle Detected” that block will look at the “Obstacle Flag” if the flag is set to “Seen an Obstacle” then the block will do the right action (IF block takes the top track, WAIT EVENT stops waiting, LOOP stops looping). The block then sets the “Obstacle Flag” back to “No Obstacle detected”

This is works the same way for “Obstacle ahead”, “Obstacle Left” and “Obstacle Right”

If your Edison is pushing up against obstacles rather than seeing them, you need to calibrate Edison’s obstacle detection sensor. There is a barcode and instructions on this in both EdBook1 and EdBook2

You can find the codes used in both EdBook1 and EdBook2 in the Load menu of http://edwareapp.com/#

June 29, 2017
1:39 pm
Bill
Member
Members
Forum Posts: 4
Member Since:
June 22, 2017
sp_UserOfflineSmall Offline

Thanks so much.  That was very helpful.  I also discovered that sometimes it is beneficial to make the robot stop and wait .5 seconds.  This gives edison enough time to check out its surroundings with its infrared sensors and then send it to a flag.  It seems to take just under .5 seconds for the flag value to get refreshed or changed to the new state that was detected.

Once the flag has been changed now when the infinite loop starts over and goes to the IF statement, it will be reading an updated flag rather than the same flag value which hasn’t changed because edison refreshes the flag state just under every .5 seconds.  

I have now written a program to follow the left wall of a maze and solve it.  I have also had it go around weird shaped objects.  I learned a lot.  Thanks for your help.  I initially began have the robot do it all with 90 degree angles and pausing, but then I understood the value of doing it in very small increments instead.  I was able to use the if statement to do all of it, and then I discovered how powerful just using the start new event program and did it with that instead.  

Thanks again.

  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Country

Pin It on Pinterest

Share This