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

DIY Robocars via Twitter
May 15
DIY Robocars via Twitter
May 14
DIY Robocars via Twitter
May 13
DIY Robocars via Twitter
RT @f1tenth: Say hi to our newest #F1TENTH creation for @ieee_ras_icra next week in Philly. It’s going to be huge! 😎 🔥 @AutowareFdn @PennEn…
May 13
DIY Robocars via Twitter
May 11
DIY Robocars via Twitter
May 8
DIY Robocars via Twitter
RT @SmallpixelCar: Noticed my car zigzagged in last run. It turned out to be the grass stuck in the wheel and made the odometry less accura…
May 8
DIY Robocars via Twitter
RT @SmallpixelCar: Test my car. RTK GPS worked great. Thanks @emlid for their support. https://t.co/EkQ6qmjmWR
May 8
DIY Drones via Twitter
RT @chr1sa: @kane That's @diydrones circa 2009. Still have a box of those Canon cameras that we used to strap into planes, just like this.…
May 3
DIY Robocars via Twitter
RT @chr1sa: Our next @diyrobocars race is going to be outside at a real RC racetrack in Fremont on May 28. Fully autonomous racing, head-to…
Apr 30
DIY Robocars via Twitter
RT @f1tenth: Our Spring 2022 F1TENTH course @PennEngineers is coming to an end with a head-to-head race as a big finale. So proud of our st…
Apr 26
DIY Robocars via Twitter
RT @DanielChiaJH: I wrote a thing! Throughout the development of my @diyrobocars car I've been using @foxglovedev Studio to visualize and d…
Apr 23
DIY Robocars via Twitter
RT @SmallpixelCar: My new car for high speed. Low body, everything ( @NVIDIAEmbedded Jetson Xavier NX, @emlid RTK GPS, IMC) under the deck…
Apr 23
DIY Robocars via Twitter
Apr 21
DIY Robocars via Twitter
RT @f1tenth: F1TENTH Race training setup @PennEngineers for our upcoming ICRA2022 @ieee_ras_icra competition. @OpenRoboticsOrg @IndyAChalle…
Apr 21
DIY Robocars via Twitter
RT @fatcatFABLAB: Proud to be hosting a restarted DIY Robocars NYC Meetup April 26. Come by if you want to talk about and race self-driving…
Apr 17
More…