Skip to content

Commit 714c265

Browse files
authored
Merge pull request #812 from cdyk/fix_809
Fixed compilation errors in unit tests.
2 parents 2e45a50 + 6a1657d commit 714c265

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

AirLib/include/vehicles/multirotor/controllers/MavLinkDroneController.hpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -787,16 +787,20 @@ struct MavLinkDroneController::impl {
787787
mag_output.magnetic_field_body,
788788
baro_output.pressure * 0.01f /*Pa to Milibar */, baro_output.altitude);
789789

790-
const auto& distance_output = getDistance()->getOutput();
791-
float pitch, roll, yaw;
792-
VectorMath::toEulerianAngle(distance_output.relative_pose.orientation, pitch, roll, yaw);
793-
794-
sendDistanceSensor(distance_output.min_distance / 100, //m -> cm
795-
distance_output.max_distance / 100, //m -> cm
796-
distance_output.distance,
797-
0, //sensor type: //TODO: allow changing in settings?
798-
77, //sensor id, //TODO: should this be something real?
799-
pitch); //TODO: convert from radians to degrees?
790+
791+
const auto * distance = getDistance();
792+
if (distance) {
793+
const auto& distance_output = distance->getOutput();
794+
float pitch, roll, yaw;
795+
VectorMath::toEulerianAngle(distance_output.relative_pose.orientation, pitch, roll, yaw);
796+
797+
sendDistanceSensor(distance_output.min_distance / 100, //m -> cm
798+
distance_output.max_distance / 100, //m -> cm
799+
distance_output.distance,
800+
0, //sensor type: //TODO: allow changing in settings?
801+
77, //sensor id, //TODO: should this be something real?
802+
pitch); //TODO: convert from radians to degrees?
803+
}
800804

801805
const auto gps = getGps();
802806
if (gps != nullptr) {

AirLibUnitTests/PixhawkTest.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ class PixhawkTest : public TestBase {
1111
public:
1212
virtual void run() override
1313
{
14-
SensorFactory sensor_factory;
15-
1614
//Test PX4 based drones
17-
auto pixhawk = MultiRotorParamsFactory::createConfig("Pixhawk", &sensor_factory);
15+
auto pixhawk = MultiRotorParamsFactory::createConfig("Pixhawk", std::make_shared<SensorFactory>());
1816

1917
DroneControllerBase* controller = pixhawk->getController();
2018
testAssert(controller != nullptr, "Couldn't get pixhawk controller");

AirLibUnitTests/RosFlightTest.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class RosFlightTest : public TestBase {
1212
public:
1313
virtual void run() override
1414
{
15-
SensorFactory sensor_factory;
16-
auto rosFlight = MultiRotorParamsFactory::createConfig("RosFlight", &sensor_factory);
15+
auto rosFlight = MultiRotorParamsFactory::createConfig("RosFlight", std::make_shared<SensorFactory>());
1716

1817
DroneControllerBase* controller = rosFlight->getController();
1918
testAssert(controller != nullptr, "Couldn't get controller");

AirLibUnitTests/SimpleFlightTest.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SimpleFlightTest : public TestBase
2222

2323
SensorFactory sensor_factory;
2424

25-
std::unique_ptr<MultiRotorParams> params = MultiRotorParamsFactory::createConfig("SimpleFlight", &sensor_factory);
25+
std::unique_ptr<MultiRotorParams> params = MultiRotorParamsFactory::createConfig("SimpleFlight", std::make_shared<SensorFactory>());
2626
MultiRotor vehicle;
2727
std::unique_ptr<Environment> environment;
2828
vehicle.initialize(params.get(), Pose(),

0 commit comments

Comments
 (0)