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

Unexpected behavior in offboard mode #273

Closed
TarekTaha opened this issue Apr 14, 2015 · 19 comments
Closed

Unexpected behavior in offboard mode #273

TarekTaha opened this issue Apr 14, 2015 · 19 comments

Comments

@TarekTaha
Copy link

I am trying to perform offboard navigation using mavros following this procedure :

  • run mavros with vision estimation enabled
  • stream pose data to the new /mavros/vision_pose/pose topic (PX4 blinks green)
  • arm the quad and fly manually
  • switch to posctrl (all fine so far and quad holds position)
  • switch to offboard mode (it gets rejected)
    • run the script to send setpoint : offboard mode accepted
    • immediately the quad flips over and motors disengages

script used to send setpoint: https://raw.githubusercontent.com/kuri-kustar/indoor_uav_control/master/scripts/setpoint_demo_2.py

plot1

The plot shows how immediately after changing to offboard mode, the motors disengage/go back to trim values.

a similar procedure using the uar_interface works fine: https://github.com/kuri-kustar/c_uart_interface_example/tree/object

@mhkabir
Copy link
Member

mhkabir commented Apr 14, 2015

@thomasgubler

@thomasgubler
Copy link

a similar procedure using the uar_interface works fine: https://github.com/kuri-kustar/c_uart_interface_example/tree/object

what is the difference to the python script from the viewpoint of the autopilot --> Do both approaches use the exact same set of mavlink messages?

@TarekTaha
Copy link
Author

Well, I tried to trace how the setpoint_position plugin works:

it seems that all it does is subscribe to the topic /mavros/setpoint_position/local , perform some bit bashing (I think it's enabling only position control and disabling velocity and acceleration) and send the data through mavlink https://github.com/mavlink/mavros/blob/d1902d1331d32d30af911f04dcc842a657b209ff/mavros/src/plugins/setpoint_position.cpp#L92-101

On the other hand, the c_uart_interface_example does the following:

So basically on the low level, the fundamental difference is the usage of mavlink_msg_set_position_target_local_ned_pack_chan in

mavlink_msg_set_position_target_local_ned_pack_chan(UAS_PACK_CHAN(_uas), &msg,
vs the usage of mavlink_msg_set_position_target_local_ned_encode as in https://github.com/kuri-kustar/c_uart_interface_example/blob/object/autopilot_interface.cpp#L374

That's as far as I could trace it. Now whether this difference is the cause of the problem, and how to fix it is what I need to know with your help.

@vooon
Copy link
Member

vooon commented Apr 14, 2015

Different encoders — bug can't be here!
I think more likely this comment api#L47:

    // this is needed for now to avoid a throttle cut...
    sp.vx  = 0.0;
    sp.vy  = 0.0;
    sp.vz  = 0.0;

So you may try edit type_mask:

uint16_t ignore_all_except_xyzy = (1 << 11) | (7 << 6); // ignore velocity vector: | (7 << 3);

@TarekTaha
Copy link
Author

@vooon Yes, changing the mask works ! Maybe you should make this change permanent in mavros (Not sure if this would effect APM) ?

I will test the velocity set point next (the velocity setpoint in the current firmware doesn't work, so I will use an older PX4 firmware)

@vooon vooon added this to the Version 0.12 milestone Apr 15, 2015
@thomasgubler
Copy link

@vooon Yes, changing the mask works ! Maybe you should make this change permanent in mavros (Not sure if this would effect APM) ?

We should fix this in PX4

@thomasgubler
Copy link

ah I was to fast...
@BlackCoder did you just change the mask to make it work or is

    sp.vx  = 0.0;
    sp.vy  = 0.0;
    sp.vz  = 0.0;

needed as well?

Probably you were sending 0 for the velocities anyway? I am confused why setting them again to 0 as per @voon 's comment should change something

@vooon
Copy link
Member

vooon commented Apr 15, 2015

In mavros velocity vector is zero (all ignored data is zero), but before it ignored.
That comment more related to type_mask, what im changed in 1455fcb .

@vooon
Copy link
Member

vooon commented Apr 15, 2015

And i think that it is bug, so this qirk may be removed after fixing PX4/PX4-Autopilot#2036 .

@aerialhedgehog
Copy link

api#L47 is definitely a hack. At the time I wrote this, ignoring the velocity components didn't help.

Are you all able to command velocity setpoints? See PX4/Firmware/#1856

@TarekTaha
Copy link
Author

@thomasgubler as @vooon said, the mavros sets the velocity vector to zero before sending it, so I just changed the mask
@aerialhedgehog the velocity setpoint in the new firmware is still broken, I am using an older firmware at the moment to test velocity setpoint

@thomasgubler
Copy link

@BlackCoder could you lend a hand for debugging the velocity issue?

@TarekTaha
Copy link
Author

@thomasgubler yes of course, just let me how do you want to approach it.

@LorenzMeier
Copy link
Member

@BlackCoder @aerialhedgehog Have you seen this branch / PR? PX4/PX4-Autopilot#1983

@TarekTaha
Copy link
Author

@LorenzMeier , no I didn't see it before. I can test it in the next couple of days. What is the expected behaviour resulting from this PR?

vooon added a commit that referenced this issue Apr 18, 2015
* master:
  plugin: param fix #276: add check before reset request downcounter.
  libmavconn #269: add seq number to debug
  gcs bridge fix #277: add link diagnostics
  vim: Add YouCompleteMe configuration file
  plugin: setpoint_position #273: add quirk for PX4.
  readme: fir glossary misprint
  readme: add notes about catkin tool
  0.11.1
  prepare release 0.11.1
  scripts #262: update mavwp
  scripts #262: mavsetp, new module mavros.setpoint
  mavftpfuse #129: done!
  mavftpfuse #129: cache file attrs
  mavftpfuse #129: initial import
@aerialhedgehog
Copy link

@LorenzMeier this is new to me too, will check it out

@vooon
Copy link
Member

vooon commented Jun 28, 2015

@LorenzMeier it is fixed?

@supermice
Copy link

@LorenzMeier Can I use the velocity control command with master firmware now?

@LorenzMeier
Copy link
Member

This is fixed in that it won't cut throttle.

@vooon vooon mentioned this issue Jul 21, 2015
4 tasks
nmichael pushed a commit to rislab/mavros that referenced this issue Mar 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants