Closed dwalton76 closed 6 years ago
I've built a BALANC3R and have it working using Laurens Valk's EV3-G programs. Once I understand how his EV3-G programs work, I'll start translating them to the new API.
For reference, the existing implementation is here: https://github.com/ev3dev/ev3dev-lang-python-demo/blob/master/robots/BALANC3R
Some of the work might be to update the GyroBalancer class in the core library.
Thanks @WasabiFan. Should we move a lot of the functionality out of the GyroBalancer class and replace it with example scripts that use the new API ? It seems like the GyroBalancer class sits at level above the new API. So wondering if we want this code in the core library or in example scripts? EV3-G does not have any programming blocks that are specific to particular models of robots.
I think that'll be a question for @dwalton76. I have never used the gyro balancer. Certainly, I think it should be available as a reusable component in some form, but whether that is in the core module or a file in the demos repo here I don't really have a preference.
I now realize that there is hardly any code in BALANCER here and most of the logic lives in that GyroBalancer class. I filed https://github.com/ev3dev/ev3dev-lang-python/issues/418 for that, @gregcowell I would do the majority of the work there. Basically just take what is there and update it to get it working. If you can get it working using the new API I would view that as a nice bonus but not a must have. I say that because Laurens was jumping through some hoops to avoid using the old API to make updating the various /sys/
files be as fast as possible.
Laurens posted the other day about some updates he has made https://github.com/ev3dev/ev3dev/issues/984
His code lives at https://github.com/laurensvalk/segway/
I ported his code ~18 to 24 months ago to create our BALANCER/GyroBalancer. It might be worth looking through the commits made since then and porting them to our codebase.
@gregcowell you may also need to fix https://github.com/ev3dev/ev3dev-lang-python/issues/414 as part of this. I haven't started working on it, no worries from me if you get to it first.
I would do the majority of the work there. Basically just take what is there and update it to get it working.
Okay, will do.
Laurens posted the other day about some updates he has made ev3dev/ev3dev#984
One of the things Laurens has done is add support for a touch sensor. Should this be in the GyroBalancer class or separated out into an example script if possible?
@gregcowell you may also need to fix ev3dev/ev3dev-lang-python#414 as part of this. I haven't started working on it, no worries from me if you get to it first.
Is the idea to move the remote control functionality out of the GyroBalancer class and into an example script ?
One of the things Laurens has done is add support for a touch sensor. Should this be in the GyroBalancer class or separated out into an example script if possible?
How about here in the demo repo update the BALANCER script to create a child class of GyroBalancer that adds support for the TouchSensor...that way we are providing a nice example of how to use object-oriented programming to build on what is already there.
Is the idea to move the remote control functionality out of the GyroBalancer class and into an example script ?
Na I would leave it there, just update it to use InfrafredSensor instead of RemoteControle
Here's something to perhaps consider for future updates.
Currently, the motion of the robot is controlled on a high level using the 'speed' and 'steering' variables, e.g.
# Just balance in place:
speed = 0
steering = 0
It would be nice to be able to control these from the main script without having to modify the control code.
That would separate high level from the low level control. On the high level, various examples are possible such as IR control or line following.
In the EV3-G example, I provide this possibility through a parallel task. Unlike in my Python code, this high level loop can also do things like waiting without stalling the balancing loop.
There may be alternatives to using parallel code as well. For example, in microcontroller type applications, one might fire a timer interrupt at constant intervals to each time run the code that currently lives in the balancing loop once. Any remaining time is available for the high level control. I've never tried this in Python though.
I like the idea of moving the drive control loop functionality out of the GyroBalancer class and into an example script. It would make the GyroBalancer class a lot more general purpose. I’m happy to look into doing this.
Sounds good. I think I'll keep my version in it's original form for development purposes, but I like the ev3dev version because of its ease of use.
Feel free to ask here if you have any questions when expanding this functionality.
Update BALANC3R to new API