Ardupilot goes into the water Part 13

Long time - no sea.

If anybody will tell me about global warming - i will kill him!
We had the coldest (and rainiest) may and june ever.

And August was - the rainiest ever.


Globalization only seems to work in the financial domain, but not for the weather. What about a "weather-transfer" of bad weather to the sahara? They will appreciate the rain there. Despite this fact and the passing away of a close relative, i wished, these months had never happened.

In mid-july, we have seen that this spherical fusion-reactor some eight light-minutes away is still running. I am personally not a fan of nuclear energy, but in this case...

What happened since my last entry?
Not really much.

The new cat has now the same color on both hulls.
The board, that holds the hulls together is now coated with fiber and epoxy to make it more rigid.
The extra battery for the sonar was dropped. The power comes now from the main battery. (-300g of weight)
The cable from the sonar to the transducer was shortened (-100g)

This was really not much, but there are still some challenges out there...

Swimming is not one of my favourite disciplines.
Swimming in bad weather conditions does not even make it better.
Swimming is OK, considering the following conditions:

1. It is summer (I mean that season, when it should be really warm)
2. You have enough time to put on your swimming suit, when the boat starts to react weird.
3. You love swimming
4. No rain

if any of the above is not applicable, staying on the shoreline is the better option.

Swimming is usually caused by:

1. Software
2. Mechanics and Hardware
3. Personal idiocy
4. A combination of the above


To prepare the this year "PID optimization campaign" i decided, to reduce my recovery-swimming exercises to a minimum and thought about Radio Control.

First, i fiddled with my 27MHz RC control from the Jetski model, but found out that this thing is abolutely crappy. Bad range performance, noisy and most of all: no failsafe behaviour. I wanted the software on the ardupilot to decide, whether there is a transmitter controlling the ship or not. And therefore i have to measure the pulses comming out of the Receiver. So far so good, but the 27MHz Rx outputs always some pulses, regardless, if the Tx is on or off (the good old analog era...).

I remembered, that the Ardupilot was originally conceived as a fail-safe
system with an RC option as a fallback for the safe launching and landing
of an airframe.
Why not using this feature for the boat?
Reading the docs and the software showed, that the implementation, which is
in the original version of the Ardupilot was not exactly what i needed.

My requirements were:

1. If the transmitter is OFF or the Receiver is out of reach, the boat shall
be fully controlled by the Ardupilot.

2. If the Transmitter is ON, control shall be passed to the Radio control.

Implementation on the original version was a little bit different,
so i decided to do it my own way.

How to detect if the RF is good or bad?
The only way is to look at the servo pulses, that come out of the Receiver.
Analog RC Systems output always something on the servo channels, even when the Tx is OFF. (see above)
Discrimination between noise and a good signal would be possible by some weird SW algorithms, but i wanted to keep it simple.

A very old friend of mine, who is an RC Dinosaur told me to buy a 2.4GHz RC control.
So i ordered a SPEKTRUM DX5e, which is a fairly priced entry level model.
Reading the manual showed, that the failsafe functionality of the receiver was exactly that what
i needed. Manuals sometimes do not tell the truth, so i oscillographed the servo outputs and found, that
they really told the truth:

1. When the receiver is turned ON without a Transmitter beeing in the air, there is silence on all servo outputs - good.
2. When the Tx is turned ON and the Rx is correctly bound to the Tx, pulses on all channels - good.
3. When the Tx is switched OFF, silence on all channels, but not on the throttle. The throttle channel outputs a pre-programmed default pulse-width. - still good.

From the software point of view, it is very easy to distinguish between silence and "something". So i took the rudder channel to sense the RF.
(Tx ON --> pulses, Tx OFF --> silence)

Technically, all worked fine.

right in the middle: the Receiver.

I have put the code here:


Please note, that the Hardware of the Ardupilot board has to be
modified!
Read the comments in the RC_Control tab.
I have refactured some of the code and added some comments.
WITHOUT testing it. Take the code as a starting point for your own
experiments.


Thats all for today, on the next episode i will tell the experience with the RC control on the lake and why i decided not to use the RC any more.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • future weather wil be not hot and not cold, but unpredictable.

    The overeglobe wind passate system now brocken and warm air from carrebean bring huge ammount of water not to jungle, but to the north of the earth.

    Therefore much ammount of  rain and snow will be in USA, Canada and Europe.

    and only good place to live and work is islands near the equator.

    welcome :-)

  • Dylan,

     

    yes i can :-)

     

     

  • Hi all, I have a quick question.
    I just got a boat driven by two motors- there is no rudder. I was looking at the sketch for this one and it would be fantastic for my project, but I only have basic programming skills and don't really know how to go about modifying it to steer by adjusting each motor's power without messing things up. If you could help me out, that would be so great!
  • Hi JD,

    i had a closer look to your waypoints. They are very close together (some 20m away) this is very close to the threshold for the waypoint-hit. And, this may cause big differences between the setpoint and the actual bearing, which in turn causes large rudde movements. I did my tests with waypoints that were at least 50m away from each other.

    This may cause some addtional meters of swimming :-)
    Buy a body-board and fins.

    By the way: lovely cats on your homepage.
    This one was one of mine:


    regards
    Harald
  • Hi JD,

    hm...
    If the hull is stable, you can concentrate on the ArduPilot.

    First, you may have a look at the center Position of the rudder servo, when driven by the AP. Maybe this differs from the RC one. you can adjust that by the #define MIDDLE_YAW directive.

    Maybe the "excellent turning capability" of you boat is the problem, if it reacts very sensitive to the joystick movements.
    reducing the KP_HEADING will help.
    I know, adjusting all this parameters can be very frustrating, but it gives a lot of know-how and if you finally have success, you will know, that is was worth doing it. Keep on...

    Regards
    Harald
  • Harald,
    I now remember reading about your earlier problems with the fire brigade ship... my boat is an R/C model from Radio Shack called the Tsunami. I found it at a thrift-store for $15 with a good motor, propeller, and no dings or dents. I removed the electronics and rudder motor and replaced them with the Ardupilot, R/C receiver, and brushed ESC for the DC drive motor. I replaced the factory DC steering motor with a Servo motor to be compatible with Ardupilot and the R/C equipment, and it works well. The boat drives very nicely with the R/C setup - keeping a pretty straight line when I leave the stick centered. The boat also has small fins protruding down the length of the hull on both sides. I have a battery pack (8AA NiMh = 9.6v) that is mounted below the electronics (see pictures) in the center of the hull. I cannot put all the weight at the rear of the boat due to the Servo steering mechanism, but it is as far back as the interior will allow, and as I said it drives very nicely with the R/C setup - keeping a straight line if left alone, but it has excellent turning capabilities if the stick is pushed to the left or right.

    Pictures:
    ftp://ftp.rediculouslygoodlooking.com/arduino/boat1.JPG
    ftp://ftp.rediculouslygoodlooking.com/arduino/boat2.JPG
    ftp://ftp.rediculouslygoodlooking.com/arduino/boat3.JPG

    thanks again for your help!

    ~JD

    I will try your suggested settings, and maybe try some new ones tomorrow. If needed, I may build a catamaran style boat like yours - I already built a fiberglass/balsa-wood boat from scratch, but the propeller placement/size and hull shape would not allow it to plane on the water, so I decided to get the Ardupilot working with a pre-made boat hull first.
  • Hi JD,

    nice to hear, that the GPS is working again.
    I have had a look to your code and found nothing pathological.

    The behaviour, that you are describing (the circling) sounds very familiar to me :-)

    It seems, that your hull is not stable enough to hold a straight line. I already had the same problems with my firebrigade ship.

    You can try this:

    First, look, where the keel weight is located (if you have any). If the weight is in the vicinity of the ship´s center of gravity, this may cause instable behaviour. Moving it more to the aft may make it better.
    What you can also try, is to add some kind of fins to the aft of your keel.
    (try some plastic or Balsawood, that you can fix with hot-glue or the like)

    Second,  try fiddling with the KP_HEADING parameter, because the one i used is optimized for my monokeel assembly. If you have oscillations, try to reduce at least by a factor of two and make the the integrator and derivator part close to zero. Try the following parameter set as a starting point:

      #define KP_HEADING 0.3
      #define KI_HEADING 0.0005
      #define KD_HEADING 0.0001
      #define MOTOR_SPEED 80
      
    This is a mere P-controller, which makes optimization more easy.

    But keep in mind, that the geometry of the ship plays the key-role for good stability. This is why i left the mono-hull approach and moved to a catamarane design. The monohull (firebrigade ship) i have used, worked quite well after lots of optimizations, but there were still oscillations.

    Can you provide some photos of your boat?

    Regards 
    Harald
  • Harald, I got the GPS working again, blue fix light is on - but when I switch into autopilot mode, the boat begins going in a figure 8 over and over. I thought the rudder might need reversing, but it did the same thing when I tried.

    I tried to remove your extra sets of waypoints to make things simpler, as well as removing the code for controlling the Mux pin. Would you mind looking over my revisions to see if I did something wrong?

    my changes:

    ACME.pde = commented out "Ifdef RADIO_CONTROL" lines
    arudpilot.pde = commented out "check_radio" lines, removed extra sets of waypoints, I am using "long_keel", so removed catamaran settings for simplicity in code.
    init.pde = commented out "init_RC_control();" and "switch_to_ardupilot();"
    RC_control.pde = commented out entire tab

    Here is link to files:
    ftp://ftp.rediculouslygoodlooking.com/arduino/ArduPilot_water_modif...

    thanks,
    JD
  • If you don´t want to wait one week, try this:


    // command sequence to switch back from SIRF to NMEA

    unsigned char gpsbuf[] =

    { 0xA0, 0xA2, 0x00, 0x18,

    0x81, 0x02, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x05, 0x01, 0x01, 0x01,
    0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x25, 0x80,

    0x01, 0x3A, 0xB0, 0xB3};


    int i;

    void setup()
    {

    Serial.begin (9600); // or whatever baudrate has been seet previously
    for (i=0; i<= 31; i++)
    Serial.print(gpsbuf[i], BYTE);
    ...


    regards
    Harald
  • I am using the EM406, and it seemed to connect fine using your code (I also have my Xbee radios set for 9600bps to work with your code, which works well).

    I loaded the Ardupilot v1 code, and in a state of confusion, used the Bind plug to try to get the GPS to get a lock.... I think this put the EM406 into binary mode - so I guess I need to wait a week or so for it to completely discharge.

    I will also test the throttle output with an oscilloscope to see what is going on there.
This reply was deleted.