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

Request message HOME_POSITION works only one time per connection, and few other questions #801

Open
savend opened this issue Apr 25, 2023 · 1 comment

Comments

@savend
Copy link

savend commented Apr 25, 2023

Hi,
I'm beginning working with mavlink and pymavlink librairies and I think I'm missing some important details to understand all. For debbuging I'm using the mission planner quadcopter stable SITL.
My first problem is that I can only ask for the HOME_POSITION message one time per connection : here is the terminal results :

Python 3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymavlink import mavutil
>>> from pymavlink import mavwp
>>> connection = mavutil.mavlink_connection('tcp:localhost:5762')
>>> connection.wait_heartbeat()
<pymavlink.dialects.v20.ardupilotmega.MAVLink_heartbeat_message object at 0x0000022A931CBE50>
>>> print("Heartbeat from system (system %u component %u)" % (connection.target_system, connection.target_component))
Heartbeat from system (system 1 component 0)
>>> connection.mav.command_long_send(1,0, mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, 0, 242, 0, 0, 0, 0, 0,0)
>>>
>>> print(connection.recv_match("HOME_POSITION", blocking=True))
HOME_POSITION {latitude : -[353633515](tel:353633515), longitude : 1491652412, altitude : 585050, x : 0.0, y : 0.0, z : 0.0, q : [1.0, 0.0, 0.0, 0.0], approach_x : 0.0, approach_y : 0.0, approach_z : 0.0, time_usec : [818545784](tel:818545784)}
>>> connection.mav.command_long_send(1,0, mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, 0, 242, 0, 0, 0, 0, 0,0)
>>>
>>> print(connection.recv_match("HOME_POSITION", blocking=True))
HEARTBEAT {type : 2, autopilot : 3, base_mode : 81, custom_mode : 0, system_status : 3, mavlink_version : 3}
>>>

If I restart python terminal (break the mavlink connection) I can ask again the HOME_POSITION without restarting the SITL.

Few other questions :

  • Where are the mav.command_long_send() or connection.amv.send() functions defined in pymavlink? To understand what they doing I tried to find the source code, but I didn't find it. (Same for all the enums, messages and commands numbers)
  • How can I disconnect a mavlink connection properly?

I'm trying to answer most of my question with the rare examples and documentation, but need some additional explanations! Thanks for that.

@jnippula
Copy link

jnippula commented May 5, 2023

Those xx_send functions are generated, can be found from pymavlink/generator//<mav_version//mavlink_msg_.h files after running generator.

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

2 participants