Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix - line follower kernel issue #273

Merged

Conversation

RobertLucian
Copy link
Contributor

@RobertLucian RobertLucian commented Oct 9, 2017

This solves this issue: RobertLucian#8.
The initial report made by John is here: raspberrypi/firmware#828 (comment)

Explanation

Also, the alternative package that was used for interfacing with the line follower sensor is only supported in Python 3, which means that if someone wants to read data from it, the modules have to be imported in Python 3.

At the moment, I haven't removed the support for Python2, so anything that uses the line follower sensor in Python 2 (aka Scratch or GoPiGo3) won't work. Therefore, this PR needs further modifications before it's merged.

The only single way of keeping Python 2 around is to delve into this issue with the I2C and create a library for it in C++. Then some python bindings would be required in order to make the library importable in python and there goes the time. I find this solution to be best of them all, but it takes time and I don't think it's justifiable to do this just so we can keep Python 2 around.

So, I suggest that we move forward with Python 3. In order to do this, we would need to do the following:

  1. Rename this branch to a feature instead of a hotfix and make it PR to the develop branch - the reason is that this is starting to look like a big mod to me and things may go haywire with the master branch.
  2. Remove support for Python 2 and exclusively support Python 3 in this repo.
  3. Remove support for Python 2 and exclusively support Python 3 in the GoPiGo3 repo.
  4. Make DexterOS support Python 3.

Also, to me, I find it peculiar that a sensor which is used on the GoPiGo3 is kept on the GoPiGo repo - I think this has to change as it makes the GoPiGo3 (and thus DexterOS) completely dependent on the GoPiGo repo and this causes us quite some delays because now lots of things have to change - by the way, this is similar to what we have with the distance sensor @CleoQc .

Testing Hotfix

In order to test the hotfix, follow the instructions:

  1. Install the latest kernel for the rpi: sudo rpi-update 5d03351413d4021cc3feeb04459eea98bcb731c0 - this will update to version v.4.9.53-v7.
  2. Git checkout my branch.
  3. Run the install script found in /Setup/ folder.
  4. Start a python 3 shell and enter:
from line_follower import line_sensor
line_sensor.read_sensor()

Also, here's a chart with the tests I have run for the GrovePi and the line follower sensor. It looks like the GrovePi works in all cases, which is great, but the line follower sensor doesn't.

kernel_tests

TL;DR

Can't hotfix kernel issue without pushing for Python 3 and "independence" of the software product. But even so, you should test it just as it is right now.

Update

@johnisanerd , @CleoQc the python scripts now use the python-periphery package as a tool for interfacing with the line follower sensor. I have tested it with the latest kernel version and with Python 2 and Python 3 and it works.

Merge Requirements

  • Add support for installing python packages on DexterOS so we can accept this PR which uses the alternative python-periphery package for interfacing with the line follower sensor.

Copy link
Collaborator

@johnisanerd johnisanerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion (clone the repo) and one request (documment the issue just a little more in the changed code so that we're kind to our future selves trying to remember what the issue was in the first place).

import time
import math
import RPi.GPIO as GPIO
import struct
import operator
import pickle
import numpy
from periphery import I2C, I2CError
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small request here. Can you put a comment explaining why we switched to this, and put a link into this PR since you wrote a detailed explanation about what you found (#273) and maybe also link to the original firmware bug report (raspberrypi/firmware#828) so if we ever have to pick this issue apart again, we have this info a little more readily accessible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Setup/install.sh Outdated
sudo pip3 install -U RPi.GPIO
sudo pip3 install pyusb
sudo pip3 install numpy
sudo pip3 install python-periphery
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An Idea: clone this repo to the DexterInd account. Check on changes once per quarter. This way, changes in the python-periphery library won't suddenly break things for us, forcing us to scramble and fix them.

Just an idea, not a requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're doing the fixed-version thing instead.

Copy link
Collaborator

@johnisanerd johnisanerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! From my end this is a go. Go!

@@ -81,6 +81,12 @@ install_dependencies() {
sudo pip install -U RPi.GPIO
sudo pip install pyusb
sudo pip install numpy
sudo pip install python-periphery==1.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!

# PR : https://github.com/DexterInd/GoPiGo/pull/273


debug = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE. Thank you very much @RobertLucian !

@@ -1 +1,2 @@
future
quick2wire-api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is quick2wire still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Good catch. This is just a left-over. I'm deleting it.

@CleoQc
Copy link
Member

CleoQc commented Nov 15, 2017

Ready to merge?

@RobertLucian
Copy link
Contributor Author

RobertLucian commented Nov 15, 2017

I'm testing it as of this moment on DexterOS just to be sure nothing gets messed up. If everything looks good, then I'm going to merge it.

@RobertLucian
Copy link
Contributor Author

@CleoQc @johnisanerd tested it on DexterOS and the line follower sensor works with the new library. I've verified the functionality both in the terminal (by importing the sensor and calling the function) and by going in Bloxter and selecting the line follower sensor.

@RobertLucian RobertLucian merged commit 1515fa2 into DexterInd:master Nov 15, 2017
@RobertLucian RobertLucian deleted the hotfix/line-follower-kernel-issue branch November 15, 2017 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants