How to run dronekit sitl on windows with (raspberry pi + pixhawk)

I have been following this article..
What I have done so far:-

  1. I have connected pixhawk with Rpi and configured everything as told in the article
    2)I have installed mavproxy on Rpi - and it works fine as shown below

3)I have successfully install Mavlink-router
4)I have successfully install dronekit on both raspberry pi and windows.
5) I have installed dronekit_sitl on windows
6) I have mission planner on windows

What I have now is :-

  1. ip address of my windows-
    2)ip address of my Rpi-
    3)Here is my mavlink-router/main.conf file

What I have understood until now is that, I can run simulator ( dronekit_sitl) on mission planner windows for my (raspberry pi + pixhawk)—> Please correct me If I am wrong here.

For this I run dronekit-sitl on windows as shown below:-

Now , I ran mavproxy on raspberry pi as shown below

The blue underline in the photo is the ip address of the windows which (port is 14550 - as set on mission planner)

At this stage I have successfully connected mission planner working on windows and (Raspberry pi+pixhawk)

As shown in the photo below:

Left side is the Mission planner and the right side is Putty(connected to raspberry pi via ssh)
Now , I want to do simulation(on mission planner) via python script running in raspberry pi.
In the documentation we have two python Api

from dronekit_sitl import SITL
sitl = SITL(path=apm) # load a binary path (optional), version, verbose=False) # ...or download system (e.g. "copter") and version (e.g. "3.3")
sitl.launch(args, verbose=False, await_ready=False, restart=False)
sitl.block_until_ready(verbose=False) # explicitly wait until receiving commands
code = sitl.complete(verbose=False) # wait until exit
sitl.poll() # returns None or return code
sitl.stop() # terminates SITL


import dronekit_sitl
sitl = dronekit_sitl.start_default() # basic ArduCopter sim
connection_string = sitl.connection_string()
sitl.stop() # terminates SITL

Now whenever I run the following script on my raspberry pi .

print("Start simulator (SITL)")
import dronekit_sitl

sitl =  dronekit_sitl.start_default() #  ==>>>> Error is shown at this line
#connection_string = sitl.connection_string()
connection_string = "tcp:"
# Import DroneKit-Python
from dronekit import connect, VehicleMode

# Connect to the Vehicle.
print("Connecting to vehicle on: %s" % (connection_string,))
vehicle = connect(connection_string, wait_ready=True)

# Get some vehicle attributes (state)
print("Get some vehicle attribute values:")
print(" GPS: %s" % vehicle.gps_0)
print(" Battery: %s" % vehicle.battery)
print(" Last Heartbeat: %s" % vehicle.last_heartbeat)
print(" Is Armable?: %s" % vehicle.is_armable)
print(" System status: %s" % vehicle.system_status.state)
print(" Mode: %s" %    # settable

# Close vehicle object before exiting script

# Shut down simulator

The error shown is as follows

At this point I understood that I cannot run SITL on raspberry pi. But then how shall I run SITL on windows on same network?

Please correct me. I want to know how to connect (Rpi+Pixhawk) and use dronekit -sitl with windows.

I am a beginner. Sorry for any mistake .
I have edited the question.
Thanking you.

On RPi: --master=/dev/serial0,921600 --out=
On Mission Planner, select connection as UDP and set port 14550.
You should be able to connect to the flight controller in Mission Planner.
Dronekit-sitl is for simulation.
Did you mean dronekit?

@Mustafa_Gokce Thanks for helping me again. There was problem with my power supply that I have corrected .I am able to connect to mission planner on windows . Now there is only one error in the dronekit program.

import dronkit_sitl
sitl = dronekit_sitl.start_default()   //Here is the problem .It automatically choose where as it should be

Thanks again @Mustafa_Gokce for helping me.

I have never worked with sitl simulation in rpi.
Why do you want to do that?
You can create an sitl on your computer and connect to it through network with rpi.
I believe dronekit sitl uses prebuilt binaries and probably doesn’t have a binary for raspberry pi.
BTW, I recommend you build your own SITL binary.
You can follow the steps in the following links.
Official Ardupilot SITL Tutorials
Below links are some of my tutorials that you may find easy to follow.
Setting up the build environment in Linux
Setting up the simulation software in Linux
Starting the simulation software individually
Creating simulation environment starter shell script

Thank you sir for responding. I do not want to run SITL on Rpi. I want to run SITL on mission planner on windows . My RPI is on same network connected with pixhawk.
Thank you for sir providing me the links for reference.

After you run simulation once, you can find the sitl binaries in:

C:\Users\YOUR_USERNAME\Documents\Mission Planner\sitl

Type cmd and press enter on your directory path in this directory.
When you run

ArduCopter.exe -S --model + --speedup 1 --defaults "default_params/copter.parm" -I0

This will start sitl.
After that, you can connect to the vehicle using TCP at port 5760 from the mission planner or from your code on the same computer.
If you want both RPI and mission planner then you need to do:

mavproxy.exe --master=tcp: --out= --out=RPI_ADDRESS:14550

From the same computer you can connect to vehicle from mission planner using UDP with port 14550.
Also you can connect from rpi with IP address RPI_ADDRESS or at port 14550.

1 Like

@Mustafa_Gokce Thank your very much sir. :heart_eyes:

1 Like