• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pypilot
#1
We will use this thread to follow the Pypilot implementation on OpenPlotter.

https://github.com/pypilot/pypilot

Branch on OP repo to work on this: https://github.com/sailoog/openplotter/tree/pypilot

Background: http://forum.openmarine.net/showthread.php?tid=463
  Reply
#2
I get this error when I try to run pypilot/boatimu.py or any client or server script:


Code:
Traceback (most recent call last):
 File "boatimu.py", line 18, in <module>
   from signalk.pipeserver import NonBlockingPipe
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/pipeserver.py", line 14, in <module>
   from server import SignalKServer, DEFAULT_PORT, default_persistent_path
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/server.py", line 19, in <module>
   from signalk.linebuffer import linebuffer
ImportError: cannot import name linebuffer

There are no files on /usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/linebuffer

This is what I have done on a fresh OP 0.12.0:

Code:
sudo apt-get install swig python-numpy python-scipy python-serial python-gps python-PIL python-dev python-opengl

Then, I have modified your RTIMULib2 fork to avoid errors: https://github.com/seandepagnier/RTIMULi...ter:master

Code:
git clone https://github.com/openplotter/RTIMULib2
cd RTIMULib2/Linux
mkdir build
cd build
cmake ..
make -j4
sudo make install
sudo ldconfig
cd ..
cd RTIMULibDrive
make -j4
sudo make install
cd ..
cd RTIMULibDrive10
make -j4
sudo make install
cd ..
cd python
python setup.py build
sudo python setup.py install



Code:
sudo pip install pyglet pywavefront


Code:
git clone https://github.com/pypilot/pypilot
cd pypilot
sudo python setup.py install
  Reply
#3
Thanks for fixing the RTIMULib2 demos... I will try to integrate it.    Is it working ok with openplotter?
It might be nice to backport the changes from the mpu9255 to the mpu9250, or it should really share code.

Did you run "sudo python setup.py install" in the base pypilot directory?

Can you "import _linebuffer" ?


I need to clean up the way it adds packages.  I have not used python much before this project.
I suspect something strange, maybe you have setuptools vs distutil??

The linebuffering, nmea parsing, and a few other stuff is implemented in c for efficiency.

I have 
Code:
sean@odroid64:/usr/local/lib/python2.7/dist-packages$ find | grep linebuffer
./signalk/linebuffer
./signalk/linebuffer/linebuffer.pyc
./signalk/linebuffer/__init__.py
./signalk/linebuffer/__init__.pyc
./signalk/linebuffer/linebuffer.py
./_linebuffer.so

It is not going into an egg.

also, not sure if "make install" from RTIMULib2 also executes "sudo python setup.py install" if not, you need to manually execute it... I added a few fields to the settings to allow modifying the kalman gains from python. They were not really tuned for the mpu9255, especially not for boat motion.
  Reply
#4
Well, I have not exactly fixed demos on RTIMULIb2, just disabled from compilation unused apps.

Yes, I ran "sudo python setup.py install" in the base pypilot directory but only worked after a second run. You have to do  "python setup.py build" before installing to fix this.

Now linebuffer is installed and boatimu.py working, this is the exit for my LSM9DS0 IMU:


Code:
failed to load /home/pi/.pypilot/pypilot.conf
pipe server on 6474
failed to load /home/pi/.pypilot/pypilot.conf
imu on 6476
Settings file not found. Using defaults and creating settings file
Detected LSM9DS0 at standard/standard address
Using fusion algorithm Kalman STATE4
Using settings file RTIMULib.ini
IMU Name: LSM9DS0
min/max compass calibration not in use
Using ellipsoid compass calibration
Accel calibration not in use
LSM9DS0 init complete
pitch -2.69812036111 roll 94.0535592695 heading 76.1268156856
pitch -2.3484733501 roll 93.4669214888 heading 75.8535104079
pitch -2.76325676522 roll 93.2973314382 heading 75.8529283744
pitch -3.16851794831 roll 93.0857197642 heading 75.8034109818
pitch -3.59688636898 roll 92.9037346098 heading 75.7329755456
pitch -3.98878780904 roll 92.7311876455 heading 75.6996014171
pitch -4.38417975067 roll 92.5672128731 heading 75.703342992
pitch -4.72435719548 roll 92.3707398708 heading 75.7006562733
...

Now testing other scripts, looks promising Smile
  Reply
#5
Some issues:

LSM9DS0 IMU works great on boatimu.py but values with a MPU-9250 are really erratic. I have seen this before with RTIMULIb2 but after ellipsoid calibration values were right.

Folder /home/pi/.pypilot has to be created manually or you get errors on some tools when they try to create conf files.

autopilot_calibration.py shows a wx window with a empty black window and some buttons. This message is repeated "connect failed to pypilot:21311". It seems to me that it is trying to connect to the signalk server so I start signalk/server.py but I get the same result. If I am not wrong running boatimu.py should run also the signalk server but same result. When clicking IMU tab returns this error:
Code:
Traceback (most recent call last):
 File "autopilot_calibration.py", line 267, in onPaintGLBoatPlot
   self.boat_plot.display(self.fusionQPose)
 File "/home/pi/pypilot/ui/boatplot.py", line 34, in display
   self.obj = pywavefront.Wavefront('Vagabond.obj')
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/__init__.py", line 53, in __init__
   ObjParser(self, self.file_name)
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/__init__.py", line 75, in __init__
   self.read_file(file_name)
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/parser.py", line 43, in read_file
   for line in open(file_name, 'r'):
IOError: [Errno 2] No such file or directory: 'Vagabond.obj'


It seems that the 3d object "Vagabond.obj" is not found.


I think you should check the file names on README, There are files that I have not found because it seems that you renamed them.
  Reply
#6
Ok I have found the data for pypilot in a separate repo and added vagabond.obj and now the eeror on IMU tab is:


Code:
Traceback (most recent call last):
 File "autopilot_calibration.py", line 267, in onPaintGLBoatPlot
   self.boat_plot.display(self.fusionQPose)
 File "/home/pi/pypilot/ui/boatplot.py", line 72, in display
   self.obj.draw()
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/__init__.py", line 57, in draw
   this_mesh.draw()
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/mesh.py", line 63, in draw
   material.draw()
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/material.py", line 103, in draw
   glMaterialf(face, GL_SHININESS, self.shininess)
 File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/lib.py", line 104, in errcheck
   raise GLException(msg)
pyglet.gl.lib.GLException: invalid value
  Reply
#7
(07-02-2017, 01:39 PM)Sailoog Wrote: Some issues:

LSM9DS0 IMU works great on boatimu.py but values with a MPU-9250 are really erratic. I have seen this before with RTIMULIb2 but after ellipsoid calibration values were right.

I have never used the lsm9ds0 imu. It should in theory work...

The 9250 is broken since I didn't backport the 9255 changes. The 9255 works great if you have one.

Quote:Folder /home/pi/.pypilot has to be created manually or you get errors on some tools when they try to create conf files.
good point, I should fix this. You are the first to test Smile
Quote:autopilot_calibration.py shows a wx window with a empty black window and some buttons. This message is repeated "connect failed to pypilot:21311". It seems to me that it is trying to connect to the signalk server so I start signalk/server.py but I get the same result. If I am not wrong running boatimu.py should run also the signalk server but same result. When clicking IMU tab returns this

The boatimu.py creates a server.

Try running signalk/client.py and maybe pass "localhost" as a parameter to once boatimu is running. You should be able to run "signalk/scope_wx.py localhost" as well for example. I need to fix the config. The idea is you have a config file that allows you to specify a default remote host for the server rather than passing it from the command line each time. I think it defaults to "pypilot" which won't resolve to anything unless you connect to the access point with the dns server on tinypilot...

Quote:error:
Code:
Traceback (most recent call last):
 File "autopilot_calibration.py", line 267, in onPaintGLBoatPlot
   self.boat_plot.display(self.fusionQPose)
 File "/home/pi/pypilot/ui/boatplot.py", line 34, in display
   self.obj = pywavefront.Wavefront('Vagabond.obj')
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/__init__.py", line 53, in __init__
   ObjParser(self, self.file_name)
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/__init__.py", line 75, in __init__
   self.read_file(file_name)
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/parser.py", line 43, in read_file
   for line in open(file_name, 'r'):
IOError: [Errno 2] No such file or directory: 'Vagabond.obj'
The binaries files are in a separate repository "pypilot_data" I just put on github today.

github.com/pypilot/pypilot_data

Quote:It seems that the 3d object "Vagabond.obj" is not found.


I think you should check the file names on README, There are files that I have not found because it seems that you renamed them.

Yes, sorry about this. It will get better... Thank you for testing.

(07-02-2017, 02:05 PM)Sailoog Wrote: Ok I have found the data for pypilot in a separate repo and added vagabond.obj and now the eeror on IMU tab is:


Code:
Traceback (most recent call last):
 File "autopilot_calibration.py", line 267, in onPaintGLBoatPlot
   self.boat_plot.display(self.fusionQPose)
 File "/home/pi/pypilot/ui/boatplot.py", line 72, in display
   self.obj.draw()
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/__init__.py", line 57, in draw
   this_mesh.draw()
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/mesh.py", line 63, in draw
   material.draw()
 File "/usr/local/lib/python2.7/dist-packages/pywavefront/material.py", line 103, in draw
   glMaterialf(face, GL_SHININESS, self.shininess)
 File "/usr/local/lib/python2.7/dist-packages/pyglet/gl/lib.py", line 104, in errcheck
   raise GLException(msg)
pyglet.gl.lib.GLException: invalid value
Ah I forgot about this !!!

Just comment out line 103 in material.py or add
self.shininess = min(128, self.shininess)
just before it.

I think it's a bug in pywavefront
  Reply
#8
I am impressed....

I have switched to LSM9DS0 IMU (I am waiting for some MPU-9255).

Set {"host": "localhost"} on /home/pi/.pypilot/signalk.conf

Added self.shininess = min(128, self.shininess), before line 103 in material.py

Started boatimu.py

Started autopilot_calibration.py and wow...

   
   

I am still getting some errors but all seems to work right:

Code:
Traceback (most recent call last):
 File "autopilot_calibration.py", line 79, in receive_messages
   msg = self.client.receive_single()
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 167, in receive_single
   line = self.receive_line(timeout)
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 132, in receive_line
   return self.receive_line(timeout - dt)
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 119, in receive_line
   raise Exception('invalid message from server:', line)
Exception: ('invalid message from server:', 'invalid request: unknown value: servo/calibration')
Traceback (most recent call last):
 File "autopilot_calibration.py", line 79, in receive_messages
   msg = self.client.receive_single()
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 167, in receive_single
   line = self.receive_line(timeout)
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 119, in receive_line
   raise Exception('invalid message from server:', line)
Exception: ('invalid message from server:', 'invalid request: unknown value: servo/calibration')
Traceback (most recent call last):
 File "autopilot_calibration.py", line 79, in receive_messages
   msg = self.client.receive_single()
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 167, in receive_single
   line = self.receive_line(timeout)
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 119, in receive_line
   raise Exception('invalid message from server:', line)
Exception: ('invalid message from server:', 'invalid request: unknown value: servo/Max Current')
Traceback (most recent call last):
 File "autopilot_calibration.py", line 79, in receive_messages
   msg = self.client.receive_single()
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 167, in receive_single
   line = self.receive_line(timeout)
 File "/usr/local/lib/python2.7/dist-packages/pypilot-0.1-py2.7-linux-armv7l.egg/signalk/client.py", line 119, in receive_line
   raise Exception('invalid message from server:', line)
Exception: ('invalid message from server:', 'invalid request: unknown value: servo/Max Current')

I have a million of questions about these settings but I can not keep testing today, I just wanted to say you congratulations. Thinking of how to apply now...
  Reply
#9
Yes, the servo calibration is obviously missing because you are running boatimu which doesn't command a servo like an actual autopilot implementation. You could try basic_autopilot, but it doesn't matter without an actual motor. You might just ignore this message.

Also... the calibration should have locked on.. Something is not working quite right. After a few minutes, the red sphere should fit the data points.
  Reply
#10
Ok to servo, this will be the next step.

Compass calibration. Today I am waiting for a MPU-9255, I will test again with this. Could this be the reason?

IMU calibration. I think all is working right. The field Model is disabled, what is the function of this field?

Scope windows fail:

Code:
Traceback (most recent call last):
 File "/home/pi/.config/pypilot/ui/../signalk/scope_wx.py", line 123, in onPaintGL
   self.plot.display()
 File "/home/pi/.config/pypilot/signalk/scope.py", line 319, in display
   self.drawtext()
 File "/home/pi/.config/pypilot/signalk/scope.py", line 260, in drawtext
   SignalKPlot.synccolor()
 File "/home/pi/.config/pypilot/signalk/scope.py", line 225, in synccolor
   glGetDoublev(GL_VIEWPORT, vp)
 File "/usr/lib/python2.7/dist-packages/OpenGL/latebind.py", line 41, in __call__
   return self._finalCall( *args, **named )
 File "/usr/lib/python2.7/dist-packages/OpenGL/wrapper.py", line 570, in wrapperCall
   pyArgs = tuple( calculate_pyArgs( args ))
 File "/usr/lib/python2.7/dist-packages/OpenGL/wrapper.py", line 347, in calculate_pyArgs
   args
ValueError: glGetDoublev requires 1 arguments (pname), received 2: (GL_VIEWPORT, <OpenGL.constants.c_double_Array_4 object at 0x6de02490>)
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)