Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Has anyone used a Sharp distance Sensor (GP2D12)?

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
21 postsPage 1 of 21, 2
21 postsPage 1 of 21, 2

Has anyone used a Sharp distance Sensor (GP2D12)?

Post by onesandzeros » Wed Feb 14, 2007 6:48 pm

Post by onesandzeros
Wed Feb 14, 2007 6:48 pm

iam trying to get mine werking right now.
i tried using this code from http://www.robonova.de/store/support/index.php?_m=downloads&_a=downloadfile&downloaditemid=66

Code Example :
‘ calculation of measured value to metric distance in cm
‘ from Joerg Pohl, roboter-teile.de
DIM Gp2d12_val AS INTEGER
Read_gp2d12:
Gp2d12_val = AD (6) ‘ 6 here depends on AD port connection
IF Gp2d12_val < 4 THEN Gp2d12_val = 4 ‘Minimum setting
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0 ‘limit

For some reason, this code keep resetting my rn1 controller even if the sensor is removed.
i just wanted to do something simple like
IF Gp2d12_val < 100 THEN gosub wave_hands

Anyone have any idea how to make this work?
iam trying to get mine werking right now.
i tried using this code from http://www.robonova.de/store/support/index.php?_m=downloads&_a=downloadfile&downloaditemid=66

Code Example :
‘ calculation of measured value to metric distance in cm
‘ from Joerg Pohl, roboter-teile.de
DIM Gp2d12_val AS INTEGER
Read_gp2d12:
Gp2d12_val = AD (6) ‘ 6 here depends on AD port connection
IF Gp2d12_val < 4 THEN Gp2d12_val = 4 ‘Minimum setting
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0 ‘limit

For some reason, this code keep resetting my rn1 controller even if the sensor is removed.
i just wanted to do something simple like
IF Gp2d12_val < 100 THEN gosub wave_hands

Anyone have any idea how to make this work?
Last edited by onesandzeros on Wed Feb 14, 2007 11:11 pm, edited 1 time in total.
onesandzeros
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 99
Joined: Mon Apr 03, 2006 1:00 am

Post by DirtyRoboto » Wed Feb 14, 2007 8:16 pm

Post by DirtyRoboto
Wed Feb 14, 2007 8:16 pm

mmmm
mmmm
In servo's we trust!
DirtyRoboto
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 412
Joined: Tue Sep 19, 2006 1:00 am
Location: London

Post by onesandzeros » Thu Feb 15, 2007 1:27 am

Post by onesandzeros
Thu Feb 15, 2007 1:27 am

Read_gp2d12:
Gp2d12_val = AD (6) '6 here depends ON AD port connection

IF Gp2d12_val < 4 THEN Gp2d12_val = 4 'Minimum setting
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0 'limit
'IF Gp2d12_val = 0 THEN RETURN
IF Gp2d12_val < 4 THEN GOSUB standard_pose
IF Gp2d12_val > 4 THEN GOSUB bow_pose
GOSUB standard_pose
RETURN

with somethign near he bows
with nuthing in its range he maintains stardard_pose
just for testing ofcourse
just thought id say it isnt resetting anymore.
ill play with it more
Read_gp2d12:
Gp2d12_val = AD (6) '6 here depends ON AD port connection

IF Gp2d12_val < 4 THEN Gp2d12_val = 4 'Minimum setting
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0 'limit
'IF Gp2d12_val = 0 THEN RETURN
IF Gp2d12_val < 4 THEN GOSUB standard_pose
IF Gp2d12_val > 4 THEN GOSUB bow_pose
GOSUB standard_pose
RETURN

with somethign near he bows
with nuthing in its range he maintains stardard_pose
just for testing ofcourse
just thought id say it isnt resetting anymore.
ill play with it more
onesandzeros
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 99
Joined: Mon Apr 03, 2006 1:00 am

re: sharp sensor

Post by engineer » Thu Feb 15, 2007 6:00 am

Post by engineer
Thu Feb 15, 2007 6:00 am

boy, limor if you don't sticky this. I don't know what it means I pmed the author for an explanation hopr he answers.
boy, limor if you don't sticky this. I don't know what it means I pmed the author for an explanation hopr he answers.
engineer
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 129
Joined: Wed Aug 09, 2006 1:00 am
Location: northern california

Post by Humanoido » Fri Feb 16, 2007 6:21 am

Post by Humanoido
Fri Feb 16, 2007 6:21 am

it sounds poetic to me... Is it Haiku or Free Verse? been looking at code too long no doubt. let us know what you find out from the pm.

You could set up a range of values. Dimension the variable. Then do a number of beeps based on the returned value. It should work good for troubleshooting, then you know what numbers are being returned from the Sharp Distance Sensor. An LCD would be better. It could display the numbers.

Humanoido
it sounds poetic to me... Is it Haiku or Free Verse? been looking at code too long no doubt. let us know what you find out from the pm.

You could set up a range of values. Dimension the variable. Then do a number of beeps based on the returned value. It should work good for troubleshooting, then you know what numbers are being returned from the Sharp Distance Sensor. An LCD would be better. It could display the numbers.

