hi everybody i was trying to enstablish a comunication between px4 and a script written using the pymavlink library. Now when i have to create a mavlink connection on localhost it works fine, but when i use the local IP address of PX4 is not able to connect, but the strange thing is that when i launch the script to send the message in broadcast, then replace the IP with the previous one and relaunch it the connection is enstablished is there something i am missing here?
What parameters are you using to connect?
Hi thanks for the reply, i am using the same parameters used in the documentation of pymavlink :
from pymavlink import mavutil
mav = mavutil.mavlink_connection('udp:lmy_local_ip_addr:14550')
after that i wait for a replay from px4 that never arrives, except in case do what i explained previously
Just to be a little bit more clear :
This is what is written in the docu
from pymavlink import mavutil
# Start a connection listening on a UDP port
the_connection = mavutil.mavlink_connection('udpin:localhost:14540')
# Wait for the first heartbeat
# This sets the system and component ID of remote system for the link
the_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component))
This is what i did
from pymavlink import mavutil
# Start a connection listening on a UDP port
the_connection = mavutil.mavlink_connection('udpin:my_local_ip_addr:14540')
# Wait for the first heartbeat
# This sets the system and component ID of remote system for the link
the_connection.wait_heartbeat()
print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component))
Now i do not recive any reply from PX4, but when i change the address to send the message in broadcast (0.0.0.0), i launch the script and then change the ip with “my_local_ip_addr” and launch it again i do get a reply message from PX4
I’m afraid I don’t know how pymavlink works and connects. However, I can always recommend using wireshark (even with mavlink displayed) to debug that sort of thing.
And that’s what i did, but it didn’t help much
okay, thanks for the help .