About running python script in mavproxy

I want to send a serial data to the arducopter telem2 port through mavproxy which is connected to copter through usb. I configured the telem2 port by mavproxy commands module load serial, serial set port telem2 and serial send "my string", everything goes fine  and i am able to see data in the telem2 port also.

But i want to send the data to the copter from a python script instead of sending from the mavproxy console.I written a python script for udp communication with same port in which mavproxy out port specified. Can someone assist me?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hello Stephen,

    I am trying to achieve something similar but without Mavproxy.

    I am trying to send MAV commands to Pixhawk through a python script via the serial port. Currently, I do not have the hardware. I am wondering if this can be tested in simulation. I am using jmavsim with PX4 .

    I would be really grateful if you could provide any sort of guidance regarding this.



    Stephen Dade said:

    Mission Planner (like all GCS's) sends heartbeat messages to the UAV. Not sure if there's a way to disable it.

    Why do you require Mission Planner between the UAV and MAVProxy? MAVProxy can talk directly to the UAV.

    I had a quick look at your script - MAVProxy takes mavlink commands through the --out destinations, not console commands.

  • Mission Planner (like all GCS's) sends heartbeat messages to the UAV. Not sure if there's a way to disable it.

    Why do you require Mission Planner between the UAV and MAVProxy? MAVProxy can talk directly to the UAV.

    I had a quick look at your script - MAVProxy takes mavlink commands through the --out destinations, not console commands.

  • Does the mission planner sending any heartbeat message to the copter through mavproxy? If sending, is it possible to stop heartbeat msg sending from mission planner and communicate with copter through mavproxy without checking for heartbeat from mission planner?

  • Has you told i used events in python to run a specific function, its working fine. And i am able to see the data transmitted from udp in the configured serial port of copter which is transmitted through mavproxy. But the problem is, the Mission planner communication is shutting down when i am transmitting the udp data continuously from the udp script.The udp script file named UDP_rec.py is attached down. I am running the mavproxy with the following command mavproxy.py --master="com14",57600 --out=udp:192.168.2.16:14550 --out=udp:192.168.2.16:14540. I opened two udp-out ports. Port14550 is for communicating with mission planner and the port 14540 is to communicate with UDP_rec.py script.

    UDP_rec.py

  • You can use events in Python to run a specific function when data is received over serial or UDP, instead of checking continuously. It's more complex to build this way though.

    You can get MAVProxy to automatically load your module on startup by using the --load-module startup option: http://ardupilot.github.io/MAVProxy/html/getting_started/starting.h...

    Startup Options — MAVProxy 1.6.4 documentation
  • Even if i create new mavproxy module also i need to enter those commands in the mavproxy console. But i want like whenever data sent through serial/udp from other pc has to be received in mavproxy and that data has to be send to the copter.

  • Has you told, i edited in mavproxy_serial.py file. I opened new com port(com3) in init function and its opened successfully. Now i will send some data in serial software from pc with the same com port(com3) which is opened and i want that data to be transmitted to the copter. For this to happen the python module which is loaded has to check continuously for the data in port (com3). Is this is the correct way to do? Is it possible to run a mavproxy module to check continuously for the data in port (com3)? Please help me i dont have any idea about this.

  • Thanks. I will check by creating a new MAVProxy module.

  • That is definitely possible. You will need to write a MAVProxy module to do so. I recommend starting with a copy of the serial module (linked in my previous reply) and editing it from there.

    There's some documentation on developing MAVProxy modules at http://ardupilot.github.io/MAVProxy/html/development/index.html

    Development — MAVProxy 1.6.4 documentation
  • Thanks for your reply. I want to send data to copter from my own python script which receives data from another pc through tcp or udp and that received data i want to transmit to the copter through mavproxy . Is it possible or not? If possible how can i do?

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…