standalone external modes

Signed-off-by: frederik <frederik@auterion.com>
This commit is contained in:
frederik 2023-11-14 13:56:21 +01:00
parent 8e0a2e38fe
commit 4e8554f0a6
7 changed files with 130 additions and 77 deletions

View File

@ -38,6 +38,7 @@ if [ "$PX4_SIMULATOR" = "sihsim" ] || [ "$(param show -q SYS_AUTOSTART)" -eq "0"
elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" -eq "1" ]; then elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" -eq "1" ]; then
# set local coordinate frame reference # set local coordinate frame reference
if [ -n "${PX4_HOME_LAT}" ]; then if [ -n "${PX4_HOME_LAT}" ]; then
param set SIM_GZ_HOME_LAT ${PX4_HOME_LAT} param set SIM_GZ_HOME_LAT ${PX4_HOME_LAT}
@ -59,36 +60,40 @@ elif [ "$PX4_SIMULATOR" = "gz" ] || [ "$(param show -q SIM_GZ_EN)" -eq "1" ]; th
. ../gz_env.sh . ../gz_env.sh
fi fi
# "gz sim" only avaiilable in Garden and later # Only start up Gazebo if STANDALONE set to false
GZ_SIM_VERSIONS=$(gz sim --versions 2>&1) if [ "$STANDALONE" != '1' ]; then
if [ $? -eq 0 ] && [ "${GZ_SIM_VERSIONS}" != "" ]
then
# "gz sim" from Garden on
gz_command="gz"
gz_sub_command="sim"
else
echo "ERROR [init] Gazebo gz please install gz-garden"
exit 1
fi
# look for running ${gz_command} gazebo world # "gz sim" only avaiilable in Garden and later
gz_world=$( ${gz_command} topic -l | grep -m 1 -e "^/world/.*/clock" | sed 's/\/world\///g; s/\/clock//g' ) GZ_SIM_VERSIONS=$(gz sim --versions 2>&1)
if [ $? -eq 0 ] && [ "${GZ_SIM_VERSIONS}" != "" ]
# shellcheck disable=SC2153 then
if [ -z "${gz_world}" ] && [ -n "${PX4_GZ_WORLDS}" ] && [ -n "${PX4_GZ_WORLD}" ]; then # "gz sim" from Garden on
gz_command="gz"
echo "INFO [init] starting gazebo with world: ${PX4_GZ_WORLDS}/${PX4_GZ_WORLD}.sdf" gz_sub_command="sim"
else
${gz_command} ${gz_sub_command} --verbose=1 -r -s "${PX4_GZ_WORLDS}/${PX4_GZ_WORLD}.sdf" & echo "ERROR [init] Gazebo gz please install gz-garden"
exit 1
if [ -z "${HEADLESS}" ]; then
# HEADLESS not set, starting gui
${gz_command} ${gz_sub_command} -g &
fi fi
else # look for running ${gz_command} gazebo world
echo "INFO [init] gazebo already running world: ${gz_world}" gz_world=$( ${gz_command} topic -l | grep -m 1 -e "^/world/.*/clock" | sed 's/\/world\///g; s/\/clock//g' )
PX4_GZ_WORLD=${gz_world}
# shellcheck disable=SC2153
if [ -z "${gz_world}" ] && [ -n "${PX4_GZ_WORLDS}" ] && [ -n "${PX4_GZ_WORLD}" ]; then
echo "INFO [init] starting gazebo with world: ${PX4_GZ_WORLDS}/${PX4_GZ_WORLD}.sdf"
${gz_command} ${gz_sub_command} --verbose=1 -r -s "${PX4_GZ_WORLDS}/${PX4_GZ_WORLD}.sdf" &
if [ -z "${HEADLESS}" ]; then
# HEADLESS not set, starting gui
${gz_command} ${gz_sub_command} -g &
fi
else
echo "INFO [init] gazebo already running world: ${gz_world}"
PX4_GZ_WORLD=${gz_world}
fi
fi fi
# start gz_bridge # start gz_bridge

View File

@ -69,7 +69,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/body.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/body.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -184,7 +184,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://rc_cessna/meshes/iris_prop_ccw.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -229,7 +229,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/left_aileron.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/left_aileron.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -385,7 +385,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/right_aileron.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/right_aileron.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -412,7 +412,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/left_flap.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/left_flap.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -439,7 +439,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/right_flap.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/right_flap.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -466,7 +466,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/elevators.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/elevators.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -493,7 +493,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.1 0.1 0.1</scale> <scale>0.1 0.1 0.1</scale>
<uri>model://rc_cessna/meshes/rudder.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/RC%20Cessna/tip/files/meshes/rudder.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>

View File

@ -43,7 +43,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.001 0.001 0.001</scale> <scale>0.001 0.001 0.001</scale>
<uri>model://standard_vtol/meshes/x8_wing.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/x8_wing.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -183,7 +183,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://standard_vtol/meshes/iris_prop_ccw.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -246,7 +246,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://standard_vtol/meshes/iris_prop_ccw.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -309,7 +309,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://standard_vtol/meshes/iris_prop_ccw.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -372,7 +372,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://standard_vtol/meshes/iris_prop_ccw.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -436,7 +436,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.8 0.8 0.8</scale> <scale>0.8 0.8 0.8</scale>
<uri>model://standard_vtol/meshes/iris_prop_ccw.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/iris_prop_ccw.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -483,7 +483,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.001 0.001 0.001</scale> <scale>0.001 0.001 0.001</scale>
<uri>model://standard_vtol/meshes/x8_elevon_left.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/x8_elevon_left.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -510,7 +510,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.001 0.001 0.001</scale> <scale>0.001 0.001 0.001</scale>
<uri>model://standard_vtol/meshes/x8_elevon_right.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/Standard%20VTOL/tip/files/meshes/x8_elevon_right.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>

View File

@ -23,7 +23,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/NXP-HGD-CF.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/NXP-HGD-CF.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -32,7 +32,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Base.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Base.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -41,7 +41,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Base.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Base.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -50,7 +50,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Base.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Base.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -59,7 +59,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Base.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Base.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -77,7 +77,7 @@
<specular>1.0 1.0 1.0</specular> <specular>1.0 1.0 1.0</specular>
<pbr> <pbr>
<metal> <metal>
<albedo_map>model://x500/materials/textures/nxp.png</albedo_map> <albedo_map>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/materials/textures/nxp.png</albedo_map>
</metal> </metal>
</pbr> </pbr>
</material> </material>
@ -96,7 +96,7 @@
<specular>1.0 1.0 1.0</specular> <specular>1.0 1.0 1.0</specular>
<pbr> <pbr>
<metal> <metal>
<albedo_map>model://x500/materials/textures/nxp.png</albedo_map> <albedo_map>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/materials/textures/nxp.png</albedo_map>
</metal> </metal>
</pbr> </pbr>
</material> </material>
@ -115,7 +115,7 @@
<specular>1.0 1.0 1.0</specular> <specular>1.0 1.0 1.0</specular>
<pbr> <pbr>
<metal> <metal>
<albedo_map>model://x500/materials/textures/rd.png</albedo_map> <albedo_map>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/materials/textures/rd.png</albedo_map>
</metal> </metal>
</pbr> </pbr>
</material> </material>
@ -250,7 +250,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale> <scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale>
<uri>model://x500/meshes/1345_prop_ccw.stl</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/1345_prop_ccw.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -265,7 +265,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Bell.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Bell.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -322,7 +322,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale> <scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale>
<uri>model://x500/meshes/1345_prop_ccw.stl</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/1345_prop_ccw.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -337,7 +337,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Bell.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Bell.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -394,7 +394,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale> <scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale>
<uri>model://x500/meshes/1345_prop_cw.stl</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/1345_prop_cw.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -409,7 +409,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Bell.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Bell.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>
@ -466,7 +466,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale> <scale>0.8461538461538461 0.8461538461538461 0.8461538461538461</scale>
<uri>model://x500/meshes/1345_prop_cw.stl</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/1345_prop_cw.stl</uri>
</mesh> </mesh>
</geometry> </geometry>
<material> <material>
@ -481,7 +481,7 @@
<geometry> <geometry>
<mesh> <mesh>
<scale>1 1 1</scale> <scale>1 1 1</scale>
<uri>model://x500/meshes/5010Bell.dae</uri> <uri>https://fuel.gazebosim.org/1.0/PX4/models/x500/1/files/meshes/5010Bell.dae</uri>
</mesh> </mesh>
</geometry> </geometry>
</visual> </visual>

View File

