Hello,please, can you explain how to use the roomba sensor in the jython for read the sensor values of a roomba 500?

roomba.sensor() doesnt work.

 

Thanks a lot.

 

Fabrice.

 

GroG

11 years 4 months ago

Could you describe what version your using ?  This should be in Help->About->version.  

Could you also describe what parts are working ?  Are you getting connected ? Do the motion forward, backward, etc work?

And what is your goal ?  To read the sensor values in Jython?  Do you have more goals ?

What Jython are you  currently using?  Can you post an example ?

fabrice2006

11 years 4 months ago

Everything work fine, foward,music, etc...execpt sensor

i have a roomba 520 and the version of myrobotlab is 893.20121027.1444 the lastest.

i want to try use slam and the FSM , Myrobotlab is fantastic and i m very happy to use it

 

Thanks a lot!

 

Fabrice.

 

fabrice2006

11 years 4 months ago

from org.myrobotlab.service import Roomba
from time import sleep
 
roomba = runtime.createAndStart("roomba2","roomba")
roomba.connect( "COM6" )
roomba.startup()
roomba.control()
roomba.playNote( 72, 10 )
roomba.sleep( 200 )
roomba.updateSensors()
roomba.stop()
sleep(1)
roomba.goForward(1000)
sleep(1)
roomba.goBackward(1000)
sleep(3)
roomba.playNote( 72, 10 )
roomba.stop()
print (roomba.updateSensors())
print (sensors())
roomba.disconnect()

That's great...

Although the first line I suspect is a spelling error - It wold be critical (unless you created the service through the gui) that the second paramter, the first letter is capitalized.

e.g.
roomba = runtime.createAndStart("roomba2","Roomba")

The first parameter is the name of the service - you can call it anything you want (although spaces are discouraged) ... the second parameter is the Type of Service ... 

As for the sensors... I looked into the code and there was a large "shake-up" regarding serial connections.. hoping everything still works after the update ;P

Theoretically, you should be able to access sensor data using the sensorsAsString method .
The Python would be like this :

roomba.updateSensors()
print ( roomba.sensorsAsString())

Hope it works for you... let me know if it does (or doesn't ;)

Looks like there's another method which pretty prints the sensor data..

roomba.printSensors()

P.S. change your avatar - you've graduated from scared gopher :D

fabrice2006

11 years 4 months ago

in Fact i dont know what method to use for reading sensor, maybe roomba.sensors() ? but it doesnt work...

fabrice2006

11 years 4 months ago

Now, the method "print ( roomba.sensorsAsString())" is working but the values are erronous:

this is a sample collect every 2 seconds when Roomba don't move and do nothing:

and the method "roomba.printSensors()" give me nothing

 

bump:__ wheel:___ wall:n cliff:l___ dirtL:0 dirtR:0 vwal:0 motr:0 dirt:0,0 remo:0 butt:0 dist:0 angl:0 chst:0 volt:0 curr:1083 temp:92 chrg:65255 capa:7429
 0 0 cb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 3b 5c fe e7 1d 5
5
bump:l_ wheel:lcr wall:Y cliff:lLRr dirtL:12 dirtR:44 vwal:-120 motr:19 dirt:12,44 remo:ffffff88 butt:fffffffd dist:11114 angl:-22253 chst:0 volt:20 curr:0 temp:-53 chrg:4876 capa:11400
 fe e7 1d 5 f3 a 88 13 c 2c 88 fd 2b 6a a9 13 0 0 14 0 0 cb 13 c 2c 88
6
bump:__ wheel:___ wall:n cliff:lLRr dirtL:43 dirtR:106 vwal:-120 motr:-3 dirt:43,106 remo:ffffffa9 butt:13 dist:0 angl:5120 chst:0 volt:51987 curr:3116 temp:-120 chrg:64811 capa:27305
 0 0 cb 13 c 2c 88 fd 2b 6a a9 13 0 0 14 0 0 cb 13 c 2c 88 fd 2b 6a a9
7
bump:__ wheel:___ wall:n cliff:____ dirtL:0 dirtR:0 vwal:0 motr:0 dirt:0,0 remo:0 butt:0 dist:0 angl:0 chst:4 volt:15196 curr:-281 temp:29 chrg:1523 capa:2696
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 3b 5c fe e7 1d 5 f3 a 88
8
bump:__ wheel:_c_ wall:n cliff:_L__ dirtL:0 dirtR:0 vwal:0 motr:0 dirt:0,0 remo:0 butt:0 dist:0 angl:0 chst:0 volt:0 curr:4 temp:59 chrg:23806 capa:59165
 14 0 0 cb 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 3b 5c fe e7 1d
9
bump:__ wheel:lcr wall:Y cliff:lLRr dirtL:19 dirtR:12 vwal:10 motr:-120 dirt:19,12 remo:2c butt:ffffff88 dist:-725 angl:27305 chst:19 volt:0 curr:5120 temp:0 chrg:51987 capa:3116
 5c fe e7 1d 5 f3 a 88 13 c 2c 88 fd 2b 6a a9 13 0 0 14 0 0 cb 13 c 2c
fin
 

thanks for your help

 

It does look pretty goofy...
Someone gave me a Roomba but it has a dead recharger...  I think I can try to hack charging it... it might live enough to let me debug...

I'll keep you posted..

GroG

11 years 4 months ago

The Roomba service is a wrapper of the RoombaComm library - http://hackingroomba.com/code/roombacomm/   -  putting it in the Service wrapper in MRL allows interactivity with many other Services.  Most methods are just pass through, although as time has progressed there has been changes here and there...   

I was wondering if you have successfully used sensors with the RoombaComm program directly ?

This information would help isolating the broken part...

Thanks,

GroG

fabrice2006

11 years 4 months ago

Grog, you're wright, the datas sensors with the RoombaComm program are erronous too... i think that the sensor data are formated with the 4xx Roomba and iCreate, Roombacomm was write for this type of roomba fist ,Juste the commands works...

 

 

What model do you have ?  Maybe we can find a link to the correct format and put it in...

Also,

what operating system are you using Windows 7 64 bit?

DWR & I have put together a working OpenNI and started 2 new services Gesture Recognition & Point Cloud... we are developing the services now..  Would you like to be involved?

fabrice2006

11 years 4 months ago

I have a roomba 520 model, and windows XP3 32bits.

I am very interesting by the 2 new services Gesture Recognition & Point Cloud, but i a have very poor programming skill...but i can make the tests with the kinect

 

 

 

Point cloud & Kinect have "begun" to work .. 

I haven't been able to find info on why a 520 is not returning good data..  

If' its messed up in RoombaCom, it is sure to be messed up in MRL.

Have you had any luck finding info on this issue?  Have you written to RoombaCom ?

fabrice2006

11 years 3 months ago

The problem is still there, It's good idea , i ll write to Roombacom for the eronous datas.