Skip to content

Commit

Permalink
rectoring choise of firmware to json setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sytelus committed Apr 21, 2017
1 parent 938ebfb commit 5549d6c
Show file tree
Hide file tree
Showing 20 changed files with 340 additions and 502 deletions.
6 changes: 2 additions & 4 deletions AirLib/AirLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@
<ClInclude Include="include\sensors\magnetometer\MagnetometerSimpleParams.hpp" />
<ClInclude Include="include\sensors\SensorBase.hpp" />
<ClInclude Include="include\sensors\SensorCollection.hpp" />
<ClInclude Include="include\vehicles\configs\BlacksheepQuadX.hpp" />
<ClInclude Include="include\vehicles\configs\FlamewheelQuadX.hpp" />
<ClInclude Include="include\vehicles\configs\PX4ConfigCreator.hpp" />
<ClInclude Include="include\vehicles\configs\Px4HILQuadX.hpp" />
<ClInclude Include="include\vehicles\configs\Px4QuadX.hpp" />
<ClInclude Include="include\controllers\ControllerBase.hpp" />
<ClInclude Include="include\controllers\MotorDirectController.hpp" />
<ClInclude Include="include\controllers\MotorDirectControllerParams.hpp" />
Expand All @@ -120,6 +117,7 @@
<ClInclude Include="include\vehicles\configs\RosFlightQuadX.hpp" />
<ClInclude Include="include\vehicles\MultiRotor.hpp" />
<ClInclude Include="include\vehicles\MultiRotorParams.hpp" />
<ClInclude Include="include\vehicles\MultiRotorParamsFactory.hpp" />
<ClInclude Include="include\vehicles\Rotor.hpp" />
<ClInclude Include="include\vehicles\RotorParams.hpp" />
</ItemGroup>
Expand Down
12 changes: 3 additions & 9 deletions AirLib/AirLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,13 @@
<ClInclude Include="include\vehicles\configs\RosFlightQuadX.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\vehicles\configs\BlacksheepQuadX.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\vehicles\configs\PX4ConfigCreator.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\vehicles\configs\FlamewheelQuadX.hpp">
<ClInclude Include="include\common\common_utils\Log.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\vehicles\configs\Px4HILQuadX.hpp">
<ClInclude Include="include\vehicles\MultiRotorParamsFactory.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\common\common_utils\Log.hpp">
<ClInclude Include="include\vehicles\configs\Px4QuadX.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down
11 changes: 4 additions & 7 deletions AirLib/include/common/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <cstdint>
#include "common/common_utils/Utils.hpp"
#include "common_utils/RandomGenerator.hpp"
#include "VectorMath.hpp"
Expand All @@ -22,8 +23,9 @@ namespace msr { namespace airlib {

//numericals
typedef float real_T;
typedef unsigned int int32_T;
typedef bool boolean_T;
//this is not required for most compilers
typedef unsigned int uint;
typedef unsigned long ulong;

//well known types
typedef msr::airlib::VectorMathf VectorMath;
Expand All @@ -43,11 +45,6 @@ typedef VectorMath::RandomVectorGaussianT RandomVectorGaussianR;
typedef VectorMath::RandomVectorT RandomVectorR;


//this is not required for most compilers
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;

template <typename T>
using vector = std::vector<T>;
Expand Down
1 change: 0 additions & 1 deletion AirLib/include/controllers/MavLinkDroneController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class MavLinkDroneController : public DroneControllerBase
struct ConnectionInfo {
/* Default values are requires so uninitialized instance doesn't have random values */

std::string vehicle_name = "Pixhawk";
bool use_serial = true; // false means use UDP instead
//Used to connect via HITL: needed only if use_serial = true
std::string serial_port = "*";
Expand Down
9 changes: 9 additions & 0 deletions AirLib/include/vehicles/MultiRotorParams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "sensors/gps/GpsSimple.hpp"
#include "sensors/magnetometer/MagnetometerSimple.hpp"

//below includes are because of setPhysicsGroundTruth methog
#include "physics/Environment.hpp"
#include "physics/Kinematics.hpp"

namespace msr { namespace airlib {

Expand Down Expand Up @@ -88,6 +91,12 @@ class MultiRotorParams {
return controller_.get();
}

//below method is needed to support firmwares without state estimation. In future, we should probably remove this support.
virtual void initializePhysics(const Environment* environment, const Kinematics::State* kinematics)
{
//by default don't use it. If derived class needs this, it should override.
}

protected: //must override by derived class
//this method must clean up any previous initializations
virtual void setup(Params& params, SensorCollection& sensors, unique_ptr<DroneControllerBase>& controller) = 0;
Expand Down
41 changes: 41 additions & 0 deletions AirLib/include/vehicles/MultiRotorParamsFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#ifndef msr_airlib_vehicles_MultiRotorParamsFactory_hpp
#define msr_airlib_vehicles_MultiRotorParamsFactory_hpp

#include "vehicles/configs/RosFlightQuadX.hpp"
#include "controllers/MavLinkDroneController.hpp"
#include "controllers/Settings.hpp"
#include "vehicles/configs/PX4QuadX.hpp"


namespace msr { namespace airlib {

class MultiRotorParamsFactory {
public:
static std::unique_ptr<MultiRotorParams> createConfig(const std::string& vehicle_name)
{
//read settings and override defaults
Settings& settings = Settings::singleton();
if (!settings.isLoadSuccess())
throw std::runtime_error("Cannot load settings.json");

Settings child;
settings.getChild(vehicle_name, child);

std::unique_ptr<MultiRotorParams> config;

if (vehicle_name == "Pixhawk") {
config.reset(new Px4QuadX(child));
} else if (vehicle_name == "RosFlight") {
config.reset(new RosFlightQuadX(child));
} else
throw std::runtime_error(Utils::stringf("Cannot create vehicle config because vehicle name '%s' is not recognized", vehicle_name.c_str()));

return config;
}
};

}} //namespace
#endif
137 changes: 0 additions & 137 deletions AirLib/include/vehicles/configs/BlacksheepQuadX.hpp

This file was deleted.

70 changes: 0 additions & 70 deletions AirLib/include/vehicles/configs/FlamewheelQuadX.hpp

This file was deleted.

Loading

0 comments on commit 5549d6c

Please sign in to comment.