Re: Position hold not working
« Reply #15 on: November 07, 2019, 08:36:10 pm »
Quote
I needed to have the USB cable plugged in to arm it - even if the cable was not connected to anything
Yea, that sounds like it is magnetized.  As posted earlier, get a second USB cable and use it while waving the first one around the FC (and watching the raw mag sensor numbers in System->DataObjects->MagSensor or on the MagSensor scope) to see if the first USB cable is magnetized enough to matter.

From your profile timezone, I had guessed that you were in Europe.  Your uav file HomeLocation is Albany / Berkely California USA though.  HomeLocation must be close to where you are flying.  If you are flying in Europe, you shouldo set HomeLocation there.  I personally have used a HomeLocation 40 miles away and the only bad thing was that the GPS map was off a couple hundred yards.  VR worked fine.

If your HomeLocation is a significant part of the world away ... I don't know, there may be issues, like because 6 timezones away the level ground is 90 degrees rotated to what it is where you are and the coordinate system is a normal Cartesian / rectangular one based at HomeLocation and you can see that left / right here may be up / down there.  I don't expect there to be an issue with this.  I would guess that the code just treats it as a flat earth and that works fine.

trust

  • ****
  • 301
Re: Position hold not working
« Reply #16 on: November 07, 2019, 10:50:20 pm »
Ok, the combo GPS/mag arrived, so I wired it up and mounted it. Changed the HDW settings and switched the magnetometer settings to aux mag only. Then ran calibration.
GPS is showing 16 satellites - so no problem there.
But I've tried calibrating twice, and I can't get the aux mag health to be under 20% - its almost always red.
The onboard one is showing green, as long as the USB cable is plugged in.
Attached see pix of mounting - plane arrow is pointed forward - correct?
And no, I'm not in Europe but in Albany as per GPS home loc.

Re: Position hold not working
« Reply #17 on: November 08, 2019, 12:43:42 am »
On Attitude -> Magnetometer page:
Mag usage = AuxOnly
Mag Type = DJI
Warning / Error = .05 and .15
Aux Mag Orientation = 0, 0, 0
(save it :) )

You haven't taken the GPS apart with a magnetized screwdriver have you?  That can magnetize the screws somewhat.  I've also had to demag a mag sensor one time.  Bulky steel watch?  I don't suspect that any of this is your problem though.

Is your GPS mast firmly mounted yet?  The GPS/mag and the FC must be locked together since the FC sensors are used to understand where the mag sensor is pointing.  I notice in the picture that it is leaning a little to one side.  Lock it down nice and vertical in a way that won't move between calibration and flight.  :)

I had a question at one time about the fact that INS13 uses a mag when calibrating a mag and that is not good.  For the mag cal, change Attitude->Settings->AttiEstAlgo to "Basic (Complementary)".  I don't recall if it does this automatically yet.  Recall that you must leave the quad motionless at power on till the fast blinking stops.  A human can't hold it still enough for this to work well.

Try my way of calibrating the mag sensor.  Point each of the 6 faces of the cube that is the quad (nose, tail, right, left, bottom, top; order is unimportant, but that is the order I use) along the north magnetic field lines (60 degrees down and north) and wiggle (rotation pointing wiggle) around a little each time.  And try to keep the USB cable away from the new GPS the whole time.  And do it outside and say 100 feet away from cars and other big metal.  I would avoid subdivision power lines too till we get this thing understood better.  Just make a good guess for the direction.  The wiggling should get you closer yet.
https://forum.librepilot.org/index.php?topic=4741.msg31914#msg31914

If it still won't calibrate, I would look at System->DataObjects->AuxMagSensor x,y,z the way I described, but note that you are using AuxMagSensor.  Example that pointing nose along north mag field lines, the x should be the largest and it should be positive.

You will want to do a thermal calibration too.  It mainly helps the baro maintain the same altitude whether the board is warmed up 10 minutes or not, and if done over a wide range will handle winter vs. summer flying too.
« Last Edit: November 08, 2019, 01:04:53 am by TheOtherCliff »

trust

  • ****
  • 301
Re: Position hold not working
« Reply #18 on: November 08, 2019, 07:23:04 pm »
Partial success. I tried changing the attitude estimation to basic, then doing a calibration. Oddly, the aux mag still showed red and large values. At first I thought - nuts, not working. But I set the attitude estimation back to GPS - and now the aux mag health was solid green! I could move it around and it stayed green. Did a short test flight - solid.
  So went to test field and tried it. It allowed arming pretty fast - within 30 seconds or so. I waiting a bit to let the gps settle some more, then armed and flew it. Hover was very solid - but then there was no wind today.
  I took it up to about 50' and switched to VelocityRoam. It didn't move at all. Yah! But aren't you supposed to be able to move it with the sticks? At least yaw? I didn't move them much, does it need large inputs? At any rate, there was slight drift, but it held stable. I wasn't able to move it in this mode. I can't find any documentation on this mode either. Link?
  So I tried RTB. It began a wide arc yawing movement heading SW. It went well past where I was. I stopped it and flew back.
I tried landing it, disarming, rearming, (I assume this reloads the base location?) and tried again. This time it took off to the north - I let it go almost too far. I had trouble telling orientation - but I eventually got it back.
FYI - if it was heading to the Albany home location, it should have gone east. But it didn't.
  Just for verification, I'm enclosing the settings.
  Previously when I checked the GPS, it was getting 16 satellites, so it seems great on the GPS mode.
So I think the aux mag is working now. Just not clear what's going one with these modes.

trust

  • ****
  • 301
Re: Position hold not working
« Reply #19 on: November 08, 2019, 07:52:30 pm »
Addendum - I set the system up in my office and looking at the TakeOffLocation parameters after arming it. They do get set, but the units are in meters? Is this an offset from the home location? Or what?

Re: Position hold not working
« Reply #20 on: November 09, 2019, 01:25:03 am »
The precise HomeLocation is not anything a normal user needs to know, except that it should be fairly close to where you fly.

TakeoffLocation is based on HomeLocation.  For instance 0,0,0 says it is exactly HomeLocation.  It gets set at different times, but by default, when you Arm.  TOL is the place it returns to when using RTB.

Before the first flight of the day, you should let it sit, powered up, gathering GPS almanac for preferably 12 minutes.  I don't always obey that either...  For each flight after the first, at least 2 minutes.  This is probably not your problem.  If you have stopped using Always Armed, it should be good enough to be better than you are getting, once it lets you arm.

I assume you are using the exact mag settings I posted.