Humanoido
Humanoido
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 574
Joined: Tue Dec 05, 2006 1:00 am
Location: Deep in the Heart of Asia

Post by onesandzeros » Fri Feb 16, 2007 8:29 am

Post by onesandzeros
Fri Feb 16, 2007 8:29 am

i do need a lcd display :(
---
so far it half works
--
Code: Select all
Read_gp2d12:
MUSIC "FEDC"
Gp2d12_val = AD (6)                  
IF Gp2d12_val < 4 THEN Gp2d12_val = 4    'min
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0   'limit
IF Gp2d12_val >= 0 AND Gp2d12_val  <= 24 THEN GOTO  forward_punch
IF Gp2d12_val >= 25 AND Gp2d12_val <= 49  THEN GOTO   ma_test1
IF Gp2d12_val >= 50 AND Gp2d12_val <= 74 THEN GOTO  bow_pose
IF Gp2d12_val >= 75 AND Gp2d12_val <= 99 THEN GOTO Dance_one
RETURN

--
i dont know anythign about programming so i need some help...
how do i get the sensor to loop, so it keeps checking the distance continuously, atleast while testing it.


sorry for the newbish questions
i do need a lcd display :(
---
so far it half works
--
Code: Select all
Read_gp2d12:
MUSIC "FEDC"
Gp2d12_val = AD (6)                  
IF Gp2d12_val < 4 THEN Gp2d12_val = 4    'min
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0   'limit
IF Gp2d12_val >= 0 AND Gp2d12_val  <= 24 THEN GOTO  forward_punch
IF Gp2d12_val >= 25 AND Gp2d12_val <= 49  THEN GOTO   ma_test1
IF Gp2d12_val >= 50 AND Gp2d12_val <= 74 THEN GOTO  bow_pose
IF Gp2d12_val >= 75 AND Gp2d12_val <= 99 THEN GOTO Dance_one
RETURN

--
i dont know anythign about programming so i need some help...
how do i get the sensor to loop, so it keeps checking the distance continuously, atleast while testing it.


sorry for the newbish questions
onesandzeros
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 99
Joined: Mon Apr 03, 2006 1:00 am

Post by Pev » Fri Feb 16, 2007 8:55 am

Post by Pev
Fri Feb 16, 2007 8:55 am

If you just wanty it to loop continually you could just add a goto at the end like this :

Read_gp2d12:
MUSIC "FEDC"
Gp2d12_val = AD (6)
IF Gp2d12_val < 4 THEN Gp2d12_val = 4 'min
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0 'limit
IF Gp2d12_val >= 0 AND Gp2d12_val <= 24 THEN GOTO forward_punch
IF Gp2d12_val >= 25 AND Gp2d12_val <= 49 THEN GOTO ma_test1
IF Gp2d12_val >= 50 AND Gp2d12_val <= 74 THEN GOTO bow_pose
IF Gp2d12_val >= 75 AND Gp2d12_val <= 99 THEN GOTO Dance_one

Goto Read_gp2d12
RETURN

That would mean that once you entered the routine you'd never leave it....

Pev
If you just wanty it to loop continually you could just add a goto at the end like this :

Read_gp2d12:
MUSIC "FEDC"
Gp2d12_val = AD (6)
IF Gp2d12_val < 4 THEN Gp2d12_val = 4 'min
Gp2d12_val = Gp2d12_val - 3
Gp2d12_val = 6787 / Gp2d12_val
IF Gp2d12_val > 100 THEN Gp2d12_val = 0 'limit
IF Gp2d12_val >= 0 AND Gp2d12_val <= 24 THEN GOTO forward_punch
IF Gp2d12_val >= 25 AND Gp2d12_val <= 49 THEN GOTO ma_test1
IF Gp2d12_val >= 50 AND Gp2d12_val <= 74 THEN GOTO bow_pose
IF Gp2d12_val >= 75 AND Gp2d12_val <= 99 THEN GOTO Dance_one

Goto Read_gp2d12
RETURN

That would mean that once you entered the routine you'd never leave it....

Pev
Carl
-------------------------
www.alt-view.co.uk
Pev
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 547
Joined: Sun Feb 26, 2006 1:00 am
Location: UK

Post by beermat » Sun Feb 25, 2007 10:11 pm

Post by beermat
Sun Feb 25, 2007 10:11 pm

Been playing around with the Sharp GP2D12 myself. I attached one to each arm, and programmed my RN to turn his head to look at anything 12-25cm away, on either side. Anything closer than 12cm, it attacks. If something is detected on both sides, RN will turn his head toward / attack the closest of the two objects. Here's the video. No Capn Crunch cardboard boxes were harmed in the making of this video:

phpBB [media]
Been playing around with the Sharp GP2D12 myself. I attached one to each arm, and programmed my RN to turn his head to look at anything 12-25cm away, on either side. Anything closer than 12cm, it attacks. If something is detected on both sides, RN will turn his head toward / attack the closest of the two objects. Here's the video. No Capn Crunch cardboard boxes were harmed in the making of this video:

phpBB [media]
Last edited by beermat on Mon Feb 26, 2007 12:55 am, edited 2 times in total.
beermat
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 137
Joined: Sun Jul 23, 2006 1:00 am

Post by Orac » Sun Feb 25, 2007 10:54 pm

Post by Orac
Sun Feb 25, 2007 10:54 pm

Fantastic, I'll have to play around with a pair of them myself :)
Fantastic, I'll have to play around with a pair of them myself :)
Orac
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 299
Joined: Wed Feb 21, 2007 12:46 am
Location: UK, Near Aylesbury

Post by beermat » Sun Feb 25, 2007 11:09 pm

Post by beermat
Sun Feb 25, 2007 11:09 pm

I'm now working on a set of arm moves that allows my RN to take a set of readings all around - left, right, front-left, front-right, back-left and back-right - and then determine which reading detected the closest object......
I'm now working on a set of arm moves that allows my RN to take a set of readings all around - left, right, front-left, front-right, back-left and back-right - and then determine which reading detected the closest object......
beermat
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 137
Joined: Sun Jul 23, 2006 1:00 am

Post by Pev » Sun Feb 25, 2007 11:20 pm

Post by Pev
Sun Feb 25, 2007 11:20 pm

Nice One lol

After I tried this http://robosavvy.com/forum/viewtopic.php?t=166&highlight=spare I went down the Sharp sensor route and have to confess it was a lot more successful than the sonar

Pev
Nice One lol

After I tried this http://robosavvy.com/forum/viewtopic.php?t=166&highlight=spare I went down the Sharp sensor route and have to confess it was a lot more successful than the sonar

Pev
Carl
-------------------------
www.alt-view.co.uk
Pev
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 547
Joined: Sun Feb 26, 2006 1:00 am
Location: UK

Post by beermat » Mon Feb 26, 2007 4:00 am

Post by beermat
Mon Feb 26, 2007 4:00 am

Yeah, the sharp sensor is a lot better than the sonar (I played around with the sonar for a while), and it is also more accurate at measuring the distance of an object.

Check out the video below - my Robonova moves his arms around and takes 6 sensor readings on his left, right, front left, front right, rear left and rear right, and then verbally reports (via the Quadravox chip hack) the location where it detected the closest object, if it found any at all within range. Audios a bit low, I'm afraid, so you might need to increase your volume:

phpBB [media]
Yeah, the sharp sensor is a lot better than the sonar (I played around with the sonar for a while), and it is also more accurate at measuring the distance of an object.

Check out the video below - my Robonova moves his arms around and takes 6 sensor readings on his left, right, front left, front right, rear left and rear right, and then verbally reports (via the Quadravox chip hack) the location where it detected the closest object, if it found any at all within range. Audios a bit low, I'm afraid, so you might need to increase your volume:

phpBB [media]
beermat
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 137
Joined: Sun Jul 23, 2006 1:00 am

Post by DerekZahn » Mon Feb 26, 2007 4:03 am

Post by DerekZahn
Mon Feb 26, 2007 4:03 am

Ha, that is excellent!
Ha, that is excellent!
DerekZahn
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 141
Joined: Wed Mar 16, 2005 1:00 am
Location: Boulder CO, USA

Post by beermat » Mon Feb 26, 2007 4:46 am

Post by beermat
Mon Feb 26, 2007 4:46 am

Thanks! (and great work on Bing 3, BTW - following your progress with much interest!)

Actually, I just realized the moves in the video are inefficient, doing front left, then front right, then rear left, then rear right. For each one, I added a 250ms pause to let the arm rest in place before reading the sensor. I originally did it an arm at a time to avoid clashing arms, but now I have changed it to read front left / rear right simultaneously, and then rear left / front right simultaneously. Much smoother, and a much faster way (half the time) to get a positional location on the enemy from 6 key spots with 2 sensors :)
Thanks! (and great work on Bing 3, BTW - following your progress with much interest!)

Actually, I just realized the moves in the video are inefficient, doing front left, then front right, then rear left, then rear right. For each one, I added a 250ms pause to let the arm rest in place before reading the sensor. I originally did it an arm at a time to avoid clashing arms, but now I have changed it to read front left / rear right simultaneously, and then rear left / front right simultaneously. Much smoother, and a much faster way (half the time) to get a positional location on the enemy from 6 key spots with 2 sensors :)
beermat
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 137
Joined: Sun Jul 23, 2006 1:00 am

Post by subpilot » Mon Feb 26, 2007 6:11 am

Post by subpilot
Mon Feb 26, 2007 6:11 am

That is extremely cool. Not far from being able to have autonomous battles. :P
I also messed with sonar and it was hit or miss but I think if think if you integrate both the sonar and IR returns you can get very accurate, unambiguous ranges.
That is extremely cool. Not far from being able to have autonomous battles. :P
I also messed with sonar and it was hit or miss but I think if think if you integrate both the sonar and IR returns you can get very accurate, unambiguous ranges.
subpilot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 146
Joined: Sat Feb 25, 2006 1:00 am
Location: Lake Arrowhead, Ca,USA

Next
21 postsPage 1 of 21, 2
21 postsPage 1 of 21, 2