Difference between revisions of "Tux Droid"

From YobiWiki
Jump to navigation Jump to search
m (Reverted edits by Etegohy (Talk) to last revision by PhilippeTeuwen)
 
(15 intermediate revisions by 2 users not shown)
Line 11: Line 11:
 
* [http://www.kysoh.com Keep Your Sense Of Humor] Commercial site
 
* [http://www.kysoh.com Keep Your Sense Of Humor] Commercial site
 
* [http://www.tuxisalive.com/ Tux is alive!] Community site ([http://www.tuxisalive.com/recently_modified recent changes])
 
* [http://www.tuxisalive.com/ Tux is alive!] Community site ([http://www.tuxisalive.com/recently_modified recent changes])
* [http://www2.tux-is-alive.com/wiki/Main_Page Tux Droid development wiki] (should disappear after transfer)
+
* [http://wiki.tuxisalive.com/index.php/Main_Page Tux Droid development wiki]
 
* [http://193.190.210.23/irclogs/index.html Logs] of the IRC channel #tuxdroid on irc.freenode.net
 
* [http://193.190.210.23/irclogs/index.html Logs] of the IRC channel #tuxdroid on irc.freenode.net
 
* Blogs aggregated [http://www.tuxisalive.com/siteplanet_view/ flatted] or [http://www.tuxisalive.com/tux-droid-forum/Members/jaguarondi/planet/ summarized]
 
* Blogs aggregated [http://www.tuxisalive.com/siteplanet_view/ flatted] or [http://www.tuxisalive.com/tux-droid-forum/Members/jaguarondi/planet/ summarized]
Line 41: Line 41:
 
Or using the native alsa layer:
 
Or using the native alsa layer:
 
mplayer -ao alsa:device=plughw=2.0 http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3
 
mplayer -ao alsa:device=plughw=2.0 http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3
  +
Or using esound:
  +
esd -d plughw:2,0
  +
mplayer -ao esd http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3
  +
  +
XMMS:
  +
* Select alsa output plugin -> configure -> type "plughw:1,0" manually and select software volume control.
  +
* Select OSS output plugin -> configure -> USB but then no volume control is possible.
  +
* Select esound output plugin and launch esd as shown above
   
 
===Reflashing===
 
===Reflashing===
Line 70: Line 78:
 
<br>Note that it would be easier if there was a CLOSE_EYES_CMD
 
<br>Note that it would be easier if there was a CLOSE_EYES_CMD
 
<br>I solved it by using the seq "OPEN_EYES_CMD, BLINK_EYES_CMD, 1, 0"
 
<br>I solved it by using the seq "OPEN_EYES_CMD, BLINK_EYES_CMD, 1, 0"
 
Note that for such personalization, only eep file is required but if you plan to use the hex file, I noticed that there was a problem in the versioning structures order, you've to some files and invert some lines:
 
 
firmware/tuxaudio/trunk/main.c invert lines 42 and 44
 
firmware/tuxcore/trunk/global.c invert lines 53 and 55
 
   
 
===Remote Control===
 
===Remote Control===
Line 96: Line 99:
 
** tuxttsdaemon button desync
 
** tuxttsdaemon button desync
 
* wrong comments in commands.h 0x1A & 0x1B control both leds
 
* wrong comments in commands.h 0x1A & 0x1B control both leds
  +
* we should have save/restore raw commands for led & position
   
 
===Misc Questions===
 
===Misc Questions===
 
* How to control the volume by software?
 
* How to control the volume by software?
  +
* How tuxes see each other? They ping constantly through IR (from the right eye) as it can be seen through a webcam.
  +
* How a dongle and a tux are paired? What if many tuxes are present simultaneously?
  +
 
===Misc===
 
===Misc===
 
* Voice recognition
 
* Voice recognition
 
** Here is a project to help open source developers make their project work better by submitting your speech samples to add them to a speech corpus used to train 4 open source projects that work on that task: http://www.voxforge.org/home
 
** Here is a project to help open source developers make their project work better by submitting your speech samples to add them to a speech corpus used to train 4 open source projects that work on that task: http://www.voxforge.org/home
  +
** Here is the wiki page about speech recognition on the official's Tux droid development wiki: http://wiki.tuxisalive.com/index.php/Speech_recognition
   
 
===Python===
 
===Python===
 
====Examples====
 
====Examples====
 
I don't know python so for those who don't know it neither, here's a small snippet to start with (from Fosdem presentation):
 
I don't know python so for those who don't know it neither, here's a small snippet to start with (from Fosdem presentation):
  +
<source lang=python>
<pre>
 
 
#!/usr/bin/python
 
#!/usr/bin/python
   
Line 122: Line 130:
 
if tux.event.wait_head_bt_pushed(60):
 
if tux.event.wait_head_bt_pushed(60):
 
tux.tts.speak("Ouch! That hurts!")
 
tux.tts.speak("Ouch! That hurts!")
</pre>
+
</source>
 
Problem: sometimes there is a delay before the speech and then movements/speech get desync.
 
Problem: sometimes there is a delay before the speech and then movements/speech get desync.
 
<br>It could be nice to get events from tts daemon when starting and stopping the speech.
 
<br>It could be nice to get events from tts daemon when starting and stopping the speech.
   
 
To launch gtdi from /usr/local/bin/gtdi I wrote a little bash script:
 
To launch gtdi from /usr/local/bin/gtdi I wrote a little bash script:
  +
<source lang=bash>
<pre>
 
 
#!/bin/bash
 
#!/bin/bash
   
 
cd /opt/tuxdroid/lib/gtdi
 
cd /opt/tuxdroid/lib/gtdi
 
./gtdi.py
 
./gtdi.py
</pre>
+
</source>
   
 
To get an interactive python shell I wrote this script /usr/local/bin/tuxsh:
 
To get an interactive python shell I wrote this script /usr/local/bin/tuxsh:
  +
<source lang=bash>
<pre>
 
 
#!/bin/bash
 
#!/bin/bash
   
 
python -i -c "import sys;sys.path.append('/opt/tuxdroid/api/python');from tux import *"
 
python -i -c "import sys;sys.path.append('/opt/tuxdroid/api/python');from tux import *"
</pre>
+
</source>
 
You can run it interactively or piping some commands:
 
You can run it interactively or piping some commands:
 
echo 'tux.cmd.mouth_open()'|./tuxsh
 
echo 'tux.cmd.mouth_open()'|./tuxsh
 
====Python API====
 
====Python API====
  +
List of functions can be generated by
Generated by
 
 
<pre>
 
<pre>
 
gawk '/^class/{match($0,/class +TUX(.*)\(object\):/,a);
 
gawk '/^class/{match($0,/class +TUX(.*)\(object\):/,a);
Line 151: Line 159:
 
</pre>
 
</pre>
   
  +
Or much cleaner:
<pre>
 
  +
tux.misc.build_documentation('/tmp/tuxapi.html')
tux.print_api_version()
 
tux.connect_to_daemon()
+
tux.misc.doc(tux)
  +
tux.misc.doc(tux.hw)
tux.disconnect_from_daemon()
 
  +
...
tux.recv_msg_Thread()
 
  +
tux.explicit_status()
 
  +
Try also help(tux.cmd)
tux.data_pooling()
 
  +
tux.dispatch_data_from_tcp_server()
 
  +
===IR===
tux.dispatch_data_from_sdaemon()
 
  +
* http://www2.tux-is-alive.com/wiki/Freaks_Asking_Questions#How_to_get_an_IR_RC5_code_from_the_API.3F
tux.dispatch_data_from_tux()
 
  +
* Looks like some of the keys of my remote are RC5 and some not... I'll try with lirc-audio hw to capture raw streams and analysing them.
tux.sys.time()
 
tux.sys.wait(seconds)
 
tux.sys.shell(command)
 
tux.sys.shell_free(command)
 
tux.sys.add_time_event(cmd_type,cmd,year,month,day,hour,minute,second)
 
tux.sys.clear_time_events()
 
tux.sys.time_events_Thread()
 
tux.event.clear()
 
tux.event.store()
 
tux.event.restore()
 
tux.event.wait_status(DATA_STATUS,DATA_VALUE,time_out)
 
tux.event.wait_stable_status(DATA_STATUS,DATA_VALUE,stable_time,time_out)
 
tux.event.wait_bt_pushed(time_out)
 
tux.event.wait_head_bt_pushed(time_out)
 
tux.event.wait_head_bt_relealed()
 
tux.event.wait_lwing_bt_pushed(time_out)
 
tux.event.wait_lwing_bt_released()
 
tux.event.wait_rwing_bt_pushed(time_out)
 
tux.event.wait_rwing_bt_released()
 
tux.event.wait_remote_bt(remote_key,timeout)
 
tux.event.set_on_bt_pushed(function)
 
tux.event.set_on_head_bt_pushed(function)
 
tux.event.set_on_lwing_bt_pushed(function)
 
tux.event.set_on_rwing_bt_pushed(function)
 
tux.event.set_on_bt_released(function)
 
tux.event.set_on_head_bt_released(function)
 
tux.event.set_on_lwing_bt_released(function)
 
tux.event.set_on_rwing_bt_released(function)
 
tux.event.set_on_remote_bt(key,function)
 
tux.cmd.cmd_ack()
 
tux.cmd.structured(fct,cmd,param1,param2,param3)
 
tux.cmd.raw(cmd,param1,param2,param3)
 
tux.cmd.eyes_on(count=1)
 
tux.cmd.eyes_open()
 
tux.cmd.eyes_close()
 
tux.cmd.eyes_on_free(count=1)
 
tux.cmd.eyes_off()
 
tux.cmd.mouth_on(count=1)
 
tux.cmd.mouth_on_free(count=1)
 
tux.cmd.mouth_open()
 
tux.cmd.mouth_close()
 
tux.cmd.mouth_off()
 
tux.cmd.wings_on(count=1,speed=5)
 
tux.cmd.wings_on_free(count=1,speed=5)
 
tux.cmd.wings_off()
 
tux.cmd.spinl_on(count=4,speed=5)
 
tux.cmd.spinl_on_free(count=4,speed=5)
 
tux.cmd.spinl_off()
 
tux.cmd.spinr_on(count=4,speed=5)
 
tux.cmd.spinr_on_free(count=4,speed=5)
 
tux.cmd.spinr_off()
 
tux.cmd.ir_on()
 
tux.cmd.ir_off()
 
tux.cmd.ir_send(address,command)
 
tux.cmd.leds_on()
 
tux.cmd.leds_blink(count,delay)
 
tux.cmd.leds_off()
 
tux.cmd.leds_during(seconds)
 
tux.cmd.leds_during_free(seconds)
 
tux.cmd.ledl_on()
 
tux.cmd.ledl_off()
 
tux.cmd.ledl_during(seconds)
 
tux.cmd.ledl_during_free(seconds)
 
tux.cmd.ledr_on()
 
tux.cmd.ledr_off()
 
tux.cmd.ledr_during(seconds)
 
tux.cmd.ledr_during_free(seconds)
 
tux.cmd.sound_play(index,volume)
 
tux.cmd.sound_storing(number)
 
tux.cmd.sound_store_index(highAdd,middleAdd,lowerAdd)
 
tux.cmd.sound_test()
 
tux.cmd.ping(count)
 
tux.cmd.sleep_on()
 
tux.cmd.sleep_off()
 
tux.cmd.audio_channel_general()
 
tux.cmd.audio_channel_tts()
 
tux.status.capture_light_level_thread()
 
tux.status.rsp_status(DATA_STATUS)
 
tux.status.get(DATA_STATUS)
 
tux.status.get_wings_motor_backward()
 
tux.status.get_spin_motor_backward()
 
tux.status.get_spin_motor_forward()
 
tux.status.get_mouth_open_position()
 
tux.status.get_mouth_closed_position()
 
tux.status.get_head_push_position()
 
tux.status.get_charger_inhibit_signal()
 
tux.status.get_wings_position_switch()
 
tux.status.get_motor_for_wings()
 
tux.status.get_left_blue_led()
 
tux.status.get_right_blue_led()
 
tux.status.get_head_motor_for_mouth()
 
tux.status.get_head_motor_for_eyes()
 
tux.status.get_ir_receiver_signal()
 
tux.status.get_spin_position_switch()
 
tux.status.get_wings_motor_forward()
 
tux.status.get_ir_led()
 
tux.status.get_eyes_open_position_switch()
 
tux.status.get_eyes_closed_position_switch()
 
tux.status.get_left_wing_push()
 
tux.status.get_right_wing_push()
 
tux.status.get_power_plug_switch()
 
tux.status.get_head_push_switch()
 
tux.status.get_tux_mute_sound()
 
tux.status.get_light_level()
 
tux.status.get_eyes_position_counter()
 
tux.status.get_mouth_position_counter()
 
tux.status.get_wings_position_counter()
 
tux.status.get_spin_position_counter()
 
tux.status.get_RF_state()
 
tux.status.get_sound_flash_count()
 
tux.sdaemon.cmd_ack()
 
tux.sdaemon.rsp_info(DATA_INFO)
 
tux.sdaemon.cmd(cmd,param1,param2,param3)
 
tux.sdaemon.cmd_no_ack(cmd,param1,param2,param3)
 
tux.sdaemon.request(req,param1,param2,param3)
 
tux.sdaemon.disconnect_client(id_client)
 
tux.sdaemon.disconnect_me()
 
tux.sdaemon.kill()
 
tux.sdaemon.set_my_client_name(name)
 
tux.sdaemon.get_version()
 
tux.sdaemon.get_client_count()
 
tux.sdaemon.get_client_name(id_client)
 
tux.sdaemon.get_my_client_id()
 
tux.hw.get_firmware_versioning(cpu_index)
 
tux.hw.behavior_get_version()
 
tux.hw.audio_get_version()
 
tux.hw.tuxrf_get_version()
 
tux.hw.donglerf_get_version()
 
tux.hw.alsa_devices_enumerate()
 
tux.hw.alsa_devices_count()
 
tux.hw.alsa_devices_select(number)
 
tux.tts.connect_to_daemon()
 
tux.tts.disconnect_from_daemon()
 
tux.tts.recv_msg_Thread()
 
tux.tts.data_pooling()
 
tux.tts.dispatch_data_from_tcp_server()
 
tux.tts.getTime()
 
tux.tts.wait_time(seconds)
 
tux.tts.send_command_to_tts(cmd_type,cmd,param1,param2,param3,param4)
 
tux.tts.soundconf_reinit(usb_bus,usb_device)
 
tux.tts.soundconf_stop()
 
tux.tts.select_voice(speaker,pitch)
 
tux.tts.select_voice_fr_male()
 
tux.tts.select_voice_fr_female()
 
tux.tts.select_voice_us_male()
 
tux.tts.select_voice_us_female()
 
tux.tts.select_voice_fr_male_tuxed()
 
tux.tts.select_voice_fr_female_tuxed()
 
tux.tts.select_voice_us_male_tuxed()
 
tux.tts.select_voice_us_female_tuxed()
 
tux.tts.speak(text)
 
tux.tts.speak_free(text)
 
tux.tts.play()
 
tux.tts.pause()
 
tux.tts.stop()
 
tux.tts.get_sound_state()
 
tux.tts.send_disconnect()
 
tux.tts.print_audio_fifo_state()
 
tux.tts.print_tux_sound_cards()
 
tux.tts.kill_daemon()
 
tux.tts.wait_until_status1(CMD_TYPE,CMD_STATUS,time_out)
 
</pre>
 

Latest revision as of 22:33, 24 November 2010

Introduction

_The_ gadget any linux geek should have ;-)

Moreover it is designed in Belgium, tadaam!

Having kids can help justifying such a, hum, impulsive buy ;-)

http://www2.tux-is-alive.com/mediawiki/images/thumb/b/b9/Tux-proto.jpg/200px-Tux-proto.jpg

Sites

Audio

  • Plugging everything for the first time, and I got immediately a new Alsa device:
cat /proc/asound/cards
...
2 [default        ]: USB-Audio - TUX RF DONGLE 
                     C2ME BELGIUM TUX RF DONGLE  at usb-0000:00:1d.2-1, full speed

And I can already place an Ekiga test call :-)
Note that echo between internal speaker and microphone is very important so echo tests are quite terrible!
Using the OSS emulation, I can play whatever I want:

mpg321 -o oss -a /dev/dsp2 /path/to/some/mp3
mplayer -ao oss:/dev/dsp2 http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3

Or using the native alsa layer:

mplayer -ao alsa:device=plughw=2.0 http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3

Or using esound:

esd -d plughw:2,0
mplayer -ao esd http://www.paul.sladen.org/pronunciation/torvalds-says-linux.mp3

XMMS:

  • Select alsa output plugin -> configure -> type "plughw:1,0" manually and select software volume control.
  • Select OSS output plugin -> configure -> USB but then no volume control is possible.
  • Select esound output plugin and launch esd as shown above

Reflashing

Then I learn that to run the new (alpha2) tuxdaemon I'll also need to flash the stuffed pinguin.
Instructions are given on the web site and are not... straightforward.

Additional notes:

  • Be sure to have installed properly libusb and to have mounted /proc/bus/usb, cf /usr/share/doc/libusb-0.1-4
    • For users to have the right to access usbfs, change /etc/udev/rules.d/020_permissions.rules and add GROUP=usb:
SUBSYSTEM=="usb_device",        MODE="0664", GROUP="usb"
  • Recompile dfu-programmer from sources! I first tried alien on the rpm but there were glibc problems and when trying tuxup fuxusb.hex I got the following "common problem" but here it's really not because of permission problems.
Programming fuxusb.hex in USB CPU
Tux not found on USB
  • They explain about tuxup fuxrf.hex and tuxup --main . but I had also to fix the tux rf counterpart: tuxup tuxrf.hex
  • At the end, replug the dongle and restart the tux

Compiling a firmware

apt-get install gcc-avr avr-libc gdb-avr

Follow the howto starting from SVNWCRev section.
To get the proper header files to compile SVNCRev:

apt-get install libsvn-dev

And edit svncrev-0.1/config.mk to fix the following path:

APR_INCLUDE=/usr/include/apr-1.0

Personalizing the firmware

For basic stuff, we'll only change the tuxcore.eep file where are stored the basic standalone behaviors.
Edit common/config.h based on commands listed in common/commands.h
Each line is one first byte (what for?) then a frame of 4 bytes to combine between 1 and 4 commands as explained in commands.h
My first personalized firmware has the following behavior:
Eyes closed when no rf link and opened when rf link is established.
Note that it would be easier if there was a CLOSE_EYES_CMD
I solved it by using the seq "OPEN_EYES_CMD, BLINK_EYES_CMD, 1, 0"

Remote Control

(from the forum)
Press 'ALT' then 'Tux and phone' and you're in test mode.
The arrows should move tux, if you press a digit key, you change the number of movements. So 4 then up will move the eyes 4 times (2 blinks: close - open -close - open)
Read firmware/tuxcore/trunk/standalone.c l262 to see all possiblities

Raw commands

gtdi allows to send raw commands, see /firmware/tuxdefs/commands.h

Misc Tips

  • First time, don't forget to plug Tux to the power adaptor for a while (~5h)
  • Want to get Acapela Telecom? It's actually available as the tts-daemon

Misc Problems

  • tuxdaemon from svn eats all CPU when running daemonised :-(
  • tuxttsdaemon launched by gtdi eated 100% cpu after a while with tux off
  • gtdi
    • source to be modified: add a space between gnome-terminal -e and "the_commands"
    • should check for the presence of gnome--terminal or fallback to xterm
    • tuxttsdaemon button desync
  • wrong comments in commands.h 0x1A & 0x1B control both leds
  • we should have save/restore raw commands for led & position

Misc Questions

  • How to control the volume by software?
  • How tuxes see each other? They ping constantly through IR (from the right eye) as it can be seen through a webcam.
  • How a dongle and a tux are paired? What if many tuxes are present simultaneously?

Misc

Python

Examples

I don't know python so for those who don't know it neither, here's a small snippet to start with (from Fosdem presentation):

#!/usr/bin/python

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

tux.tts.select_voice(3,150)
tux.cmd.leds_blink(200,10)
tux.cmd.mouth_on_free(22)
tux.tts.speak("The box said: 'Requires Windows 95 or better', so I installed LINUX")
tux.cmd.eyes_on_free(4)
tux.cmd.wings_on_free(4)
tux.tts.speak("ha ha ha")
if tux.event.wait_head_bt_pushed(60):
    tux.tts.speak("Ouch! That hurts!")

Problem: sometimes there is a delay before the speech and then movements/speech get desync.
It could be nice to get events from tts daemon when starting and stopping the speech.

To launch gtdi from /usr/local/bin/gtdi I wrote a little bash script:

#!/bin/bash

cd /opt/tuxdroid/lib/gtdi
./gtdi.py

To get an interactive python shell I wrote this script /usr/local/bin/tuxsh:

#!/bin/bash

python -i -c "import sys;sys.path.append('/opt/tuxdroid/api/python');from tux import *"

You can run it interactively or piping some commands:

echo 'tux.cmd.mouth_open()'|./tuxsh

Python API

List of functions can be generated by

gawk '/^class/{match($0,/class +TUX(.*)\(object\):/,a);
               if(a[1]=="TCPCommunicator")c=""; else c=tolower(a[1])"."}
      /^ +def/ && !/__init__/{$0=gensub(/^ +def (.*)self,?(.*):/,"tux." c "\\1\\2",1);print}'\
/opt/tuxdroid/api/python/tuxapi_class.py

Or much cleaner:

tux.misc.build_documentation('/tmp/tuxapi.html')
tux.misc.doc(tux)
tux.misc.doc(tux.hw)
...

Try also help(tux.cmd)

IR