Skip to content
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

Implement support to MAV_CMD commands #21 and #22 #1281

Closed
TSC21 opened this issue Aug 16, 2014 · 13 comments
Closed

Implement support to MAV_CMD commands #21 and #22 #1281

TSC21 opened this issue Aug 16, 2014 · 13 comments

Comments

@TSC21
Copy link
Member

TSC21 commented Aug 16, 2014

Hi,

Right now it's allowed to send, by mavros (here: https://github.com/vooon/mavros/blob/master/mavros/src/plugins/command.cpp#L269 and here: https://github.com/vooon/mavros/blob/master/mavros/scripts/mavcmd#L80), commands that use MAV_CMD_NAV_LAND and MAV_CMD_NAV_TAKEOFF to respectively land and take-off. Soon, it will also allow to land and take-off on the current GPS position (already working to get take-off/land in local position).

They are both working but always get FCU: command unsupported: 21 or FCU: command unsupported: 22, since they are not supported in the firmware side.

I ask if someone can add support for this commands in the PX4 side or, at least, give some guidance on how to implement them. I'm not really used to the PX4 code structure/API.

Thanks in advance!

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

In mavros side: mavlink/mavros#125, will allow now to TOL in the current GPS position, by reading the GPS coordinates and pushing them to the rospy srv.

So offboard side is working, just needs to be supported on firmware side.

@LorenzMeier
Copy link
Member

@DrTon Could you chime in here and provide some guidance?

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

I assume the behaviour will be similar to when the FCU reads a TOL waypoint, so parsing the command into the loop that controls this process is the way to go, I think. But I'm not really aware how it is implemented and what can be changed so some guidance to what files to change and what to change on those files would be helpful.
Thanks @LorenzMeier and @DrTon.

@DrTon
Copy link
Contributor

DrTon commented Aug 17, 2014

LAND command can be implemented by switching to LAND nav state (but which main state to use in this case? do we need new main state LAND?)

TAKEOFF will be more tricky. Which mode we need after takeoff? LOITER or MISSION?

The problem is that both modes are intermediate, i.e. they shouldn't have corresponding main state. But then commander must know when to switch from one nav state to another.

So let me think more how to do this better.

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

I was assuming that land can be issued in every mode (being in Stabilize, POSCTL, LOITER or MISSION).
Takeoff, since we are using GPS coordinates, can switch to POSCTL, LOITER or MISSION.

So let me think more how to do this better.

Sure thing :) I was looking if we can grab this process and move it also for TOL in local positions. This last ones behaviours can be built offboard and control the quad while it is in POSCTL.

@DrTon
Copy link
Contributor

DrTon commented Aug 17, 2014

No, LAND and TAKEOFF must not be used only in manual controlled modes (including POSCTL), else we will have conflict between RC and auto action.

Takeoff, since we are using GPS coordinates, can switch to POSCTL, LOITER or MISSION.

Leaving only LOITER or MISSION here: so what? LOITER or MISSION? This is the main question. As I see this: if user switched to MISSION and armed (with RC or GCS) he wants to start mission, so do takeoff immediately and we already do this. If he is in LOITER and armed - vehicle will stay on ground now, but this can be reviewed - if user armed he maybe want vehicle in air, in this case we don't need TAKEOFF command at all :)

Could you please provide example of use case for TAKEOFF command. (LAND command is indeed useful as we have no simple one-button way to land vehicle now).

This last ones behaviours can be built offboard and control the quad while it is in POSCTL.

Not sure if I understand you correctly, but POSCTL was not designed for offboard control (i.e. control by offboard computer), but for controlling by human with RC/joystick. You should use OFFBOARD mode for this.

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

So you are saying that TAKEOFF can't switch to POSCTL?

Could you please provide example of use case for TAKEOFF command. (LAND command is indeed useful as we have no simple one-button way to land vehicle now).

I was thinking in this case it can change to LOITER, but this mode needs to allow being armed and get out from the ground, so it can hold position on the coordinates issued.

You should use OFFBOARD mode for this.

