Pages: [1]   Go Down
Author Topic: Trying out a flowchart 'follow me' algorithm for my robot  (Read 1761 times)
0 Members and 1 Guest are viewing this topic.
Charleston, SC
Offline Offline
Full Member
***
Karma: 1
Posts: 144
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
**Updated stuff toward the end of this post**
Before I 'try' and put together some code for my first directive/algorithm for my bot (just a simple..? follow me algorithm), I thought I try and put together a flowchart on what exactly I want it to do.
My bot has 2 PIR sensors on the front(left and right sides) as well as 2 PING sensors(also left and right sides).
I would appreciate any suggestions, ideas & corrections.
I just set the min. distance threshold for the front PING sensors at 36".
I'm a bit unsure on where to put the PING sensor decisions, and what to do if the range distance is under what is set.  To stay put/standby? or to back up a bit (12"), or until the minimum threshold is achieved.?


t
« Last Edit: July 03, 2012, 01:00:13 pm by thomas3120 » Logged


UK
Offline Offline
Shannon Member
****
Karma: 219
Posts: 12374
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't actually handle the 'both' case where you test for left/right/both/none. I assume it means that you are pointing the right way and should go into your range check, but the algorithm as described would start turning in an arbitrary direction.

Gut feeling is that the two checks for PIR sensors picking up motion should be the same check i.e. your initial state is the same as the state when you are clear of obstacles and motion.

I assume you mean to turn towards the motion and then try to move to within 36", but the logic as described would not stop turning if you were already within 36".

What do you intend your 'bot to do about motion detection while it is moving forward? It seems to me that it should always steer towards detected motion but what should it do if there is nothing in range and it stops detecting motion?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Charleston, SC
Offline Offline
Full Member
***
Karma: 1
Posts: 144
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't actually handle the 'both' case where you test for left/right/both/none. I assume it means that you are pointing the right way and should go into your range check, but the algorithm as described would start turning in an arbitrary direction.

Gut feeling is that the two checks for PIR sensors picking up motion should be the same check i.e. your initial state is the same as the state when you are clear of obstacles and motion.

I assume you mean to turn towards the motion and then try to move to within 36", but the logic as described would not stop turning if you were already within 36".

What do you intend your 'bot to do about motion detection while it is moving forward? It seems to me that it should always steer towards detected motion but what should it do if there is nothing in range and it stops detecting motion?


Thanks for the response Peter.
Below I updated my flowchart...hopefully a bit better.

Yeah, shortly after I posted, I noticed the 'both' condition for the motion sensors.
I may have to modify the 'left, right, both & none' condition with the decision 'are both motion sensors picking up motion?'

On the turning part, I wanted the bot to turn (left or right) depending on what sensor picks up motion, to turn until both motion sensors are picking up motion.  Then stop turning & proceed.

On the PING min. threshold, my intention was to check and see if the min. threshold was greater or equal to (36") to proceed (with both motion sensors active).
And also stay at that threshold while following or when the person/motion stops.

When there's no motion, atm, just stop.  But later possibly search for motion by turning one way 360deg. or traveling in a 'X' distance radius... 
But for now, I think just stop when there's no motion on either left ot right PIR sensors...unless maybe one sensor picks up motion,
then go through the routine to find where both motion sensors are active or pick up motion.


Logged


UK
Offline Offline
Shannon Member
****
Karma: 219
Posts: 12374
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you intend to happen in the case where you detect motion, turn towards it and start moving forwards, and do not detect any further motion? Are you going to stop (and try to reacquire somehow) or keep going forwards blindly in the hope you will run into something eventually?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Georgina Ontario
Offline Offline
Sr. Member
****
Karma: 5
Posts: 437
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To model this you should really consider a State Machine  (HSM or an FSM) -- I have updated my training post with a few more links.

http://arduino.cc/forum/index.php/topic,112462.0.html

Flow charts do not always capture the nuances of a complicated design.

Logged

Just another Hacker

Charleston, SC
Offline Offline
Full Member
***
Karma: 1
Posts: 144
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you intend to happen in the case where you detect motion, turn towards it and start moving forwards, and do not detect any further motion? Are you going to stop (and try to reacquire somehow) or keep going forwards blindly in the hope you will run into something eventually?

Hey Peter,
I was hoping, from the flowchart, that if no more motion was detected it would stop and stay put in the 'Detect motion?' loop until there is motion detected (you can see where the 'move foward' condition loops back up to 'Detect motion?' decision).
Having it go foward blindly in the hope it will run into something, is part of another algorithm I had planned at a later time: 'Search & Destroy'.....hehe
...just kidding smiley-wink

In all seriousness, definitely did not intend to have it go fowards blindly until hitting something.  I hope that's not what the flowchart is doing?


@WillR,
Thanks for the information Will smiley
I'll check out the link and info you posted.
« Last Edit: July 03, 2012, 12:41:41 pm by thomas3120 » Logged


Charleston, SC
Offline Offline
Full Member
***
Karma: 1
Posts: 144
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If anyone is interested, just found an interesting PDF on flowcharts (and microcontrollers):
http://www2.tech.purdue.edu/eet/courses/eet209/Lecture/L7%20Algorithms%20and%20Flowcharts.pdf
Pretty interesting read.  Just at a glance, now I can see where I may have left out some important stuff...

Also found this (also used in conjuction with C++):
http://www.allclearonline.com/applications/DocumentLibraryManager/upload/program_intro.pdf

Here is another great source of info that includes designing statecharts (as WillR recommended)
http://publib.boulder.ibm.com/infocenter/rhaphlp/v7r6/index.jsp?topic=%2Fcom.ibm.rhp.uml.diagrams.doc%2Ftopics%2Frhp_c_dm_designing_flow_charts.html

Looks like I have a bit of reading to do hehe..
Appreciate the replies & suggestions,
thanks again.
Logged


UK
Offline Offline
Shannon Member
****
Karma: 219
Posts: 12374
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I was hoping, from the flowchart, that if no more motion was detected it would stop and stay put in the 'Detect motion?' loop until there is motion detected (you can see where the 'move foward' condition loops back up to 'Detect motion?'


I suggest you find out how your motion sensors behave. My experience of PIR sensors is that they're highly sensitive to being moved and need to be stationary (and have time to settle) before they will detect motion. Also that they are motion sensors not presence sensors, so if you intend the bot to detect you and follow you, I suspect you'll need to keep waving at it to maintain its interest.

(You can describe this type of behaviour in many ways including FSM and flow charts - to me a FSM seems like a more natural way to express this type of behaviour because I anticipate that your design will have several modes of operation depending what the sensors tell it. But you can describe it using a flow chart if you find that easier to understand. The important thing is to be clear in your own mind what behaviour you're trying to achieve.)
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Charleston, SC
Offline Offline
Full Member
***
Karma: 1
Posts: 144
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I suggest you find out how your motion sensors behave. My experience of PIR sensors is that they're highly sensitive to being moved and need to be stationary (and have time to settle) before they will detect motion. Also that they are motion sensors not presence sensors, so if you intend the bot to detect you and follow you, I suspect you'll need to keep waving at it to maintain its interest.

(You can describe this type of behaviour in many ways including FSM and flow charts - to me a FSM seems like a more natural way to express this type of behaviour because I anticipate that your design will have several modes of operation depending what the sensors tell it. But you can describe it using a flow chart if you find that easier to understand. The important thing is to be clear in your own mind what behaviour you're trying to achieve.)

I agree about the sensitivity, it's a bit high on mine (by Parallax).  So far I may try a few options(or a combination):
- 1st: Adding some tape on the lense and allow only the outer, upper quadrant to detect motion on either side PIRs.
- 2nd: As someone on the boards suggested, add a small tube, possibly a thin walled PVC tube to 'narrow' the sensing range.
- 3rd: change out a couple capacitors & resistors on the PIR sensor itself to reduce the sensitivity (saw an Adafruit? tutorial on their PIR sensor)

I think I went to flow charts because of a FORTRAN class I took 12+ years ago, and some mech. engineering classes as well...they had a brief chapter or two on flowcharts.

Thanks again for the help Peter
Logged


Pages: [1]   Go Up
Jump to: