-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Mavsdk python package with AirSim simulator #3213
Comments
Hi @sytelus, Which python package is better for communication between 2 drones in AirSim? Mavros or Mavsdk? |
Hi @rajat2004, Do you have any idea about this? |
Hello @AIKUUM , I've done some testing and can confirm that mavsdk's example scripts (I tested Here's my settings.json for reference: {
"SettingsVersion": 1.2,
"SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/master/docs/settings.md",
"SimMode": "Multirotor",
"DefaultVehicleConfig": "PX4",
"Vehicles": {
"PX4": {
"VehicleType": "PX4Multirotor",
"UseSerial": false,
"UseTcp": true,
"TcpPort": 4560,
"ControlPort": 14580
}
}
} and here's a screenshot of the example script connecting and running: Hope this helps |
Hi @AIKUUM! You are continuing the topic of #3145 here, so I suggest you close there. |
Hi @jonyMarino, I have closed the issue #3145 |
Hi @jonyMarino, I'm sorry for disturbing you again. But is PX4 in SITL compulsorily required along with AirSim for UAV communication? or just AirSim is sufficient? |
Just AirSim is sufficient. AirSim uses mavlink to integrate the PX4 flight controller. But what you want is to use mavlink for other purposes. You would not have requirements from the AirSim side because you will simulate the communication on the client-side (your script). You are doing this for research, or do you plan to deploy this in a real drone? |
What I want to do is for a project. |
Hi @ahmed-elsaharti, How are you using mavsdk? I mean did you install the module through pip? Or did u download mavsdk-python package from https://github.com/mavlink/MAVSDK-Python? I have done both. Can you suggest me which would be better to use? |
I remember installing it through pip and cloning the https://github.com/mavlink/MAVSDK-Python repo just for the example scripts. The general difference between the pip version and the github version of any library would be that the version on github is the one being updated with every commit while the pip one awaits publishing by the creator |
Hi @ahmed-elsaharti, I tried executing the same python file (takeoff_and_land.py) as you did with PX4 in SITL. But there are some issues with the execution as in the screenshot below: These are settings that I have used in settings.json file: Can you help me to resolve the issues? |
@AIKUUM try getting rid of the "Parameters": { "NAV_RCL_ACT": 0, "NAV_DLL_ACT": 0, "LPE_LAT": 47.641468, "LPE_LON": -122.140165, "COM_OBL_ACT": 1 }, section in your settings.json and make sure the anaconda prompt is not blocked by a firewall or an antivirus |
Hi @ahmed-elsaharti, I tried what you suggested. But nothing appears after "Waiting for drone to connect..." in Anaconda Prompt. INFO [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0 By the way there was no problem with Anaconda prompt when I tried to execute scripts outside mavsdk package. |
What is the port on line 10 of the takeoff-land example script? |
If its Edit: or change the |
Hi @ahmed-elsaharti, I tried exactly as you have suggested. But I'm still getting these errors in PX4: In Anaconda prompt, this is all that gets displayed: settings.json contents: Contents of takeoff_and_land.py: import asyncio async def run():
if name == "main": ` Can you please help me? I'm stuck with this issue for enough time now. |
@AIKUUM as I mentioned, you need to do ONE of them or the other. What you did was that you changed both the control port and the port in mavsdk. It should be either: |
Hi @ahmed-elsaharti, I followed procedure A. Execution of "takeoff_and_land.py" is successful. In PX4, I can also see takeoff detection and landing logs. Is it ok to get these errors? |
Hi @jonyMarino, But I'm not sure about what parameters I need to consider to differentiate between 2 drones (IP address, port numbers etc). Can you suggest? |
These are probably more related to #3236. As long as the flight is not affected I wouldn't think they're an issue. If you get an error that causes the drone to lose GPS and crash (I've been getting those recently with SITL) that would be problematic. |
Hi @ahmed-elsaharti, what changes can I make in "takeoff_and_land.py", so that both the drones takeoff, when 2 drones are configured in settings.json? |
@AIKUUM tbh I wouldn't really know since I haven't looked into it that much but this would be a very good question for the folks over at the Mavsdk repo. However, I do know that for you to set up two drones in SITL you'll need to run multiple instances of SITL in addition to setting them up in settings.json (ie: having two drones in settings.json but one SITL instance wont work, you'll need one SITL instance per drone). Have a look at #3222 for some docs on how to do that. |
Hi @ahmed-elsaharti, I tried this in PX4 console: But nothing happens in Anaconda prompt after this: Can you help me? |
Was airsim started after this and was it able to connect to the px4 sitl instances? |
Hi @ahmed-elsaharti, I opened PX4 console first and did this: And then, I opened Blocks environment and these logs were present on the screen: And then i executed the python script. |
What does your settings.json look like? |
Hi @ahmed-elsaharti, contents of settings.json: |
Hi @ahmed-elsaharti, There is one more issue which I forgot to mention yesterday. When I execute hello_drone.py (link:https://github.com/microsoft/AirSim/blob/master/PythonClient/multirotor/hello_drone.py), sometimes the drone goes to specified location based on (x,y,z in code), sometimes the drone becomes unstable during the flight and doesnt go to the specified location. Even after the execution of code completes, the drone doesnt land, but lands after some time automatically. Can you tell me why this could be happening? |
Hi @AIKUUM, can you open a new issue filling the bug report, please? |
Hi @jonyMarino, I have done, Links: |
Hi @AIKUUM! PX4 is now working. See: |
Question
What's your question?
Include context on what you are trying to achieve
Context details
Include details of what you already did to find answers
Below screenshot represents the details of my system:
AirSim version (1.3.1)
Unreal version(4.25)
python version (3.8.3)
Im using AirSim simulator for my test cases. As of now I want communication to happen between 2 drones in an automated simulation environment of AirSim. I also want to know if mavsdk python package can be used along with airsim.
Details of what I already tried to check if Mavsdk python package can be used along with AirSim simulator:
The text was updated successfully, but these errors were encountered: