I have this running on an Arduino sketch. Now how do I get this into InMoov so the robot will react to something in range of the sensor?

GroG

9 years 8 months ago

Great Question Bhouston.. 

I would recommend getting it working in MRL - then getting it to work in InMoov

Assuming you have the latest MRL...

Try the following script ..

 

sr04 = Runtime.start("sr04", "UltrasonicSensor")
 
# there are 2 ways to get range data
# 1 is a blocking call - the other is event driven
# we are going to use even driven because it's preferrable
 
# tell the sr04 range finder to send its range to python
sr04.addPublishRangeListener(python)
 
# here is the "callback" 
def publishRange(distance):
  print distance
 
# attach the sr04 to the Arduino and connect MRL to the
# Arduino - input is (input port, trigger pin, echo pin) - 
# but it sounds as if the trigger and echo pin are tied together ?
# sr04.attach("COM4", 8, 7)
 
# try this way trigger & echo pin the same
sr04.attach("COM4", 7, 7)
 
# start the process of ranging
sr04.startRanging()
 
# get a bunch of ranges and print them in the publishRange function
# for 10 seconds
sleep(10)
 
# done
sr04.stopRanging()
 
 
 
 
Theoretically (and its very theoretical) - the range should be printed in the python tab - oh yeah and the sr04 tab will have a bar which represents range..
I HAVE NOT TESTED THIS SCRIPT - I HAVE NOT DONE ANY PYTHON .. but I have tested this functionality in Java ..  it was a quick attempt to get you what you needed - but I can even validate the Python at the moment...
 
If it does not work, you know the procedure :)
send a noWorky and our crack team of monkeys will be right on it..

bhouston

9 years 8 months ago

I have to take an unexpected trip to the East coast, so I'll play with this when I get back.