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
Cool. Laurens and I were trading emails in Jan when I was working on this, he was very helpful. I got it somewhat working but it still needed some fine tuning. My branch is https://github.com/dwalton76/ev3dev-lang-python/tree/gyro
feel free to grab anything from there that you like. Laurens said he had a much better algorithm in the works so I stopped working on this until he got that published.
I have a program for the gyroboy in progress. However, I have been having trouble getting the loop time down as well. What kind of loop time are you able to get? I am at 20-25ms. Hoping to get it down below 10ms though. It seems like I was getting this 1+ years ago the last time I was doing a balancing robot in ev3dev. Basically, each sysfs read/write is 3 to 4ms, which is way too long. If we could get it down to 1ms, it would be ok. It depends on if there is something in python that can be changed or if the seek and read/write syscalls just actually take that long.
It's also interesting to me that the first iteration of the loop takes much longer. Here are my function call times in ms for the first iteration.
GG is reading the gyro sensor value. GM reads the motor positions of 2 motors and cntrl writes the duty_cycle_sp of 2 motors.
I've included the patch from @antonvh that removes the extra absolute path lookup, which, by the way, no longer seems to be in the develop branch (did @rhempel force push?)
Interesting. I was using python3, however times are better in python2.
Python 2.7.9 (default, Mar 1 2015, 13:52:09)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> timeit.repeat('f.seek(0); f.read()', 'f = open("/sys/class/tacho-motor/motor0/position", "r+")', number=1000)
[1.2495520114898682, 1.2299458980560303, 1.206686019897461]
Python 3.4.2 (default, Oct 8 2014, 14:47:30)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> timeit.repeat('f.seek(0); f.read()', 'f = open("/sys/class/tacho-motor/motor0/position", "r+")', number=1000)
[3.638115724999807, 3.6730630889996974, 3.7583993859989278]
No @rhempel did not pull in that patch yet (he thinks)
I think @dlech was pointing out that the PR was merged but the commits are no longer in the develop branch. That likely means that someone force-pushed while their working HEAD was behind the remote.
I've made a gyroboy program that does not use ev3dev-lang-python. I got the loop time down to about 15ms, so there is some overhead in ev3dev-lang-python that might be able to be shaved off, but the really just might be the best we can do with python and sysfs.
Lauren's has a newer version of his balancing algorithm and he wrote it in Python. I made a class based version of it for ev3dev. I am out of town for work right now but will send a pull request this weekend when I get home. He has his cycle time at 10ms
I used ev3dev and with my patch (antonvh@abdcae4) I get loop times of around 16-17ms which is enough to balance.
Laurens' version is without ev3dev and directly reads files. He's getting loop times of around 11ms. I think the ev3dev overhead is still too large. A few lines of python shouldn't make milliseconds of difference. I wonder where that comes from.
On the Pi I get loop times of 10ms with ev3dev. But the BrickPi is acting up. It's all shaky and it feels like 'updateMotorsAndSensors()' is called too often by the driver. I have to investigate that some more, but I ran out of time.
@rhempel : Yes, I just uploaded the line following example to my github just for you. I'm guessing it is for the FIRST festival so I'll keep it short. You need to:
@laurensvalk
I followed your instructions. The program segway.py seems to run, except it doesn't do anything apart from exiting when I press the touch sensor. Here is the console output.
@laurensvalk
I've checked that the motors are on A and D, and are seen by Brickman, the values change when I twist the wheels. And I extracted the SD card and ran your Balanc3r-Remote-control project with great success, it balances. It's just the Python version which doesn't move the wheels. Any ideas?
my guess is a kernel version/ev3dev-lang-python version mismatch. there have been breaking changes to the motor drivers, so if they don't match, motors don't work.
@dlech
What should I do at this point? Until "hello world" runs, I am slavishly following instructions.
I have now scanned through the netiquette link. Here anyway is a codefence test:
Ceci n'est pas du code
I wish there were backticks on my french keypboard
Buvez de ce whisky que le patron juge fameux
@dlech Downgraded kernel, perfect! Thank you! @laurensvalk Very stable. Thank you for the help and the code! @rhempel Ran your demo too. Balances ok. Needs the touch sensor apparently (not part of original Laurens Valk web demo), and the old kernel. Thank you!
It would be nice to know whether the code is really incompatible with the new kernel or whether I did something strange ... I guess you'll be interested in that too.
Here is a log of the fix being applied:
robot@ev3dev:~$ sudo flash-kernel --force 3.16.7-ckt21-9-ev3dev-ev3
[sudo] password for robot:
flash-kernel: forcing install of 3.16.7-ckt21-9-ev3dev-ev3 instead of 3.16.7-ckt26-10-ev3dev-ev3.
flash-kernel: WARNING: Installing any new kernel package might override this.
flash-kernel: installing version 3.16.7-ckt21-9-ev3dev-ev3
Activity
dwalton76 commentedon Jan 22, 2016
@rhempel feel free to assign this to me. I created the ticket in case anyone else is interested in working on this with me.
antonvh commentedon Mar 14, 2016
I'm actually working with Laurens on the python port. We're nearly there... Some trouble with r/w speed. It's patched in the development branch.
dwalton76 commentedon Mar 14, 2016
Cool. Laurens and I were trading emails in Jan when I was working on this, he was very helpful. I got it somewhat working but it still needed some fine tuning. My branch is
https://github.com/dwalton76/ev3dev-lang-python/tree/gyro
feel free to grab anything from there that you like. Laurens said he had a much better algorithm in the works so I stopped working on this until he got that published.
dlech commentedon Mar 30, 2016
I have a program for the gyroboy in progress. However, I have been having trouble getting the loop time down as well. What kind of loop time are you able to get? I am at 20-25ms. Hoping to get it down below 10ms though. It seems like I was getting this 1+ years ago the last time I was doing a balancing robot in ev3dev. Basically, each sysfs read/write is 3 to 4ms, which is way too long. If we could get it down to 1ms, it would be ok. It depends on if there is something in python that can be changed or if the seek and read/write syscalls just actually take that long.
It's also interesting to me that the first iteration of the loop takes much longer. Here are my function call times in ms for the first iteration.
Then for a later iteration...
GGis reading the gyro sensor value.GMreads the motor positions of 2 motors andcntrlwrites the duty_cycle_sp of 2 motors.I've included the patch from @antonvh that removes the extra absolute path lookup, which, by the way, no longer seems to be in the
developbranch (did @rhempel force push?)dlech commentedon Mar 30, 2016
Interesting. I was using python3, however times are better in python2.
dlech commentedon Mar 31, 2016
hmm... I implemented the change I suggested for python3 in #155, but I'm not really seeing any changes in performance.
rhempel commentedon Mar 31, 2016
No @rhempel did not pull in that patch yet (he thinks)
rhempel commentedon Mar 31, 2016
First iteration is longer because it sets up the caching subsystem - after that the reads/writes go through already open file handles.
WasabiFan commentedon Mar 31, 2016
I think @dlech was pointing out that the PR was merged but the commits are no longer in the develop branch. That likely means that someone force-pushed while their working HEAD was behind the remote.
dlech commentedon Mar 31, 2016
I've made a gyroboy program that does not use ev3dev-lang-python. I got the loop time down to about 15ms, so there is some overhead in ev3dev-lang-python that might be able to be shaved off, but the really just might be the best we can do with python and sysfs.
dwalton76 commentedon Mar 31, 2016
Lauren's has a newer version of his balancing algorithm and he wrote it in Python. I made a class based version of it for ev3dev. I am out of town for work right now but will send a pull request this weekend when I get home. He has his cycle time at 10ms
antonvh commentedon Mar 31, 2016
I did a python version of the balancer here: https://github.com/antonvh/segway
It's forked from the original by @laurensvalk here: https://github.com/laurensvalk/segway
I used ev3dev and with my patch (antonvh@abdcae4) I get loop times of around 16-17ms which is enough to balance.
Laurens' version is without ev3dev and directly reads files. He's getting loop times of around 11ms. I think the ev3dev overhead is still too large. A few lines of python shouldn't make milliseconds of difference. I wonder where that comes from.
I also did a BrickPi version: https://github.com/antonvh/segway/tree/brickpi
On the Pi I get loop times of 10ms with ev3dev. But the BrickPi is acting up. It's all shaky and it feels like 'updateMotorsAndSensors()' is called too often by the driver. I have to investigate that some more, but I ran out of time.
29 remaining items
rhempel commentedon Apr 28, 2016
@laurens or @antonvanh - do you have the balancer code with the line follower as well?
laurensvalk commentedon Apr 28, 2016
@rhempel : Yes, I just uploaded the line following example to my github just for you. I'm guessing it is for the FIRST festival so I'll keep it short. You need to:
Also, you just tagged another Github user called Laurens.
laurensvalk commentedon Apr 28, 2016
Or if you use Git, this is all you need to do, as I believe it maintains the executable settings:
@edmundronald in your case, if you don't need line following just yet, run the other program, so just do:
edmundronald commentedon Apr 28, 2016
@laurensvalk
I followed your instructions. The program segway.py seems to run, except it doesn't do anything apart from exiting when I press the touch sensor. Here is the console output.
edmundronald commentedon Apr 29, 2016
@laurensvalk
I've checked that the motors are on A and D, and are seen by Brickman, the values change when I twist the wheels. And I extracted the SD card and ran your Balanc3r-Remote-control project with great success, it balances. It's just the Python version which doesn't move the wheels. Any ideas?
btw, I also ran the demo in https://github.com/rhempel/ev3dev-lang-python.git and it runs errorfree, now that I have added the touch sensor to the hardware, but it also doesn't move the motors.
Edmund
dlech commentedon Apr 29, 2016
my guess is a kernel version/ev3dev-lang-python version mismatch. there have been breaking changes to the motor drivers, so if they don't match, motors don't work.
Also, I would suggest https://help.github.com/categories/writing-on-github/
if you put a "code fence" around your terminal output, it makes it much easier to read.
edmundronald commentedon Apr 29, 2016
@dlech
What should I do at this point? Until "hello world" runs, I am slavishly following instructions.
I have now scanned through the netiquette link. Here anyway is a codefence test:
dlech commentedon Apr 29, 2016
You can edit your previous post so we can read it. 😉
Also, what kernel are you running on your EV3 (output of
uname -r)?edmundronald commentedon Apr 29, 2016
@dlech
Edited. Now, why didn't I think of that by myself? :)
dlech commentedon Apr 29, 2016
I image @laurensvalk has not updated for the motor changes in kernel release 10. You can attempt to fix the code or you can attempt to downgrade your kernel.
dlech commentedon Apr 29, 2016
Although after a quick look at the code, I don't see any changes that need to be made...
edmundronald commentedon Apr 29, 2016
@dlech Downgraded kernel, perfect! Thank you!
@laurensvalk Very stable. Thank you for the help and the code!
@rhempel Ran your demo too. Balances ok. Needs the touch sensor apparently (not part of original Laurens Valk web demo), and the old kernel. Thank you!
It would be nice to know whether the code is really incompatible with the new kernel or whether I did something strange ... I guess you'll be interested in that too.
Here is a log of the fix being applied:
[-]Implement BALANC3R and Gyro Boy[/-][+]Implement BALANC3R[/+]dwalton76 commentedon May 1, 2016
BALANC3R is now supported