PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

Add webots simulation support

Open dzywater opened this issue 4 years ago • 13 comments

dzywater avatar Sep 10 '21 15:09 dzywater

Could you add any specifics? What would the advantage over Gazebo or Ignition Gazebo be? Are you interested in doing the integration?

dagar avatar Sep 10 '21 17:09 dagar

Could you add any specifics? What would the advantage over Gazebo or Ignition Gazebo be? Are you interested in doing the integration?

1.Controllers can be written in c, c++, python, and MatLab. 2.A lot of sensors exist. 3.Ability to add custom physics to simulate things such as wind. 4.Ability to add OpenStreetMap and run the simulator in environments very similar to reality Above is from https://ardupilot.org/dev/docs/sitl-with-webots.html#advantage-of-webots. Especially, its class/API definition is brief, understandable and user-friendly.

Beside, (1)Texture is closer to the real world and it is better to computer vision algorithm development. (2)Be easier to install on not only Linux but Windows and can attract more users.

I am interested to contribute, but someone can define a framework first.

dzywater avatar Sep 12 '21 01:09 dzywater

I have interest in do this integration too, how can I help?

angel-ayala avatar Jul 19 '22 13:07 angel-ayala

I have interest in do this integration too, how can I help?

@angel-ayala @dzywater should we arrange a short call to discuss? Either join the weekly dev call (https://docs.px4.io/main/en/contribute/dev_call.html) or ping me on PX4 slack.

dagar avatar Jul 19 '22 15:07 dagar

I have interest in do this integration too, how can I help?

@angel-ayala @dzywater should we arrange a short call to discuss? Either join the weekly dev call (https://docs.px4.io/main/en/contribute/dev_call.html) or ping me on PX4 slack.

Great! I think I wold star to read some PX4 terms and participate in the weekly call first, when more specific questions appears will be useful that call.

angel-ayala avatar Jul 19 '22 17:07 angel-ayala

Hi, how has the addition of Webots support into PX4 autopilot been? Recently I've started exploring Webots as an alternative to Gazebo. Having experimented on Gazebo for over a year, Webots seems like a very reliable alternative to Gazebo. I too am interesting in the possibilities of addding Webots support into PX4. In addition, currently im a Undergrad student would seek for opportunities to explore into this area. Thanks!

Linus-Goh avatar Mar 09 '24 14:03 Linus-Goh

Hello, I'm trying to implement Webots SITL for PX4, started just yesterday, and it seems messed up some sensor mappings. Here is the project. If you know how to map them properly, suggestions are welcome. https://github.com/green-creeper/px4-webots

Now it connects, takes off and crashes shortly as probably ACC and gyro have some problems with mapping from webots to px4 (ENU → NED) I guess

https://github.com/user-attachments/assets/fb522d31-5104-40d5-bcdf-58cfe2751faa

green-creeper avatar Jun 08 '25 11:06 green-creeper

Hi @green-creeper seems nice, but as you mentioned there are some changes need in the PX4 source code side. The code that you prepared was based on the Ardupilot's Webots example right? Lately I was working more with Ardupilot, and they have some extra code for both Webots with code in C and Webots with code in Python, which in essence they are reading the simulation position and gyro angles for the SITL side as an external positional system.

Maybe @dagar can have an idea on how it can be implement for PX4?

angel-ayala avatar Jun 08 '25 14:06 angel-ayala

@angel-ayala No changes needed for PX4 code itself, it just uses "other" simulator capability e.g. make px4_sitl none_iris

Yes, it's based on ardupilot example, however I'm doing my first steps in MAVLink-based firmware (I used to MSP), so the way they pass sensors wasn't clear to me. I looked at this comment and tried to implement it in a similar way but with real values

green-creeper avatar Jun 08 '25 14:06 green-creeper

Oh I got it, I just read from the top, and says that communication happens with HIL_SENSOR and HIL_ACTUATOR_CONTROLS between the simulator and SITL respectively, with a TCP connection on port 4560. This is why changes should be made in the Webots controller ardupilot_vehicle_controller to fulfill the Simulation API stack

What do you think?

angel-ayala avatar Jun 08 '25 15:06 angel-ayala

Oh, sorry now I checked more your webots repo. I saw that the API is already developed. I'm not that sure anymore, I was looking the controller, and maybe there is something with the motors index correction here, due that motors indices can be set by argument win --motors , and if the order changes, it must also define --reversed-motors.

I doesn't have PX4 code right now, or I will do the test, and right now have no time for it.

angel-ayala avatar Jun 08 '25 15:06 angel-ayala

yeah, I'll play around with it as well tomorrow. It took me a while to make it run on macOS (using either docker or raspberry pi) I also see there's with hil_state_quterion and wonder if it's mandatory, I don't see it complaining for not having this information and introducing it now means introducing more points of failure.

green-creeper avatar Jun 08 '25 15:06 green-creeper

Yeah I totally understand, using SITL in Windows is complicated too, that's why I prefer Linux distros.

I think that hil_state_quterion is mandatory, at least most of external positioning systems reports coordinates and quaternions to represent a vehicle's pose.

angel-ayala avatar Jun 08 '25 15:06 angel-ayala

I am also doing a similar job. However, I am using HITL simulation and the px4 version of the pixhawk I use is 1.12.3. My problem is that when both the HIL_sensor and HIL_state_quternion messages are sent, the z-axis acceleration value zacc is incorrect. However, when only one of these messages is sent, the value of zacc is correct.

TinkerYxs avatar Jul 06 '25 12:07 TinkerYxs

Image When the zacc of hIL_sensor and the zacc of HIl_state_quaternion are fused ,the resulting zacc is -4.95 instead of -9.81. HIL_sensor acc : accel_data_ned =[-accel_data_enu[0],accel_data_enu[1],-1*accel_data_enu[2]] ;HIL_state_quaternion acc:accel_true_ned =[-accel_data_enu[0]*1000/9.81,accel_data_enu[1]1000/9.81,-1accel_data_enu[2]*1000/9.81] ;accel_data_enu is from webots

TinkerYxs avatar Jul 06 '25 12:07 TinkerYxs

This issue has been marked as stale due to 90 days of inactivity. If no further activity occurs, it will be automatically closed in 30 days. Please leave a comment, add a reaction, make an update, or remove the stale label if you’d like to keep it open.

github-actions[bot] avatar Oct 30 '25 02:10 github-actions[bot]

This issue has been closed due to prolonged inactivity after being marked as stale. If you believe this was closed in error or the topic is still relevant, please feel free to reopen it or create a new issue.

github-actions[bot] avatar Nov 30 '25 02:11 github-actions[bot]