You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What would you like me to do? Where would you like help? Apart from the steering function I'd like to make a MotorPair class, so you can m_pair.run_forever(direction=-50, speed_sp=75)
All of these are pretty straightforward to implement except for Button and LCD class. Both of these need low-level access to input/output devices, and both of them probably belong to EV3 platform (are there any buttons on RPI except for full-sized USB keyboard? Is there an LCD screen on RPI? Does it work through framebuffer?).
I was going to try and finish Led class later this week. Feel free to choose any other task. By the way, since you are running RPI, can you please show the contents of /sys/class/leds folder?
I think @ddemidov is going to work on the LED class implementation we talked about. @antonvh, could you send him the contents of your rPi /sys/class/led directory please? @antonvh - would you like to try to fill out the Button or Sound classes?
Coming from the Lua world, I am in favour of "mechisms, not policy" - what that means for us is implementing a minimal feature set for each class that allows users to build what they need on top of it.
For Sound, let's consider starting with a basic tone API (frequency, duration, volume as kwargs) and then maybe add specific sound file support as an add-in. We may want to also consider being able to send a sequence of tones as a list of tuples and playing to completion. Do we wait for the tone to complete before returning, do we add a function to tell us if the tone is playing or the driver is idle? etc...
You could also work on the power supply or remote control API. I might give the remote control API a try since I used it for the DrawString bot :-)
Note that the Sound class has just a handful of methods in C++/boostc bindings.
Sound::beep() is an alias for Sound::tone(1000, 100), Sound::tone(freq, dur) makes a noise on the given frequency for the given duration (and it uses sysfs file, so should be simple to implement). Both of the methods are asynchronous.
Sound::play() is just a wrapper around system call to aplay utility (I think patched by @dlech to better work in ev3 system). It may be synchronous or asynchronous depending on user flag.
Just to be clear, it would be best if we can minimize the functions in each class, and specify them in spec.json so that bindings for other languages can be scored against how much of the spec they implement.
What do you suggest to put into spec.json, except for may be list of method names (and may be parameters)? I don't think the methods for, say, Sound or LCD could be completely autogenerated in each of the bindings from a universal spec.
There is also wrapper-specification.md, which is partly generated from spec.json, but also contains some human-parseable statements (like description of the above methods).
@ensonic, I've pushed the changes and uploaded binary packages to PyPI. I tried to check that these work, but I can not guarantee that I did not break anything. Bug reports are welcome :).
@rhempel, do we still want to include the steering() function implementation? Its very easy to implement, and that's why I would not feel bad asking users to put it in their own code.
Re Sound implementation:
The C++ bindings use /sys/devices/platform/snd-legoev3/tone to control the beeper. @dlech, will there be similar devices on brickpi/pistorms? If yes, what are their names?
PiStorms does not have any sound devices. EVB does though. However, my personal preference is to use the existing kernel interface for sound via linux input devices with capability EV_SND. /sys/devices/platform/snd-legoev3/tone is a "back door" and comes from @fdetro to make it a bit easier to use, but is exclusive to the EV3.
The disadvantage of using ioctls though is described in the Ioctl Wackiness section in the man page for beep. You will get a permission error if the program is not running on the active virtual terminal unless the program is run with CAP_SYS_TTY_CONFIG.
So, I guess it depends on if you want to go for no surprises or force people to learn something about Linux.
Another option would be to patch our kernels to not check permissions for KIOCSOUND and KDMKTONE. Although, probably better not mess with the kernel.
Or, you can call the beep command which has the sticky bit set, so will work from anywhere.
Use the back door device for now (I think) it gives users the flexibility they will expect - I vote for fewer surprises and no requirement to learn much about Linux
I thought about using beep command through system call. It makes implementation easier and also in line with speak() and play() methods, which also use system to call espeak and play commands correspondingly.
I was going to say that should probably turn it into a new sysfs class then instead of relying on platform-specific paths, but @ddemidov makes a good point that other sound functions are system calls anyway. The beep command has a nice "language" that lets you construct a whole song in a single command if you want. We could just pass this string directly to beep. It also makes the choice of sync/async playback easier by using a separate process.
Activity
Merge pull request #11 from ddemidov/master
antonvh commentedon Oct 19, 2015
What would you like me to do? Where would you like help? Apart from the steering function I'd like to make a
MotorPairclass, so you canm_pair.run_forever(direction=-50, speed_sp=75)ddemidov commentedon Oct 19, 2015
All of these are pretty straightforward to implement except for
ButtonandLCDclass. Both of these need low-level access to input/output devices, and both of them probably belong to EV3 platform (are there any buttons on RPI except for full-sized USB keyboard? Is there an LCD screen on RPI? Does it work through framebuffer?).I was going to try and finish
Ledclass later this week. Feel free to choose any other task. By the way, since you are running RPI, can you please show the contents of/sys/class/ledsfolder?antonvh commentedon Oct 19, 2015
rhempel commentedon Oct 19, 2015
I think @ddemidov is going to work on the LED class implementation we talked about. @antonvh, could you send him the contents of your rPi
/sys/class/leddirectory please?@antonvh - would you like to try to fill out the
ButtonorSoundclasses?Coming from the
Luaworld, I am in favour of "mechisms, not policy" - what that means for us is implementing a minimal feature set for each class that allows users to build what they need on top of it.For
Sound, let's consider starting with a basic tone API (frequency, duration, volume askwargs) and then maybe add specific sound file support as an add-in. We may want to also consider being able to send a sequence of tones as a list of tuples and playing to completion. Do we wait for the tone to complete before returning, do we add a function to tell us if the tone is playing or the driver is idle? etc...You could also work on the power supply or remote control API. I might give the remote control API a try since I used it for the DrawString bot :-)
ddemidov commentedon Oct 19, 2015
Note that the
Soundclass has just a handful of methods in C++/boostc bindings.Sound::beep()is an alias forSound::tone(1000, 100),Sound::tone(freq, dur)makes a noise on the given frequency for the given duration (and it uses sysfs file, so should be simple to implement). Both of the methods are asynchronous.Sound::play()is just a wrapper around system call toaplayutility (I think patched by @dlech to better work in ev3 system). It may be synchronous or asynchronous depending on user flag.rhempel commentedon Oct 19, 2015
Just to be clear, it would be best if we can minimize the functions in each class, and specify them in
spec.jsonso that bindings for other languages can be scored against how much of the spec they implement.ddemidov commentedon Oct 19, 2015
What do you suggest to put into
spec.json, except for may be list of method names (and may be parameters)? I don't think the methods for, say,SoundorLCDcould be completely autogenerated in each of the bindings from a universal spec.There is also
wrapper-specification.md, which is partly generated fromspec.json, but also contains some human-parseable statements (like description of the above methods).antonvh commentedon Oct 19, 2015
I will work on the
Buttonfirst and later trySound. I couldn't find any specs. I will try to emulate boostc as well as possible.ddemidov commentedon Oct 20, 2015
Found @dlech's comment about framebuffer implementation in python: ev3dev/ev3dev#404 (comment)
antonvh commentedon Oct 20, 2015
anton@ev3dev-rpi1:~$ ls /sys/class/leds
brickpi1:blue:ev3dev brickpi2:blue:ev3dev led0 led1
anton@ev3dev-rpi1:~$ ls /sys/class/leds/brickpi1:blue:ev3dev/
brightness device max_brightness subsystem trigger uevent
anton@ev3dev-rpi1:~$ cat /sys/class/leds/brickpi1:blue:ev3dev/brightness
255
ddemidov commentedon Oct 20, 2015
I've already implemented brickpi leds (@dlech sent me the info yesterday). Thanks anyway!
ensonic commentedon Oct 20, 2015
FYI: The APIs are realative easy to compare by doing a pprint(dir(ev3dev)) with the respective import:
here is the pure one: https://gist.github.com/ensonic/2f00834f8213ae2df81b
and the boost one: https://gist.github.com/ensonic/331f0f57c10abe33cf4c
I'll start a sed script that will rewrite the api.
ddemidov commentedon Oct 20, 2015
Thanks, there is a lot of noise in boostc version (due to the need to work around fixed c++ interface), but this is very helpful.
@ensonic, since you are going to work on sed script, I could push changes to boostc version tonight with renamed classes. Would that be ok?
ensonic commentedon Oct 20, 2015
@ddemidov +1
ddemidov commentedon Oct 20, 2015
@ensonic, I've pushed the changes and uploaded binary packages to PyPI. I tried to check that these work, but I can not guarantee that I did not break anything. Bug reports are welcome :).
ddemidov commentedon Oct 30, 2015
@rhempel, do we still want to include the
steering()function implementation? Its very easy to implement, and that's why I would not feel bad asking users to put it in their own code.ddemidov commentedon Oct 30, 2015
Re
Soundimplementation:The C++ bindings use
/sys/devices/platform/snd-legoev3/toneto control the beeper. @dlech, will there be similar devices on brickpi/pistorms? If yes, what are their names?dlech commentedon Oct 30, 2015
PiStorms does not have any sound devices. EVB does though. However, my personal preference is to use the existing kernel interface for sound via linux input devices with capability
EV_SND./sys/devices/platform/snd-legoev3/toneis a "back door" and comes from @fdetro to make it a bit easier to use, but is exclusive to the EV3.The disadvantage of using ioctls though is described in the Ioctl Wackiness section in the man page for beep. You will get a permission error if the program is not running on the active virtual terminal unless the program is run with
CAP_SYS_TTY_CONFIG.So, I guess it depends on if you want to go for no surprises or force people to learn something about Linux.
Another option would be to patch our kernels to not check permissions for
KIOCSOUNDandKDMKTONE. Although, probably better not mess with the kernel.Or, you can call the
beepcommand which has the sticky bit set, so will work from anywhere.rhempel commentedon Oct 30, 2015
My vote re steering is let the users handle it if needed - we can certainly provide sample code based on the API - and that would be a GoodThing (tm)
rhempel commentedon Oct 30, 2015
Use the back door device for now (I think) it gives users the flexibility they will expect - I vote for fewer surprises and no requirement to learn much about Linux
ddemidov commentedon Oct 30, 2015
I thought about using
beepcommand throughsystemcall. It makes implementation easier and also in line withspeak()andplay()methods, which also usesystemto callespeakandplaycommands correspondingly.dlech commentedon Oct 30, 2015
I was going to say that should probably turn it into a new sysfs class then instead of relying on platform-specific paths, but @ddemidov makes a good point that other sound functions are system calls anyway. The beep command has a nice "language" that lets you construct a whole song in a single command if you want. We could just pass this string directly to
beep. It also makes the choice of sync/async playback easier by using a separate process.rhempel commentedon Oct 30, 2015
I read up on beep and now I agree - let's do it with a system call