Are you always flying at the same location?  Power lines?  Heavy industry?  Car junk yard?  RF interference?  Government secure area GPS spoofing (I hear there are some areas where car GPS doesn't work for no good reason).  Try another place.

VtolPathFollowerSettings has some interesting things in it.  I assume you have not changed anything from the defaults.  For instance HorizontalVelocityMax is the speed that you get with full roll or pitch stick when flying VR.  The default is 10 meters per second.  It's proportional, so even 1/10th of full stick gives you 1 m/s which is about walking speed.  Moving the stick at all in VR does produce noticeable motion.

I suggest you switch on transmitter, plug in the quad battery, plug in USB / GCS, go to Input -> FlightModeSwitch page and flip the mode switch on the transmitter around.  That will tell you what mode you are in.  Then go to Input page and make sure the switch positions are in the middle of the section for each mode.  Right on the edge can drift to be a different mode.

Maybe get an OpLink and make a video and telemetry flight log of the same flight.  There may be some alarm codes to look at, etc.

Maybe something is set up wrong.  There are plenty of cases where a fix seems to work, but two wrongs don't make a right.  Save your settings, erase, and redo the simplest setup (no OSD or gimbal) from default settings (not a cloud config).

f5soh

  • *****
  • 4572
    • LibrePilot
Re: Position hold not working
« Reply #21 on: November 10, 2019, 02:39:20 am »
Addendum - I set the system up in my office and looking at the TakeOffLocation parameters after arming it. They do get set, but the units are in meters? Is this an offset from the home location? Or what?
NED (North, East, Down) coordinates from HomeLocation, in meters.

Re: Position hold not working
« Reply #22 on: November 10, 2019, 06:11:11 am »
I went over your settings more carefully and I found a likely issue.

airframetype should be quadx, not custom
  for custom, you should have set VtolPfSettings.TreatCustomAs = VTOL
    and it is supposed to work, but the code doesn't seem to check this secondary case in all cases
    but it is set to FIXEDWING which is definitely wrong and may be the cause of some things not working
  for the sake of this issue set airframetype = quadx
  do not set it on the Vehicle page or you will loose your current mixer and motor numbering
    not a real issue, but you can avoid re-entering that stuff by doing the following
  System->Settings->SystemSettings->AirframeType = QuadX
    then click on AirFrameType to highlight the line
    then press the red up arrow at the top of the screen to save it
    after that, you can go to the Vehicle page and make sure things look right

disable piroette comp (Stabilization page)
  this is especially a problem if your quad is out of balance with a camera hanging off of one end
  it will fly better in some modes

until you get a demagnetized USB cable to calibrate with,
  when you want to try to use the onboard mag,
  fly with the usb cable plugged in, the one used while doing mag cal
  "aux mag only" should be immune to being calibrated with a USB cable
  aux mag page may have funny values for onboard mag
    and so the bar graphs will not be right since they compare onboard to aux
      you will just have to ignore that

trust

  • ****
  • 301
Re: Position hold not working
« Reply #23 on: November 10, 2019, 08:08:50 pm »
Success! That aircraft type setting was the problem. I can now VelocityRoam, and if I take hands off sticks it holds position nicely. I can yaw and tilt in any direction.
Also RTB works! I moved it several times to different positions and directions away and when switched to RTB it would head back to a position directly over my head. There seemed to be a bit of hunting - it would move for 30-40', slow down, then move again in a similar stepwise fashion. But it got there every time.
Not sure how it ended up as custom. When initially set up, it was set as a 450 size quad. But I may have played with the motor mixer setting in the custom tab. Not sure.

Thanks so much for working me through this!

As far as I know, virtually all USB cables use a metal plug end - and it contains some ferrous material. If there are any that don't I'd love to hear about them. Barring an ability to demagnetize the ends, I suppose just having a short stub you could leave plugged in might work. But the GPS/mag unit you recommended seems to work very well - it pulls in more satellites than the other one, plus it avoids the whole USB connector issue, plus it seems to lock in quickly - maybe 30 seconds from power on to all green when first moved to a new location. I have it set for aux mag only.
I did also turn off the pirouette mode. Not sure it made any improvement - I balanced the camera pretty well by adjusting the battery position to counterweight the camera.

Now that it works on a quad, I will be testing it on some of our experimental VTOL aircraft, which are more like fixed wing aircraft than quadcopters.

Re: Position hold not working
« Reply #24 on: November 10, 2019, 09:20:23 pm »
Having Pirouette Compensation enabled only affects pirouettes, i.e. yaw motions.

An unbalanced copter with PC enabled will wobble if you hover and use a lot of yaw.  Even worse, it will shoot off in some direction when you stop the yaw.  Videos linked in this post:
https://forum.librepilot.org/index.php?topic=4651.msg31493;topicseen#msg31493

I should clarify that Pirouette Compensation gets automatically disabled for self leveling modes like Attitude, Rattitude, VelocityRoam, etc.  Use it mainly for Rate and VirtualBar.  It can be enabled for Acro+, but that should probably be avoided since Acro+ can basically disconnect the gyro that tells PC where it is.
« Last Edit: November 13, 2019, 04:03:15 am by TheOtherCliff »

trust

  • ****
  • 301
Re: Position hold not working
« Reply #25 on: November 16, 2019, 02:17:02 am »
I did some more testing of VelocityRoam and RTB. They both seem to be working basically fine, but in both cases, if the quad sits in one position (or when RTB returns to the base point), it seems to slowly sway tilting from left to right, right to left, with an amplitude that slowly increases centered around one point. It doesn't just sit. There is also a slight rearward drift in VelocityRoam. Is there a way to dial these out?

Re: Position hold not working
« Reply #26 on: November 16, 2019, 04:04:30 am »
The increasing oscillation (with a period of about 4 seconds for me) is caused by the DJI/Naza GPS smoothing and thus delaying the GPS data.  Just like when you use slow ESCs you get (much quicker) Attitude mode oscillations.

There is a workaround here until the cause found in either the EKF configuration (tweakable in the GCS) or the flight code is changed to take this into account.  There is pre-compiled firmware for 16.09 and source code for you to build your own version of whatever else you are using:
https://forum.librepilot.org/index.php?topic=3012.msg21154#msg21154

Or now that we have your configuration working, you could also try going back to your previous GPS and see if your mag issues are small enough to allow you to fly.

trust

  • ****
  • 301
Re: Position hold not working
« Reply #27 on: November 17, 2019, 09:16:26 pm »
After some issues with loading the oscillation fix 16.09-dirty firmware referenced, I finally got it loaded and working. I assume the mag calibration settings are also saved with the uav files? Seems so, as I had to reload them and it worked fine.
Just tested it with two batteries- seems improved. In VelocityRoam - sometimes there is still one or two oscillations, but then it stops oscillating and holds position fine. 
RTB seems even better - smooth movement to base, no oscillation seen.

Re: Position hold not working
« Reply #28 on: November 18, 2019, 05:53:26 am »
The firmware there is 16.09 and does not need any settings changes.  You could just flash the firmware and leave the settings as they were.  It seems you backed up your settings to a UAV file, flashed new firmware, restored settings from UAV file, and that is fine too.  :)

trust

  • ****
  • 301
Re: Position hold not working
« Reply #29 on: November 27, 2019, 11:55:24 pm »
Are there parameters that can be modified to affect the VelocityRoam stabilization, and the speeds of the RTB?
Is there any online documentation on VelocityRoam?