Skip to content

Commit

Permalink
On branch update_hitl_ip_setup
Browse files Browse the repository at this point in the history
Updated IPs of FC for model_hitl.sdf files in Tools/simulator/gz/models
Adjust delays for improved reliability for MAVSDK testing
  • Loading branch information
Ilia-Loginov committed Nov 28, 2024
1 parent 87d267a commit c9f6ab3
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Tools/simulation/gz/hitl_run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#example for run
#./Tools/simulation/gz/hitl_run.sh x500/model_hitl.sdf
#./Tools/simulation/gz/hitl_run.sh ssrc_holybro_x500/model_hitl.sdf

MODEL_PATH=$1

Expand Down
3 changes: 2 additions & 1 deletion Tools/simulation/gz/models/ssrc_holybro_x500/model_hitl.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<plugin filename="libmavlink_hitl_gazebosim.so" name="mavlink_interface::GazeboMavlinkInterface">
<robotNamespace/>
<imuSubTopic>/link/base_link/sensor/imu_sensor/imu</imuSubTopic>
<gpsSubTopic>/link/base_link/sensor/navsat_sensor/navsat</gpsSubTopic>
<poseSubTopic>/pose/info</poseSubTopic>
<mavlink_addr>192.168.200.101</mavlink_addr>
<mavlink_addr>192.168.202.1</mavlink_addr>
<mavlink_udp_local_port>14542</mavlink_udp_local_port>
<mavlink_udp_remote_port>14543</mavlink_udp_remote_port>
<mavlink_tcp_port>4560</mavlink_tcp_port>
Expand Down
3 changes: 2 additions & 1 deletion Tools/simulation/gz/models/ssrc_skywalker_x8/model_hitl.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<plugin filename="libmavlink_hitl_gazebosim.so" name="mavlink_interface::GazeboMavlinkInterface">
<robotNamespace/>
<imuSubTopic>/link/base_link/sensor/imu_sensor/imu</imuSubTopic>
<gpsSubTopic>/link/base_link/sensor/navsat_sensor/navsat</gpsSubTopic>
<poseSubTopic>/pose/info</poseSubTopic>
<mavlink_addr>192.168.200.101</mavlink_addr>
<mavlink_addr>192.168.202.1</mavlink_addr>
<mavlink_udp_local_port>14542</mavlink_udp_local_port>
<mavlink_udp_remote_port>14543</mavlink_udp_remote_port>
<mavlink_tcp_port>4560</mavlink_tcp_port>
Expand Down
3 changes: 2 additions & 1 deletion Tools/simulation/gz/models/ssrc_standard_vtol/model_hitl.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<plugin filename="libmavlink_hitl_gazebosim.so" name="mavlink_interface::GazeboMavlinkInterface">
<robotNamespace/>
<imuSubTopic>/link/base_link/sensor/imu_sensor/imu</imuSubTopic>
<gpsSubTopic>/link/base_link/sensor/navsat_sensor/navsat</gpsSubTopic>
<poseSubTopic>/pose/info</poseSubTopic>
<mavlink_addr>192.168.200.101</mavlink_addr>
<mavlink_addr>192.168.202.1</mavlink_addr>
<mavlink_udp_local_port>14542</mavlink_udp_local_port>
<mavlink_udp_remote_port>14543</mavlink_udp_remote_port>
<mavlink_tcp_port>4560</mavlink_tcp_port>
Expand Down
1 change: 1 addition & 0 deletions Tools/simulation/gz/models/x500/model_hitl.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<plugin filename="libmavlink_hitl_gazebosim.so" name="mavlink_interface::GazeboMavlinkInterface">
<robotNamespace/>
<imuSubTopic>/link/base_link/sensor/imu_sensor/imu</imuSubTopic>
<gpsSubTopic>/link/base_link/sensor/navsat_sensor/navsat</gpsSubTopic>
<poseSubTopic>/pose/info</poseSubTopic>
<mavlink_addr>192.168.0.3</mavlink_addr>
<mavlink_udp_local_port>14542</mavlink_udp_local_port>
Expand Down
4 changes: 4 additions & 0 deletions test/mavsdk_tests/mavsdk_preparing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ int main(int argc, char **argv)

if (command_set_param == command) {
//TODO: For some reason when we set the new value it sometimes takes several attempts to change a parameter.
//The reason is the bug of mavsdk lib.
//When we set one parameter many times, sometimes the lib sends not the new but the previous value.
int attempt = 1;
const int max_attemp = 5;
const auto param_name = "SYS_AUTOSTART";
Expand All @@ -137,6 +139,8 @@ int main(int argc, char **argv)
auto res = param.get_param_int(param_name);

if (res.first == Param::Result::Success && res.second == param_value) {
//For some reason, if we reboot device immediately after changing of parameter, it will not be saved.
std::this_thread::sleep_for(3s);
break;
}

Expand Down
1 change: 0 additions & 1 deletion test/mavsdk_tests/mavsdk_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ def reboot_px4(self):

if (res):
print("The device has successfully rebooted")
time.sleep(15)
else:
print("Reboot failed")
exit(-1)
Expand Down
4 changes: 2 additions & 2 deletions test/mavsdk_tests/process_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def start(self) -> None:

if self.name == "mavsdk_tests":
if self.env["HIL_MODE"] == "hitl":
delay = 10
delay = 30
print("Waiting ", delay, " seconds for connection to be established... ")
time.sleep(10)
time.sleep(delay)
print("Running test...")
atexit.register(self.stop)

Expand Down

0 comments on commit c9f6ab3

Please sign in to comment.