-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add gps.py part #992
Add gps.py part #992
Conversation
Note the changes to install; I'm having trouble testing them because of the conda issue with solving the environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks great, very good and clear/readible code. I only have a couple of minor comments.
donkeycar/parts/gps.py
Outdated
import utm | ||
|
||
logger = logging.getLogger("gps") | ||
logger.setLevel(logging.DEBUG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should set the logging level only in manage.py
and then all parts will log according to that level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, left over debugging code. Thanks
donkeycar/parts/gps.py
Outdated
line = self._readline() | ||
if line: | ||
if self.debug: | ||
logger.info(line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you would say logger.debug(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually want this to log at info level, but only if debugging is turned on. I don't want to turn on all debug level logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, that having the functionality of the logging module which allows a very fine grained adjustment of which messages in which modules will perform logging is contradictory to having an additional boolean debug
flag here. So you would make this a debug statement here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging module won't do what I want unless I can set the level per logger, which itself is a pain; we could setup a logging configuration file to make this happen, but this is simple and does what I need. See more comments below.
donkeycar/parts/gps.py
Outdated
if self.gps is not None: | ||
with self.lock: | ||
try: | ||
if self.gps is not None and self.gps.is_open: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.gps
has already been checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this.
donkeycar/parts/gps.py
Outdated
if self.lock.acquire(blocking=False): | ||
try: | ||
# TODO: Serial.in_waiting _always_ returns 0 in Macintosh | ||
if self.gps is not None and self.gps.is_open and self.gps.in_waiting: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.gps
has been checked already
donkeycar/parts/gps.py
Outdated
""" | ||
Calculate (min, max, mean, std_deviation) of a list of floats | ||
""" | ||
if data is None or len(data) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not data:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
install/envs/mac.yml
Outdated
- moviepy | ||
- install -U --no-deps numpy==1.19.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed this to make it a legal set of arguments for pip install
install/envs/mac.yml
Outdated
- psutil | ||
- kivy=2.0.0 | ||
- plotly | ||
- pyyaml | ||
- fastai | ||
- pip: | ||
- tensorflow==2.2.0 | ||
- --no-binary :h5py: h5py==3.1.0 | ||
- tensorflow==2.5.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be these changes crept in accidentally, they don't look right....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this so it is legal arguments to pip install
. These have been tested using pip directly. However, I can't test this using the standard install instructions because conda never resolves the environment; after 12 hours I quit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot get the conda install instructions to work at all. I got a pip install script to work on mac, but I did have to install h5py this way so it would build and tensorflow 2.2.0 is not longer available. I think we need to do some basic testing on the install in all the environments; I think the RPi is broken because of tensorflow 2.2.0 as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be happy to back out all the setup changes and we can deal with them in a separate pull request to fix the install issues on every platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please revert those change, the Mac conda environment runs well on the CI as well as on my computer. If the RPi install gives a problem then we need to address this differently, as the RPi installs through pip (using setup.py
) only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted mac.yml to be same as main.
donkeycar/parts/gps.py
Outdated
|
||
logger = logging.getLogger("gps") | ||
|
||
class gps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that: class names should be upper/camel case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it Gps
as GPS looks like a constant.
donkeycar/parts/gps.py
Outdated
import serial | ||
import utm | ||
|
||
logger = logging.getLogger("gps") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't use __name__
as the name of the logger, it won't inherit the settings from the base logger (actually any base logger in the hierarchy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed that. Thanks.
donkeycar/parts/gps.py
Outdated
line = self._readline() | ||
if line: | ||
if self.debug: | ||
logger.info(line) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, that having the functionality of the logging module which allows a very fine grained adjustment of which messages in which modules will perform logging is contradictory to having an additional boolean debug
flag here. So you would make this a debug statement here.
donkeycar/parts/gps.py
Outdated
# | ||
parts = gps_str.split(".") | ||
degrees_str = parts[0][:-2] | ||
minutes_str = parts[0][-2:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, I think you don't need to do any split
here: just
degrees = float(gps_str[:2])
minuts = float(gps_str[2:])
install/envs/mac.yml
Outdated
- psutil | ||
- kivy=2.0.0 | ||
- plotly | ||
- pyyaml | ||
- fastai | ||
- pip: | ||
- tensorflow==2.2.0 | ||
- --no-binary :h5py: h5py==3.1.0 | ||
- tensorflow==2.5.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please revert those change, the Mac conda environment runs well on the CI as well as on my computer. If the RPi install gives a problem then we need to address this differently, as the RPi installs through pip (using setup.py
) only.
@@ -49,7 +49,10 @@ def package_files(directory, strip_leading): | |||
'progress', | |||
'typing_extensions', | |||
'pyfiglet', | |||
'psutil' | |||
'psutil', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add these to 3 libraries to the conda yaml files.
@Ezward - everything looks good, I think we need to bump the version (rebase from main) and update the conda yaml files. |
- reads gps coordinates as tuple (timestamp, longitude, latitude)
- note that currently it is not able to check for buffered chars on the mac; the Serial.in_waiting always returns 0. - this is a problem; it would be better to have the loop continue if no chars are waiting, rather than block. - I will test this on raspberrypi and nano and see if i can get that feature to work
- Serial.in_waiting always returns 0 on mac, but it works on raspberrypi os, so I added it back in. - Added plotting of the waypoints, their bounds and ellipse - Added separate hit tests for bounds, ellipse and axis-aligned standard deviation.
- limit self.debug checks to those that should only happen using the __main__ self test.
- I have successfully used these options directly with pip - I cannot test them directly because conda will not resolve the dependencies
- we will deal with mac install issues in a separate issue
- logger had syntax error - modern gps use 'GNRMC' message, which is standard
- based on multiple of standard deviation
I did that and updated the conda yaml files, but I have not tested these yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - need to wait until checks passed.
setup.py
Outdated
@@ -24,7 +24,7 @@ def package_files(directory, strip_leading): | |||
long_description = fh.read() | |||
|
|||
setup(name='donkeycar', | |||
version="4.3.10", | |||
version="4.3.11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just merged your other PR which bumped the version to 4.3.11 - can you rebase and force-push?
Part of Issue #991