@ -1,6 +1,6 @@
############################################################################ ############################################################################
# #
# Copyright (c) 2015 PX4 Development Team. All rights reserved. # Copyright (c) 2015-2023 PX4 Development Team. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
@ -31,11 +31,12 @@
# #
############################################################################ ############################################################################
add_subdirectory(Arming)
add_subdirectory(failsafe)
add_subdirectory(failure_detector) add_subdirectory(failure_detector)
add_subdirectory(HealthAndArmingChecks) add_subdirectory(HealthAndArmingChecks)
add_subdirectory(failsafe)
add_subdirectory(Arming)
add_subdirectory(ModeUtil) add_subdirectory(ModeUtil)
add_subdirectory(MulticopterThrowLaunch)
px4_add_module( px4_add_module(
MODULE modules__commander MODULE modules__commander
@ -59,20 +60,22 @@ px4_add_module(
mag_calibration.cpp mag_calibration.cpp
rc_calibration.cpp rc_calibration.cpp
Safety.cpp Safety.cpp
UserModeIntention.cpp
worker_thread.cpp worker_thread.cpp
MODULE_CONFIG MODULE_CONFIG
module.yaml module.yaml
DEPENDS DEPENDS
ArmAuthorization
circuit_breaker circuit_breaker
failsafe
failure_detector failure_detector
geo geo
health_and_arming_checks health_and_arming_checks
hysteresis hysteresis
ArmAuthorization mode_util
MulticopterThrowLaunch
sensor_calibration sensor_calibration
world_magnetic_model world_magnetic_model
mode_util
failsafe
) )
px4_add_unit_gtest(SRC mag_calibration_test.cpp LINKLIBS modules__commander) px4_add_unit_gtest(SRC mag_calibration_test.cpp LINKLIBS modules__commander)

View File

@ -34,14 +34,13 @@
#pragma once #pragma once
/* Helper classes */ /* Helper classes */
#include "failure_detector/FailureDetector.hpp"
#include "failsafe/failsafe.h" #include "failsafe/failsafe.h"
#include "Safety.hpp" #include "failure_detector/FailureDetector.hpp"
#include "worker_thread.hpp"
#include "HealthAndArmingChecks/HealthAndArmingChecks.hpp" #include "HealthAndArmingChecks/HealthAndArmingChecks.hpp"
#include "HomePosition.hpp" #include "HomePosition.hpp"
#include "ModeManagement.hpp" #include "ModeManagement.hpp"
#include "UserModeIntention.hpp" #include "UserModeIntention.hpp"
#include "worker_thread.hpp"
#include <lib/controllib/blocks.hpp> #include <lib/controllib/blocks.hpp>
#include <lib/hysteresis/hysteresis.h> #include <lib/hysteresis/hysteresis.h>
@ -81,7 +80,6 @@
#include <uORB/topics/vehicle_command.h> #include <uORB/topics/vehicle_command.h>
#include <uORB/topics/vehicle_global_position.h> #include <uORB/topics/vehicle_global_position.h>
#include <uORB/topics/vehicle_land_detected.h> #include <uORB/topics/vehicle_land_detected.h>
#include <uORB/topics/vehicle_local_position.h>
#include <uORB/topics/vtol_vehicle_status.h> #include <uORB/topics/vtol_vehicle_status.h>
using math::constrain; using math::constrain;
@ -176,6 +174,10 @@ private:
void safetyButtonUpdate(); void safetyButtonUpdate();
bool isThrowLaunchInProgress() const;
void throwLaunchUpdate();
void vtolStatusUpdate(); void vtolStatusUpdate();
void updateTunes(); void updateTunes();
@ -216,6 +218,7 @@ private:
FailsafeBase &_failsafe{_failsafe_instance}; FailsafeBase &_failsafe{_failsafe_instance};
FailureDetector _failure_detector{this}; FailureDetector _failure_detector{this};
HealthAndArmingChecks _health_and_arming_checks{this, _vehicle_status}; HealthAndArmingChecks _health_and_arming_checks{this, _vehicle_status};
MulticopterThrowLaunch _multicopter_throw_launch{this};
Safety _safety{}; Safety _safety{};
WorkerThread _worker_thread{}; WorkerThread _worker_thread{};
ModeManagement _mode_management{ ModeManagement _mode_management{

View File

@ -42,6 +42,8 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <cstdlib>
#include <fstream>
GZBridge::GZBridge(const char *world, const char *name, const char *model, GZBridge::GZBridge(const char *world, const char *name, const char *model,
const char *pose_str) : const char *pose_str) :
@ -72,7 +74,18 @@ int GZBridge::init()
// service call to create model // service call to create model
gz::msgs::EntityFactory req{}; gz::msgs::EntityFactory req{};
req.set_sdf_filename(_model_sim + "/model.sdf"); std::string filename = "../../../Tools/simulation/gz/models/" + _model_sim + "/model.sdf";
std::ifstream file(filename);
std::string fileContent;
if (file.is_open()) {
// Read the file content into a string
fileContent = std::string((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>()));
file.close();
}
req.set_sdf(fileContent);
req.set_name(_model_name); // New name for the entity, overrides the name on the SDF. req.set_name(_model_name); // New name for the entity, overrides the name on the SDF.
@ -116,15 +129,44 @@ int GZBridge::init()
bool result; bool result;
std::string create_service = "/world/" + _world_name + "/create"; std::string create_service = "/world/" + _world_name + "/create";
if (_node.Request(create_service, req, 1000, rep, result)) { bool gz_called = false;
if (!rep.data() || !result) { // Check if STANDALONE has been set.
PX4_ERR("EntityFactory service call failed"); char *standalone_val = std::getenv("STANDALONE");
if ((standalone_val != nullptr) && (std::strcmp(standalone_val, "1") == 0)) {
// Check if Gazebo has been called and if not attempt to reconnect.
while (gz_called == false) {
if (_node.Request(create_service, req, 1000, rep, result)) {
if (!rep.data() || !result) {
PX4_ERR("EntityFactory service call failed");
return PX4_ERROR;
} else {
gz_called = true;
}
}
// If Gazebo has not been called, wait 2 seconds and try again.
else {
PX4_WARN("Service call timed out as Gazebo has not been detected.");
system_usleep(2000000);
}
}
}
// If STANDALONE has not been set, do not retry to reconnect.
else {
if (_node.Request(create_service, req, 1000, rep, result)) {
if (!rep.data() || !result) {
PX4_ERR("EntityFactory service call failed");
return PX4_ERROR;
}
} else {
PX4_ERR("Service call timed out");
return PX4_ERROR; return PX4_ERROR;
} }
} else {
PX4_ERR("Service call timed out");
return PX4_ERROR;
} }
} }