Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 09-07-2018, 07:49   #46
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 3,301
Re: PyPilot

Not sure which motor controller you used, but you may need to modify the source.

It would be great to hear how it works.
__________________

boat_alexandra is offline   Reply With Quote
Old 09-07-2018, 08:31   #47
Moderator
 
sailorchic34's Avatar

Cruisers Forum Supporter

Join Date: Feb 2011
Location: SF Bay Area
Boat: Islander 34
Posts: 5,151
Re: PyPilot

Quote:
Originally Posted by boat_alexandra View Post
Not sure which motor controller you used, but you may need to modify the source.

It would be great to hear how it works.
I'm using a Cytron 13A, 5-30V Single DC Motor Controller, from robotshop.com. It uses two pins for pwm and direction, or one pin using pwm for left and right with 50% duty being off.
Yep, I expect I'll need to modify servo.py a bit.

Going to be a few weeks before I travel to where the parts are waiting for me.
__________________

sailorchic34 is offline   Reply With Quote
Old 09-07-2018, 13:22   #48
Registered User

Join Date: Feb 2016
Posts: 25
Re: PyPilot

i would be interested too.. if you get it to work with an h-bridge.
jim321 is offline   Reply With Quote
Old 06-08-2018, 03:02   #49
Registered User

Join Date: Aug 2018
Posts: 3
Re: PyPilot

I found pypilot a month ago, but have not yet tested it.



I have accurate GSP compass in my boat and wonder can pypilot use it's 20 Hz heading information? Or would it be reasonably simple to implement pypilot to use it? I can provide heading information either by serial or network server.
timolappalainen is offline   Reply With Quote
Old 06-08-2018, 06:41   #50
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 3,301
Re: PyPilot

pypilot uses the gyro to compute heading at high rate, not GPS. From there the kalman filter uses the compass to correct gyro bias and integration errors.

The GPS is optional. GPS cannot compute the heading the boat is facing, only the direction it is moving, so this depends on currents as well as sideslip.

GPS is also bad at computing heading at low speeds, especially below 2 knots boat speed. unless you have differential GPS, with multiple antennas, but I have not heard of anyone who has dgps on their boat.

Also typically GPS has a lag. Not sure about your high rate gps, but most lag by a few seconds. If you send this data over a network the lag can be even higher.

If you want to steer to GPS for true north or for route following, the GPS is filtered and the angle between GPS heading and compass heading is computed. The autopilot follows this constantly changing compass course. You could change the tuning of the filter if your GPS is better.

I don't know what GPS you have, but I wouldn't be surprised if it had inertial sensors as well at least if the 20hz data is really good.
boat_alexandra is offline   Reply With Quote
Old 06-08-2018, 08:14   #51
Registered User

Join Date: Aug 2018
Posts: 3
Re: PyPilot

It is GPS compass not just GPS. GPS compass gives you exact direction in any speed also at 0. My GPS compass has 2 antennas, but some uses three antennas. This is better than any solid stare gyro I have ever got for testing. It is also insensitive for any metal like brigde or ship around. With solid state compasses my boat made allways curve with autopilot under bridge or big ships near - GPS compass keeps track.


GPS compasses also start to rather common. With 1000 $ you can get reasonably good GPS compass, while you have to pay 600-700 $ for solid state compass. GPS compass either need any other that offset calibration. This is of course still lot compared to 10 € shield.



Also this is not lagging. It provides 5 Hz for Raymarine pilot, since Raymarine works best with 5 Hz. I can change it up to 20 Hz. It has some internal gyro for calculations.



I have radar overlay on my nav system and it was also turning with solid state compass specially on gusts, when boat suddently tilted. GPS compass is also insensitive for that - heading stays and right in any boat tilt angle.



Check e.g. https://hemispheregnss.com/Products/...sition-Heading


It is about 4-5 years since I last time made comparison between solid state gyros, so the situation may be different. But why I should move to more inaccurate system?
timolappalainen is offline   Reply With Quote
Old 06-08-2018, 11:22   #52
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 3,301
Re: PyPilot

Quote:
Originally Posted by timolappalainen View Post
It is GPS compass not just GPS. GPS compass gives you exact direction in any speed also at 0. My GPS compass has 2 antennas, but some uses three antennas. This is better than any solid stare gyro I have ever got for testing. It is also insensitive for any metal like brigde or ship around. With solid state compasses my boat made allways curve with autopilot under bridge or big ships near - GPS compass keeps track.


GPS compasses also start to rather common. With 1000 $
The gps I am using cost < $20, and the gyros and compass. With that you can get basically the same performance for practical purposes of autopilot, unless as you say, you are near a bridge or ship or something.
Quote:
you can get reasonably good GPS compass, while you have to pay 600-700 $ for solid state compass. GPS compass either need any other that offset calibration. This is of course still lot compared to 10 € shield.
For mpu9255 (if you are lucky and don't get a bad part) and calibration is automatic. It's already more than enough accuracy.

Quote:
Also this is not lagging. It provides 5 Hz for Raymarine pilot, since Raymarine works best with 5 Hz. I can change it up to 20 Hz. It has some internal gyro for calculations.
there is always some amount of lag depending on how the data reaches the autopilot. With the intertial sensors on i2c, the lag is less than 100 milliseconds.. with wireless or other network links, the lag can be variable.

Typical gps, lags more for speed and direction because only one antenna is used.
Quote:

I have radar overlay on my nav system and it was also turning with solid state compass specially on gusts, when boat suddently tilted. GPS compass is also insensitive for that - heading stays and right in any boat tilt angle.
your solid state compass is not working correctly. Probably lacking a 3d calibration which gives heading errors on tilt.

pypilot automatically calibrates the compass for both 2d and 3d when possible, but although the relative precision is fine for tracking, it may be noticable for something like a radar overlay.

Quote:
Check e.g. https://hemispheregnss.com/Products/...sition-Heading


It is about 4-5 years since I last time made comparison between solid state gyros, so the situation may be different. But why I should move to more inaccurate system?
1000 euro for a gps is out of reach for most of us, so the autopilot is unlikely to be tested or have much feedback using these sensors and I do not have access to them at this time.


To properly take advantage of differential gps in the autopilot you would need to modify the source code, which is possible to do because pypilot is free software.
boat_alexandra is offline   Reply With Quote
Old 06-08-2018, 21:42   #53
Registered User

Join Date: Aug 2018
Posts: 3
Re: PyPilot

Quote:
Originally Posted by boat_alexandra View Post
there is always some amount of lag depending on how the data reaches the autopilot. With the intertial sensors on i2c, the lag is less than 100 milliseconds.. with wireless or other network links, the lag can be variable.
Also Raymarine has build in gyro. Then it just uses heading info from bus for correcting internally calculated heading. That was I though could be also on pypilot.



Quote:
Originally Posted by boat_alexandra View Post
your solid state compass is not working correctly. Probably lacking a 3d calibration which gives heading errors on tilt.
As I said it was 4-5 years ago and development has been huge after that.


Quote:
Originally Posted by boat_alexandra View Post
To properly take advantage of differential gps in the autopilot you would need to modify the source code, which is possible to do because pypilot is free software.
PyPilot could have two choices:

1. Use HDG message from, if it is available. It should fix internal HDT, when message arrives.
2. Provide HDG message to the bus.


In this way one could have one single HDG info at boat. As I have GPS compass and N2k bus, I have one heading for all devices.


I could change PyPilot, but since code is totally new for me, it may take several hours or days and I do not have time to study the code - unfortunately. Instead as with any own code (like my NMEA 2000 library https://github.com/ttlappalainen/NMEA2000) I can make improvements relatively easy compared to someone who is not familiar with NMEA 2000 logic. To get HDG for testing, one can e.g. use my NMEA Simulator (see. Kave Oy)
timolappalainen is offline   Reply With Quote
Old 18-08-2018, 18:55   #54
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 11,391
Stepper Motor - Controller -Arduino

rgleason is offline   Reply With Quote
Old 29-08-2018, 13:03   #55
Moderator
 
sailorchic34's Avatar

Cruisers Forum Supporter

Join Date: Feb 2011
Location: SF Bay Area
Boat: Islander 34
Posts: 5,151
Re: PyPilot

Well over the last 6 weeks I taught myself python, command line linux, learned all about the Pi SBC's, and studied the Pypilot code.

End the end, I wanted to start with a more basic autopilot then Sean's most excellent Pypilot. Plus being an engineer, I wanted more buttons .
So I started with Seans boatimu.py file and wrapped my own python autopilot code around it. It was easier for me to do that then to delve deep into Sean's code to understand how it all worked.

So I have a basic autopilot controller that also runs openplotter/openCPN in the same pi3 box. With openCPN and my apilot running, process load was 3% to 15% with 30% memory used. I added a basic wired remote (harder for it to fall overboard), using a cheap 10/100 cable for the 20 feet of wire. I already had the extra buttons. I may add a wireless remote in the future as well.

It's bench tested, but it will be a few weeks before I take the Rose out again to give it a real world test. I included some options to change motor gain, etc.

Once the basic system is tested and adjusted in real life, I'll add in a Nema 0183 parser, the glue to openCPN and a rudder position sensor.

I have a bit bigger box then Sean's. It has a gasketed cover and watertight bulkhead connectors for power, motor and remote/gps. There is room inside for a small I2c 4 channel AD converter and a GPS puck.

It oddly would be pretty easy to get pypilot running on it now as well. But for me that's far less fun to do.

My total cost with Remote and a Pi3 is less then $140.

I'll report back in a few weeks after I take my first sail with it.
Attached Thumbnails
Click image for larger version

Name:	autopilot.jpg
Views:	60
Size:	396.0 KB
ID:	176411  
sailorchic34 is offline   Reply With Quote
Old 29-08-2018, 15:43   #56
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 3,301
Re: PyPilot

Great to hear about this, and also I am glad you can adapt the code to make use of it. It's a good idea to at least adopt boatimu.py because it already autocalibrates the sensors and runs the kalman filter, so the rest is much simpler.

My autopilot _does_ support wired buttons, as well as IR remote (I'm waiting on parts for wireless remotes) I support nokia5110 display with a complete menu interface. The code to do that is in lcd/client.py It is a separate process so as not to interfere with the main autopilot code which runs in a real-time priority process.

The same is true for the nmea parsing, and webapp etc... They are separate processes to avoid interfering or lagging the critical autopilot loop.

I hope you are able to make use of the "signalk_client" "signalk_client_wx" and "signalk_scope_wx" tools to help tune things.

What sort of motor controller are you using?
boat_alexandra is offline   Reply With Quote
Old 29-08-2018, 16:10   #57
Moderator
 
sailorchic34's Avatar

Cruisers Forum Supporter

Join Date: Feb 2011
Location: SF Bay Area
Boat: Islander 34
Posts: 5,151
Re: PyPilot

Quote:
Originally Posted by boat_alexandra View Post
Great to hear about this, and also I am glad you can adapt the code to make use of it. It's a good idea to at least adopt boatimu.py because it already autocalibrates the sensors and runs the kalman filter, so the rest is much simpler.

My autopilot _does_ support wired buttons, as well is IR remote, and nokia5110 display with a complete menu interface. The code to do that is in lcd/client.py It is a separate process so as not to interfere with the main autopilot code which runs in a real-time priority process.

The same is true for the nmea parsing, and webapp etc... They are separate processes to avoid interfering or lagging the critical autopilot loop.

I hope you are able to make use of the "signalk_client" "signalk_client_wx" and "signalk_scope_wx" tools to help tune things.

What sort of motor controller are you using?
Yes the autocalibration and kalman filter sold me on boatIMU.py. I tried two others on github and they lacked both features. Makes it easy peasy to get heading info with all the heavy lifting done.

I'm using a Cytron 13A H bridge from robotshop.com ($14 ish) for the motor controller. Good for 13A continuous and 30A intermediate use. It has separate leds that light when forward or reverse is active. Direction uses one pin and PWM the other and third pin ground. It's powered from 12V. https://www.robotshop.com/en/cytron-...ontroller.html
sailorchic34 is offline   Reply With Quote
Old 29-08-2018, 16:37   #58
Registered User
 
boat_alexandra's Avatar

Join Date: Aug 2009
Location: chesapeake bay
Boat: bristol 27
Posts: 3,301
Re: PyPilot

Quote:
Originally Posted by sailorchic34 View Post
Yes the autocalibration and kalman filter sold me on boatIMU.py. I tried two others on github and they lacked both features. Makes it easy peasy to get heading info with all the heavy lifting done.

I'm using a Cytron 13A H bridge from robotshop.com ($14 ish) for the motor controller. Good for 13A continuous and 30A intermediate use. It has separate leds that light when forward or reverse is active. Direction uses one pin and PWM the other and third pin ground. It's powered from 12V. https://www.robotshop.com/en/cytron-...ontroller.html
What IMU sensors do you have? A few are pre-calibrated accelerometers, but for ones that are not, I just added code to calibrate them automatically as well. You need to hold them in 6 sides of a box perfectly still for a few seconds to perform this.


By all means do your own thing, it's fun to create your own autopilot, but keep in mind, I have already developed opencpn plugins for full control, as well as tuneable route following logic, and recently autopilot related watchdog alarms. The nmea parsing and gps and everything is working... but please have fun hacking whatever you like. You could maybe try "simple_autopilot.py" instead of "basic_autopilot.py" but it's only slightly simpler. I am continuing to develop logic, and machine learning is coming soon!


You should be able to hack in support to servo.py to drive the controller if you do decide to use the full pypilot. The pi should have 1 hardware pwm you could use for this.

I initially did drive an ESC directly from the pi in this way, but started using arduino because I needed to measure voltage, current, temperature and rudder feedback and rudder stop switches as well, and arduino is actually the simplest and cheapest way to add an ADC to the raspberry. Then I needed optical isolation to protect the raspberry from the motor controller, and doing this over a serial port is less isolators than spi. The arduino can react faster to overcurrent than the raspberry as well.

You will want some sort of feedback to prevent the motor stalling at end of travel. If you get it working I would like to hear about it.
boat_alexandra is offline   Reply With Quote
Old 29-08-2018, 18:58   #59
Moderator
 
sailorchic34's Avatar

Cruisers Forum Supporter

Join Date: Feb 2011
Location: SF Bay Area
Boat: Islander 34
Posts: 5,151
Re: PyPilot

Quote:
Originally Posted by boat_alexandra View Post
You will want some sort of feedback to prevent the motor stalling at end of travel. If you get it working I would like to hear about it.
My goal is to add a rudder position sensor that will give feedback and limit travel. It does require a AD converter. There is a single chip one that can be wired I2C for a few dollars. That's my winter project.

I like the Pypilot software I looked at your code and it's a very nice system. tons of options. I had originally thought to use it. But I wanted a bit more of a challenge. So doing my best to roll my own. I'm using the Luma-LCD python code for the Nokia 5110

Oh I'm using a Wingoneer MPU-9255 heading sensor (amazon). It worked very well with your boatIMU code.
sailorchic34 is offline   Reply With Quote
Old 03-09-2018, 08:55   #60
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 11,391
Re: PyPilot

Sean has updated Pypilot 0.8.0
__________________

rgleason is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 15:57.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.