-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Holding Flight Position while giving the drone 2D velocity Command #739
Comments
Are you feeding Optitrack data into the Pixhawk through MAVROS? |
I am feeding Optitrack Data as /mavros/mocap and I have also changed the Pixhawk parameters such that it uses this information for local position estimation, the result is actually pretty good. But that being said, I am currently just trying to work with Gazebo simulator (not including mocap). In my code, I create both setpoint_position and setpoint_velcity publishers. I set "set_position.pose.position.z = 2" and "set_velocity.linear.x = 1" But the drone just hover at 2 meters, without moving anywhere. And it gives me this error: |
I found the issue for the error message. I made a mistake when I try to send '/mavros/setpoint_velocity/cmd_vel'. The message type should be TwistStamped, instead of Twist. After modifying my set_velocity to 'set_velocity.twist.linear.x = 1' the error disappears. However, a new issue appears. The drone is not stable at all, it keeps shaking as it moves forward (+x direction). I am not sure if my approach is correct. Please let me know if there is a formal way to do it. |
Actually the error states what is the problem. The velocity command you are sending is a |
Without checking the code you are using, is kinda difficult to understand what's wrong. |
@TSC21 Thanks for the help! Unfortunately , I am not sure if I can post my original source code. I will get back to this issue once I have the permission. I apologize for the inconvenience. I will also post the solution for this particular problem once I find it because I think it is a really good application/demo. |
The inconvenience is not for us that are trying to help you. But asserting over the functionality of a piece of code without knowing the code is kinda difficult. |
@TSC21 Yes. I completely understand. |
OK. So here is a simple script I have to control both velocity and position.
|
You should base your code in this: https://dev.px4.io/en/ros/mavros_offboard.html. I see you send the position setpoint only once while you should send it for a while. Then, when it check it's in the |
I am thinking about a different approach. Instead of rely on '/mavros/setpoint_position/local' to achieve the altitude hold, I might as well write my own PID altitude controller that takes the difference of the desired altitude and my current altitude (set_z - measured_z) as my input, and output velocity control in the z direction. Therefore, all I need is to publish Vz to maintain the altitude, it might require some tuning though. |
That is something I have already done in |
Thanks! I will take a look at it and I believe it is a great approach. I think this issue can be closed now. |
https://github.com/darknight-007/docking/blob/master/testVelocityControl.py I modified this to get altitude hold while controling horizontal velocity. You can also try setpoint_raw, but I found that it didn't work. |
@schmittlema , can you tell me how did you modify to give a constant velocity with altitude hold? |
Below. I made a 3 PID controllers for each axis. Then if the desired velocity is none it holds that axis position. Z is always trying to hold altitude. Hopefully it helps. import rospy class VelocityController:
|
Hey there. You cannot control Vx, Vy and Z, only velocities or only position. If the drone is shaking it's because it answer to the position setpoint then the velocity. |
@AlexisTM currently you can: Bitmasks are: |
Indeed, but he mentioned using Also, I am not certain the mode is working as the |
I am a PhD student currently working on an experiment that requires me to control drones with 2D Velocity Command (Vx, Vy). Essentially I want the drone to hold at a constant altitude and move around on the x,y plane.
My current setup is the following: DJI F450 frame, Odroid XU4, Pixhawk, PX4 Firmware with LPE (I am also using Optitrack). At this point, I am just trying to get my algorithm working in the Gazebo Simulator.
So far, I have got the waypoints working but I am having trouble to let the drone hold its position while sending Vx, Vy. Do anyone have experience with this? Any help would be appreciated!
The text was updated successfully, but these errors were encountered: