Skip to content

Start px4_sitl_default jmavsim simulation from within Python Script #141

@Kathik-R

Description

@Kathik-R

Hello!

I have built a Pixhawk quadcopter with PX4 installed on it and I wish to create a virtual copy of it.
I have installed dronekit and dronekit-sitl on my Python3 (Ubuntu 20.04).
The PX4 Toolchain has been installed and it works as expected. When I use the terminal to launch a simulation using the command make px4_sitl_default jmavsim the virtual drone is created.
However, I want to do this through a python script. Is there a way to mimic the following terminal command in python using dronekit_sitl package?

I ran the following code but it creates an APM Copter V3.3.

connection_string = '127.0.0.1:14540'
try:
        #### connect to px4 drone if simulation already triggered
	vehicle = connect(connection_string, wait_ready=True)
except:
        #### trigger new px4 sitl jmavsim simulation
	import dronekit_sitl
	sitl = dronekit_sitl.start_default()
	vehicle = connect(sitl.connection_string(), wait_ready=True)

How can I give it the input to use px4_sitl_default and jmavsim instead of Arducopter?

Thank you for your time :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions