Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PX4 integration #181

Open
petergerten opened this issue Dec 2, 2023 · 4 comments
Open

PX4 integration #181

petergerten opened this issue Dec 2, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@petergerten
Copy link

Did anybody integrate PX4 SITL with this framework to utilize it for higher level objectives?

@JacopoPan JacopoPan added the question Further information is requested label Dec 2, 2023
@JacopoPan
Copy link
Member

Hi @petergerten , no, so far no one has worked on PX4 integration yet.

@JacopoPan JacopoPan added enhancement New feature or request help wanted Extra attention is needed labels Mar 2, 2024
@dmvinson
Copy link

What would be involved in integrating with PX4? Is that covered under the Use SITL services with steppable simulation roadmap item? I'd be interested in this for my work, happy to contribute if there is an initial set of pointers to being development

@JacopoPan
Copy link
Member

Hi @dmvinson

if you want to try and implement a lockstep version of PX4 SITL paired with one of the environments in this repo, it would be great and I'm happy to advise/guide/PR review the process.

I would start from the example in beta.py for which the execution instructions are here.

In this case the SITL is NOT in lockstep (the PyBullet simulation and the SITL of Betaflight run in parallel in separate processes

# Spawn SITL Betaflight instances (must have been created with assets/clone_bfs/sh first)
for i in range(num_drones):
FOLDER = os.path.dirname(os.path.abspath(__file__))+'/../../betaflight_sitl/bf'+str(i)+'/'
cmd = f"gnome-terminal -- bash -c 'cd {FOLDER} && ./obj/main/betaflight_SITL.elf; exec bash'"
subprocess.Popen(cmd, shell=True)

and communication happens over UDP
# print("rc", struct.unpack('@dHHHHHHHHHHHHHHHH', rc_packet))
self.sock[j].sendto(rc_packet, (self.UDP_IP, BASE_PORT_RC + 10 * (j))) # drone0 will be on 9004, drone1 on 9014, etc.
#### PWMs message from Betaflight ##########################
try:
data, addr = self.sock_pwm[j].recvfrom(16) # buffer size is 100 bytes (servo_packet size 16)

I believe that something similar using the default UDP/TCP port of SITL PX4 (see this diagram) and WITH THE ADDITION of lockstep execution (see this paragraph could be implemented by creating a new example gym_pybullet_drones/examples/px4.py and a new environment (spawning and talking to PX4 SITL) gym_pybullet_drones/envs/PX4Aviary.py

@dmvinson
Copy link

Thanks for the guidance, I'll take a look at this over the next few days. I appreciate your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants