Skip to content

Things to do to catch up with boostc #15

Closed

Description

@ddemidov
  • Implement device_index property for Device class.
  • Implement platform-specific Led instances and color functions.
  • Implement measured_amps and measured_volts properties for PowerSupply class (the names in the generated doc seem to be messed up).
  • Implement Button class for ev3 buttons.
  • Implement Sound class.
  • Implement LCD class.
  • Implement RemoteControl class.
  • Implement bin_data_format and bin_data for Sensor.
  • Implement steering function.

Activity

  1. added a commit that references this issue on Oct 19, 2015
  2. antonvh commented on Oct 19, 2015

    @antonvh
    Contributor

    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)

  3. ddemidov commented on Oct 19, 2015

    @ddemidov
    MemberAuthor

    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?

  4. antonvh commented on Oct 19, 2015

    @antonvh
    Contributor
  5. rhempel commented on Oct 19, 2015

    @rhempel
    Member

    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 :-)

  6. ddemidov commented on Oct 19, 2015

    @ddemidov
    MemberAuthor

    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.

  7. rhempel commented on Oct 19, 2015

    @rhempel
    Member

    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.

  8. ddemidov commented on Oct 19, 2015

    @ddemidov
    MemberAuthor

    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).

  9. antonvh commented on Oct 19, 2015

    @antonvh
    Contributor

    I will work on the Button first and later try Sound. I couldn't find any specs. I will try to emulate boostc as well as possible.

  10. ddemidov commented on Oct 20, 2015

    @ddemidov
    MemberAuthor

    Found @dlech's comment about framebuffer implementation in python: ev3dev/ev3dev#404 (comment)

  11. antonvh commented on Oct 20, 2015

    @antonvh
    Contributor

    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

    On 19 Oct 2015, at 11:21, Denis Demidov notifications@github.com wrote:

    /sys/class/leds

  12. ddemidov commented on Oct 20, 2015

    @ddemidov
    MemberAuthor

    I've already implemented brickpi leds (@dlech sent me the info yesterday). Thanks anyway!

  13. ensonic commented on Oct 20, 2015

    @ensonic
    Contributor

    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.

  14. ddemidov commented on Oct 20, 2015

    @ddemidov
    MemberAuthor

    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?

  15. ensonic commented on Oct 20, 2015

    @ensonic
    Contributor
  16. ddemidov commented on Oct 20, 2015

    @ddemidov
    MemberAuthor

    @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 :).

  17. ddemidov commented on Oct 30, 2015

    @ddemidov
    MemberAuthor

    @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.

  18. ddemidov commented on Oct 30, 2015

    @ddemidov
    MemberAuthor

    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?

  19. dlech commented on Oct 30, 2015

    @dlech
    Member

    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.

  20. rhempel commented on Oct 30, 2015

    @rhempel
    Member

    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)

  21. rhempel commented on Oct 30, 2015

    @rhempel
    Member

    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

  22. ddemidov commented on Oct 30, 2015

    @ddemidov
    MemberAuthor

    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.

  23. dlech commented on Oct 30, 2015

    @dlech
    Member

    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.

  24. rhempel commented on Oct 30, 2015

    @rhempel
    Member

    I read up on beep and now I agree - let's do it with a system call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions