AWDRONE
(AWDRONE)
May 23, 2020, 11:13am
1
Hi,
I am trying to launch an order via mavlink and MAV_CMD_REQUEST_MESSAGE
My code:
from pymavlink import mavutil
master = mavutil.mavlink_connection(self.url)
master.wait_heartbeat()
master.mav.command_long(master.target_system, master.target_component,
mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE,
0, 74, 0, 0, 0, 0, 0, 0, 0)
ack = False
while not ack:
ack_msg = master.recv_match(type=‘COMMAND_ACK’, blocking=True)
ack_msg = ack_msg.to_dict()
print(mavutil.mavlink.enums[‘MAV_RESULT’][ack_msg[‘result’]].description)
But I have an error message:
AttributeError: ‘MAVLink’ object has no attribute ‘command_long’
If I replace command_long with command_long_send in my code, I’ve the message :
Command is not supported (unknown)
What’s the problem?
Thanks,
Nico
Hi,
Please take a look in our pymavlink documentation , about the error message while using command_long_send
, please display the full output.
AWDRONE
(AWDRONE)
May 23, 2020, 1:15pm
3
Here is my complete script
ROVPilot2.txt (1.8 KB)
And here is the output:
Nico
Hi,
I just did a simple test and the code works here:
from pymavlink import mavutil
master = mavutil.mavlink_connection('udpin:0.0.0.0:14550')
master.wait_heartbeat()
master.mav.command_long_send(master.target_system, master.target_component, mavutil.mavlink.MAV_CMD_REQUEST_MESSAGE, 0, 74, 0, 0, 0, 0, 0, 0, 0)
ack = False
while not ack:
ack_msg = master.recv_match(type='COMMAND_ACK', blocking=True)
ack_msg = ack_msg.to_dict()
print(mavutil.mavlink.enums['MAV_RESULT'][ack_msg['result']].description)
From the code that you shared, it appears that you have not shared the entire script, please test this minimum example or share a complete file with the minimum amount of code to replicate your issue.
AWDRONE
(AWDRONE)
May 23, 2020, 7:02pm
5
I ran your code (ROVPilot2b.txt (657 Bytes) ), and I still get the same error message:
Command is not supported (unknown)
My version of pymavlink is 2.4.8
My version of ArduSub is 3.5.4
Nico
AWDRONE
(AWDRONE)
May 24, 2020, 1:54pm
6
I updated the pixhawk firmware (new version 4.0.1) and now I have a message:
So the command is OK, but how do I display the result? (in my example, I made a request on message 74 (VFR_HUD) to retrieve the depth)
Nico
Hi @AWDRONE ,
So you should change the recv_match
argument from COMMAND_ACK to VFR_HUD , or check if the message was received, check Receive data and filter by message type in our python examples .
AWDRONE
(AWDRONE)
May 28, 2020, 5:53pm
8
Hi,
Thanks, it works.
I can recover the battery voltage with the SYS_STATUS parameter, the depth with the VFR_HUD parameter.
I would also like to recover the tilt of the camera, and the power of the headlights, but I don’t see what parameter to check.
Nico
Check the SERVO_OUTPUT_RAW message, where each port will be the servo output ports of your pixhawk.
If you only needs to fetch values, I would recommend to take a look in our new mavlink rest API .
This topic was automatically closed after 14 days. New replies are no longer allowed.