AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

Question: drone starts to shake if the altitude is over 50m

Open xiahaa opened this issue 8 years ago • 17 comments

Hi, Version: Airsim 1.2.0, binary. Control: call moveOnPathSync with default setting but assigned waypoints. Problem: looks fine if the altitude is lower than 50m. However, if I tried to fly along the same path with an altitude over 60m, the drone started to shake. Does anyone have an idea about this abnormal phenomenon?

xiahaa avatar Sep 13 '18 13:09 xiahaa

I faced the same problem with moveToPositionAsync() when the drone flies over or around a certain height. But I have no idea about this.

hoangtranngoc avatar Sep 13 '18 20:09 hoangtranngoc

I faced the same problem with moveToPositionAsync() when the drone flies over or around a certain height. But I have no idea about this.

It seems quite strange. Could the aerial dynamics constraints be the reason? I added gimbal, so the footage you will get is ok. But the drone's attitude is a mass...

xiahaa avatar Sep 14 '18 07:09 xiahaa

Could you please provide the sample code to reproduce this? I'm guessing your speed is too high.

sytelus avatar Sep 17 '18 18:09 sytelus

Could you please provide the sample code to reproduce this? I'm guessing your speed is too high. Sure.

        path = []
        x0 = 0
        y0 = 0
        z0 = -self.lalti
        l = self.length
        w = self.stripewidth
        dalti = self.lalti - self.halti;
        offsets = [[0,l,0],\
                  [-w,l,0],\
                  [-w,0,0],\
                  [-w*2,0,0],\
                  [-2*w,l,0],\
                  [-3*w,l,0],\
                  [-3*w,0,0],\
                  [-4*w,0,0],\
                  [-4*w,l,0],\
                  [-4*w,l,dalti],\
                  [-4*w,0,dalti],\
                  [-3*w,0,dalti],\
                  [-3*w,l,dalti],\
                  [-2*w,l,dalti],\
                  [-2*w,0,dalti],\
                  [-w,0,dalti],\
                  [-w,l,dalti],\
                  [-0,l,dalti],\
                  [-0,0,dalti]]
                
        distance = 0
        xold = x0
        yold = y0
        zold = z0
        for i in range(len(offsets)):
            xnew = x0 + offsets[i][0]
            ynew = y0 + offsets[i][1]
            znew = z0 + offsets[i][2]
            path.append(airsim.Vector3r(xnew,ynew,znew))
            dx = xnew - xold
            dy = ynew - yold
            dz = znew - zold
            distance = distance + math.sqrt(dx*dx+dy*dy+dz*dz)
            xold = xnew
            yold = ynew
            zold = znew
        
        print("Total distance is " + str(distance))
        tripTime = distance / self.velocity
        print("Estimated Time is " + str(tripTime))
        
        self.client.moveOnPathAsync(path,\
                                    self.velocity,\
                                    tripTime * 3,\
                                    airsim.DrivetrainType.MaxDegreeOfFreedom,\
                                    airsim.YawMode(True,0), \
                                    -1, 0)

Note:

  1. self.velocity = 2 m/s.
  2. I let timeout = tripTime * 3 since the rough time estimation by dist / avg_spd is too short to make the UAV finish the whole path.

xiahaa avatar Sep 18 '18 07:09 xiahaa

@xiahaa can you please try the branch bug_fixes/z_controller and get back to us?

madratman avatar Dec 19 '18 22:12 madratman

@xiahaa can you please try the branch bug_fixes/z_controller and get back to us?

Sure~

xiahaa avatar Dec 21 '18 12:12 xiahaa

@xiahaa any news?

madratman avatar Jan 08 '19 19:01 madratman

Hi @madratman! In my case, the error is still there. The drone is still shaking. You can see my recorded video here https://youtu.be/VOaxnu0XI_s

hoangtranngoc avatar Jan 11 '19 14:01 hoangtranngoc

@xiahaa any news?

Sorry for the delay. I have tried with the branch you provided. The behavior is even more wired, from what I have seen~ I made a gif that you can see the behaviors.

airsim1

xiahaa avatar Jan 12 '19 15:01 xiahaa

@madratman Any solution for this ? Its looks like Weather : Wind bug.

stavBodik avatar Apr 18 '19 08:04 stavBodik

Still getting this bug in the latest AirSimNH environment

ACLeighner avatar May 13 '20 06:05 ACLeighner

UPDATE Ok, my old solution didn't work at higher speeds, so try this one and see if it works for you:

Basically we aren't going to use the position PID controller which seems to have some issues. Instead use the velocity PID with target z velocity 0 when we are close to our goal altitude.

If someone else confirms it works, or if I don't run into any issues for a while Ill do a pull request

NOTE: Be sure to change MoveByVelocityZInternal to MoveByVelocityInternal (No Z)

  1. In MultirotorAPIBase.cpp change some code in the moveToPathPosition
  2. rebuild AirSim
  3. added the new Plugin files to UE4

Replace

//send commands
//try to maintain altitude if path was in XY plan only, velocity based control is not as good
    if (std::abs(cur.z() - dest.z()) <= 1) //for paths in XY plan current code leaves z untouched, so we can compare with strict equality
        moveByVelocityZInternal(velocity_vect.x(), velocity_vect.y(), dest.z(), yaw_mode);
    else
        moveByVelocityInternal(velocity_vect.x(), velocity_vect.y(), velocity_vect.z(), yaw_mode);

with
//send commands
//try to maintain altitude if path was in XY plan only, velocity based control is not as good
    if (std::abs(cur.z() - dest.z()) <= 1) //for paths in XY plan current code leaves z untouched, so we can compare with strict equality
        moveByVelocityInternal(velocity_vect.x(), velocity_vect.y(), 0, yaw_mode);
    else
        moveByVelocityInternal(velocity_vect.x(), velocity_vect.y(), velocity_vect.z(), yaw_mode);

ACLeighner avatar May 18 '20 04:05 ACLeighner

This did not help at higher altitudes. We still see a lot of jitter/vibrations at 70m/80m heights. @madratman, are there any other fixes we can try?

fawadahm avatar Jun 15 '20 07:06 fawadahm

Huh, you rebuilt with that change and no luck? I just tried flying at 90m and didnt have any issues...If someone else wants to try, it looks like the issue is is moveByVelocityZInternal, which causes the drone to very quickly change its zvelocity at the target altitude. So it is essentially stuck oscillating (shaking) at that altitude.

ACLeighner avatar Jun 18 '20 05:06 ACLeighner

OK! I realize now that my earlier solution doesn't work at higher velocity...Edited my earlier comment with a new change that seems to be working

ACLeighner avatar Jun 19 '20 08:06 ACLeighner

This works. Thank you!

fawadahm avatar Jun 22 '20 08:06 fawadahm

i have alse met this problem? do you guys have any solution for that?

lucafei avatar Oct 31 '20 18:10 lucafei