Skip to content

Commit c9d406c

Browse files
amathamkamathamk
authored andcommitted
AC_Simulink: simulink support for ArduCopter
Glue code to enable Simulink-generated controller with ArduCopter
1 parent 8c1da9a commit c9d406c

File tree

7 files changed

+116
-0
lines changed

7 files changed

+116
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
/// @file AC_Simulink_Base.h
4+
/// @brief Base class implementation of Simulink integration
5+
6+
#include <AP_Common/AP_Common.h>
7+
8+
class AC_Simulink_Base {
9+
public:
10+
virtual ~AC_Simulink_Base() {}
11+
virtual void init() = 0;
12+
virtual void update() = 0;
13+
virtual void reset() = 0;
14+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
/// @file AC_Simulink_ControllerInterfaces.cpp
3+
/// @brief Controller and motor interface of Simulink integration
4+
5+
#include <AP_HAL/AP_HAL.h>
6+
#include "AC_Simulink_ControllerInterfaces.h"
7+
8+
AC_Simulink_ControllerInterfaces::AC_Simulink_ControllerInterfaces(AP_AHRS_View *&ahrs,
9+
AC_AttitudeControl *&att_control, AC_PosControl *&pos_control, AP_MotorsMulticopter *&motors) {
10+
//Controller and Motor handles will be used by the Simulink generated code
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#pragma once
2+
3+
/// @file AC_Simulink_ControllerInterfaces.h
4+
/// @brief Controller and motor interface of Simulink integration
5+
6+
#include <AP_Common/AP_Common.h>
7+
#include <AP_AHRS/AP_AHRS_View.h>
8+
#include <AC_AttitudeControl/AC_AttitudeControl.h>
9+
#include <AC_AttitudeControl/AC_PosControl.h>
10+
#include <AP_Motors/AP_MotorsMulticopter.h>
11+
12+
class AC_Simulink_ControllerInterfaces {
13+
public:
14+
AC_Simulink_ControllerInterfaces(AP_AHRS_View *&ahrs,
15+
AC_AttitudeControl *&_att_control, AC_PosControl *&_pos_control,
16+
AP_MotorsMulticopter *&motors);
17+
18+
CLASS_NO_COPY(AC_Simulink_ControllerInterfaces);
19+
20+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
/// @file AC_Simulink_Empty.cpp
3+
/// @brief Empty class implementation for Simulink integration
4+
5+
#include "AC_Simulink_Empty.h"
6+
AC_Simulink_Empty::AC_Simulink_Empty() {
7+
}
8+
9+
void AC_Simulink_Empty::init() {
10+
}
11+
12+
void AC_Simulink_Empty::update() {
13+
}
14+
15+
void AC_Simulink_Empty::reset() {
16+
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
/// @file AC_Simulink_Empty.h
4+
/// @brief Empty implementation for Simulink integration
5+
6+
#include "AC_Simulink_Base.h"
7+
8+
class AC_Simulink_Empty : public AC_Simulink_Base {
9+
public:
10+
AC_Simulink_Empty();
11+
~AC_Simulink_Empty() override {}
12+
13+
void init() override;
14+
void update() override;
15+
void reset() override;
16+
17+
CLASS_NO_COPY(AC_Simulink_Empty);
18+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
/// @file AC_Simulink_Factory.cpp
3+
/// @brief Factory class for choosing the right class for Simulink integration based on the simulation mode
4+
5+
#include "AC_Simulink_Factory.h"
6+
7+
AC_Simulink_Base* AC_Simulink_Factory::createSimulinkInstance() {
8+
#ifdef MW_EXTERNAL_MODE
9+
return new AC_Simulink_ExtMode();
10+
#elif defined(MW_NORMAL_MODE)
11+
return new AC_Simulink_Normal();
12+
#elif defined(MW_CONNECTEDIO_MODE)
13+
return new AC_Simulink_ConnectedIO();
14+
#else
15+
return new AC_Simulink_Empty();
16+
#endif
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
/// @file AC_Simulink_Factory.h
4+
/// @brief Factory class for choosing the right class for Simulink integration based on the simulation mode
5+
6+
#include "AC_Simulink_Base.h"
7+
#ifdef MW_EXTERNAL_MODE
8+
#include "AC_Simulink_ExtMode.h"
9+
#elif defined(MW_NORMAL_MODE)
10+
#include "AC_Simulink_Normal.h"
11+
#elif defined(MW_CONNECTEDIO_MODE)
12+
#include "AC_Simulink_ConnectedIO.h"
13+
#else
14+
#include "AC_Simulink_Empty.h"
15+
#endif
16+
class AC_Simulink_Factory {
17+
public:
18+
static AC_Simulink_Base* createSimulinkInstance();
19+
};

0 commit comments

Comments
 (0)