Skip to content

Commit

Permalink
Additional changes for Ardupilot PR #1387
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Oct 9, 2018
1 parent 56dc900 commit f4a2c7c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 82 deletions.
1 change: 0 additions & 1 deletion AirLib/AirLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
<ItemGroup>
<ClCompile Include="src\api\RpcLibClientBase.cpp" />
<ClCompile Include="src\api\RpcLibServerBase.cpp" />
<ClCompile Include="src\vehicles\multirotor\MultiRotorParamsFactory.cpp" />
<ClCompile Include="src\vehicles\multirotor\api\MultirotorApiBase.cpp" />
<ClCompile Include="src\safety\ObstacleMap.cpp" />
<ClCompile Include="src\safety\SafetyEval.cpp" />
Expand Down
6 changes: 0 additions & 6 deletions AirLib/AirLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,5 @@
<ClCompile Include="src\vehicles\multirotor\api\MultirotorApiBase.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\vehicles\multirotor\MultiRotorParamsFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\vehicles\MultiRotorParamsFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
7 changes: 3 additions & 4 deletions AirLib/include/physics/FastPhysicsEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,10 @@ class FastPhysicsEngine : public PhysicsEngineBase {
body.kinematicsUpdated();


////// (FIXME this is from PhysicsBody, where it's commented out - it appears that we need it here to ensure that GPS sensing functions properly)
//TODO: this is now being done in PawnSimApi::update. We need to re-think this sequence
body.getEnvironment().setPosition(next.pose.position);
body.getEnvironment().update();
////// (End FIXME)
//with below commented out - Arducopter GPS may not work.
//body.getEnvironment().setPosition(next.pose.position);
//body.getEnvironment().update();

}

Expand Down
43 changes: 29 additions & 14 deletions AirLib/include/vehicles/multirotor/MultiRotorParamsFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,41 @@
#ifndef msr_airlib_vehicles_MultiRotorParamsFactory_hpp
#define msr_airlib_vehicles_MultiRotorParamsFactory_hpp

#include "vehicles/multirotor/MultiRotorParams.hpp"
#include "common/AirSimSettings.hpp"
#include "sensors/SensorFactory.hpp"
#include "vehicles/multirotor/firmwares/mavlink/MavLinkMultirotorApi.hpp"
#include "vehicles/multirotor/firmwares/mavlink/Px4MultiRotorParams.hpp"
#include "vehicles/multirotor/firmwares/simple_flight/SimpleFlightQuadXParams.hpp"
#include "vehicles/multirotor/firmwares/mavlink/ArduCopterSoloParams.hpp"


namespace msr { namespace airlib {

class MultiRotorParamsFactory {
public:

static void reset();

static std::unique_ptr<MultiRotorParams> createConfig(const AirSimSettings::VehicleSetting* vehicle_setting,
std::shared_ptr<const SensorFactory> sensor_factory);

private:

// Simple zero-based ID for ArduCopterSolo vehicles
static int next_solo_id_;

static std::unique_ptr<MultiRotorParams> createConfig(const AirSimSettings::VehicleSetting* vehicle_setting,
std::shared_ptr<const SensorFactory> sensor_factory)
{
std::unique_ptr<MultiRotorParams> config;

if (vehicle_setting->vehicle_type == AirSimSettings::kVehicleTypePX4) {
config.reset(new Px4MultiRotorParams(*static_cast<const AirSimSettings::MavLinkVehicleSetting*>(vehicle_setting),
sensor_factory));
}
else if (vehicle_setting->vehicle_type == AirSimSettings::kVehicleTypeArduCopterSolo) {
config.reset(new ArduCopterSoloParams(*static_cast<const AirSimSettings::MavLinkVehicleSetting*>(vehicle_setting), sensor_factory));
}
else if (vehicle_setting->vehicle_type == "" || //default config
vehicle_setting->vehicle_type == AirSimSettings::kVehicleTypeSimpleFlight) {
config.reset(new SimpleFlightQuadXParams(vehicle_setting, sensor_factory));
}
else
throw std::runtime_error(Utils::stringf(
"Cannot create vehicle config because vehicle name '%s' is not recognized",
vehicle_setting->vehicle_name.c_str()));

config->initialize();

return config;
}
};

}} //namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace msr { namespace airlib {
class ArduCopterSoloParams : public MultiRotorParams {

public:
ArduCopterSoloParams(const AirSimSettings::MavLinkVehicleSetting& vehicle_settings, std::shared_ptr<const SensorFactory> sensor_factory, int instance_id)
ArduCopterSoloParams(const AirSimSettings::MavLinkVehicleSetting& vehicle_settings, std::shared_ptr<const SensorFactory> sensor_factory)
: sensor_factory_(sensor_factory)
{
connection_info_ = getConnectionInfo(vehicle_settings, instance_id);
connection_info_ = getConnectionInfo(vehicle_settings);
}

virtual ~ArduCopterSoloParams() = default;
Expand Down Expand Up @@ -74,13 +74,9 @@ namespace msr { namespace airlib {
computeInertiaMatrix(params.inertia, params.body_box, params.rotor_poses, box_mass, motor_assembly_weight);
}

static const AirSimSettings::MavLinkConnectionInfo getConnectionInfo(const AirSimSettings::MavLinkVehicleSetting& vehicle_setting, int instance_id)
static const AirSimSettings::MavLinkConnectionInfo getConnectionInfo(const AirSimSettings::MavLinkVehicleSetting& vehicle_setting)
{
AirSimSettings::MavLinkConnectionInfo result = vehicle_setting.connection_info;

result.sitl_ip_port += 10 * instance_id;
result.ip_port += 10 * instance_id;

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,8 @@ class MavLinkMultirotorApi : public MultirotorApiBase

protected: //variables

//TODO: below was made protected from private to support Ardupilot
//implementation but we need to review this and avoid having protected variables
static const int RotorControlsCount = 8;

const SensorCollection* sensors_;
Expand Down
47 changes: 0 additions & 47 deletions AirLib/src/vehicles/multirotor/MultiRotorParamsFactory.cpp

This file was deleted.

3 changes: 0 additions & 3 deletions Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "Kismet/GameplayStatics.h"
#include "Misc/OutputDeviceNull.h"
#include "Engine/World.h"
#include "vehicles/multirotor/MultiRotorParamsFactory.hpp"

#include <memory>
#include "AirBlueprintLib.h"
Expand Down Expand Up @@ -438,8 +437,6 @@ void ASimModeBase::setupVehiclesAndCamera()
camera_director_position_uu);
initializeCameraDirector(camera_transform, camera_director_setting.follow_distance);

MultiRotorParamsFactory::reset();

//find all vehicle pawns
{
TArray<AActor*> pawns;
Expand Down

0 comments on commit f4a2c7c

Please sign in to comment.