I wasn't aware that this mode already was implemented. In the RC calibration and mode setup at least I didn't see it there. Can it be configured in a RC channel? By the way, if I change to this mode, will the vehicle enter in position hold and then allow to receive commands from offboard? (like setpoints for position and velocity)

Thanks for the feedback! As I said, best I can think off for take-off is then change to POSCTL (which I didn't understand if it's possible or not) and to LOITER, since for MISSION we already can use the waypoint for take-off.

@DrTon
Copy link
Contributor

DrTon commented Aug 17, 2014

So you are saying that TAKEOFF can't switch to POSCTL?

Exactly. Because it's useless and dangerous, mc_pos_control will do the same if you just move throttle stick full up in POSCTL mode. Why need to complicate things? If you are using POSCTL you MUST use RC/joystick. So why need to takeoff with GCS if you can't control from it anyway.

I was thinking in this case it can change to LOITER, but this mode needs to allow being armed and get out from the ground, so it can hold position on the coordinates issued.

So if copter will takeoff automatically when arming in LOITER mode, is it ok? I don't see real use case for TAKEOFF command in this case.

I wasn't aware that this mode already was implemented. In the RC calibration and mode setup at least I didn't see it there. Can it be configured in a RC channel? By the way, if I change to this mode, will the vehicle enter in position hold and then allow to receive commands from offboard? (like setpoints for position and velocity)

Yes, it's implemented but not in qgroundcontrol RC calibration, you have to change parameters manually, look RC_MAP_OFFB_SW parameter. This may be useful: http://pixhawk.org/users/system_modes/mode_switch_config OFFBOARD-related parameters are not documented yet, sorry, so if you will have any questions, create separate issue please, if no - add some docs please :)
OFFBOARD mode can be activated by RC (if using RC) or by mavlink command (if NOT using RC). It should work, but may not, we have a lot of related changes and maybe broke something. Please look mailing list/github issues and ask @LorenzMeier which mavlink messages should be used. You can send position / velocity / attitude / attitude rate setpoints (but not sure that all types are implemented already).

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

Arming in LOITER mode and then issue a takeoff command to take it off automatically: yes that's what I was thinking about.
I'll be using offboard control. Everything is already set up in mavros side. Already took a look in the offboard2 branch and it seems its ready to recieve offboard commands.
Can you just answer me if changing to offboard mode gets the quad into position hold?
Thanks again for the feedback!

@TSC21
Copy link
Member Author

TSC21 commented Jun 23, 2015

@LorenzMeier I see that you have support for MAV_CMD_NAV_TAKEOFF in https://github.com/PX4/Firmware/blob/c62ae87c69963a4880c990c02000fd09e9b228f4/src/modules/mavlink/mavlink_mission.cpp, but where's the support for MAV_CMD_NAV_LAND. I see that you added https://github.com/PX4/Firmware/blob/c62ae87c69963a4880c990c02000fd09e9b228f4/src/modules/uORB/topics/mission.h#L59, but if the command is comming from a Mavlink msg, how can it be translated in this case?

@TSC21
Copy link
Member Author

TSC21 commented Jun 23, 2015

This is just to be aware of how I'm going to implement mavlink/mavlink#401 in the loop.

Also do I have to get commands to local frames through mavlink_mission_item?

@tinito
Copy link
Contributor

tinito commented Sep 28, 2015

Hi, I would like to implement the multicopter takeoff on firmware side for local navigation, but I have a couple of questions:

  1. is it implemented for GPS navigation, or it is missing even in that case? If it is implemented, where is the code? I can't find it, the only references for SETPOINT_TYPE_TAKEOFF are in the fixed wings position controller code
  2. which takeoff strategy would be the best? Now I'm trying to takeoff by sending velocity setpoints via mavros, and switching to position control when the copter reaches the given altitude. Anyway this is not reliable: the transition between the two modes is not smooth at all, and sometime the copter start drifting a lot and I have also experienced a couple of flips

@LorenzMeier
Copy link
Member

We have this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants