Personal tools
Document Actions

python API 0.2.1 bug?

Up to General discussion

python API 0.2.1 bug?

Posted by oswald-p at May 08. 2007

here is a little script I wrote as a test:


The eyes should blink when head button is pressed but it doesn't work...


It doesn't seems to work  when a "cmd" class function is called from a "event" class one...



Is this a python API 0.2.1 bug or is there a problem in this script?


#!/usr/bin/python
# -*- coding: UTF8 -*-
# -----------------------------------------------
# Initalization of modules
# uses objects "tux" and "tss"
# -----------------------------------------------

import sys
sys.path.append('/opt/tuxdroid/api/python')
from tux import *

# -----------------------------------------------
# Script
# -----------------------------------------------

# initialization

tux.cmd.mouth_close()
tux.cmd.eyes_open()
tux.cmd.leds_off()

def blink():
tux.cmd.leds_blink(10,25)
# body
blink()
tux.event.on_head_bt_pushed=blink

# -----------------------------------------------
# End of script
# -----------------------------------------------
tux.event.wait_remote_bt(K_STANDBY,9999)
tux.destroy()



Attachments

Re: python API 0.2.1 bug?

Posted by Thomas Carpentier at May 08. 2007

hi oswald,


I have tested your script, and i've got the same problem.


I don't know where is the problem (script or python API), but if you make one action before "tux.cmd.eyes_blink(10,25)", like "time.sleep(1)", it work fine.


Re: python API 0.2.1 bug?

Posted by oswald-p at May 08. 2007

Thanks for you're help...


I tried to insert "time.sleep(1)" but this action doesn't seems to be recognize by the API...




time.sleep(1)
NameError: global name 'time' is not defined




Did I missed something?



Anyway, a more "complex" code like this should work but it doesn't:

def laugh():
    tux.cmd.leds_on();
    tux.cmd.mouth_open();
    tux.sys.wait(1);
    tux.cmd.sound_play(8,0);
    tux.sys.wait(1);
    tux.cmd.mouth_close();
    tux.cmd.leds_off();
# body
laugh()
tux.event.on_head_bt_pushed=laugh

Do you have any idea? (except that I am not a good coder at all ;))



O-p


Re: python API 0.2.1 bug?

Posted by Thomas Carpentier at May 08. 2007

oups!!






at the top of your script :


import time


Re: python API 0.2.1 bug?

Posted by oswald-p at May 08. 2007

I was full of hope... but no... it still doesn't work... I really think it is a major python API bug (it doesn't authorized any complex command of the droid)...


this exemple doesn't work... even adding the time.sleep function:


<pre>

#!/usr/bin/python
# -*- coding: UTF8 -*-
# -----------------------------------------------
# Initalization of modules
# uses objects "tux" and "tss"
# -----------------------------------------------

import sys
sys.path.append('/opt/tuxdroid/api/python')
from tux import *

import time
# -----------------------------------------------
# Script
# -----------------------------------------------

# initialization

tux.cmd.mouth_close()
tux.cmd.eyes_open()
tux.cmd.leds_off()


# label


def laugh():
    tux.cmd.leds_on();
    tux.cmd.mouth_open();
    tux.cmd.sound_play(8,0);
    tux.cmd.mouth_close();
    tux.cmd.leds_off();

# body


laugh()
tux.event.on_head_bt_pushed=laugh

# -----------------------------------------------
# End of script
# -----------------------------------------------
tux.event.wait_remote_bt(K_STANDBY,9999)
tux.destroy()


</pre>






Thank you for you're help Thomas...


If you have any other idea ;)






O-p


Powered by Ploneboard
You are here: Home Forum General discussion python API 0.2.1 bug?

Powered by Plone CMS, the Open Source Content Management System