diff --git a/sw/simulator/Makefile b/sw/simulator/Makefile index 21d3641ef2..8de05c1053 100644 --- a/sw/simulator/Makefile +++ b/sw/simulator/Makefile @@ -91,8 +91,10 @@ JSBSIM = /home/violato/JSBSim CC = g++ CFLAGS = -Wall -I $(JSBSIM)/src -I../include LDFLAGS = -L $(JSBSIM)/lib -lJSBSim -CFLAGS += `pkg-config glib-2.0 --cflags` -I /usr/include/meschach -LDFLAGS += `pkg-config glib-2.0 --libs` -lm -lmeschach -lpcre -lglibivy +CFLAGS += -I /usr/include/meschach +LDFLAGS += -lmeschach +#CFLAGS += `pkg-config glib-2.0 --cflags` +#LDFLAGS += `pkg-config glib-2.0 --libs` -lm -lpcre -lglibivy test1: nps_test1.c $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) diff --git a/sw/simulator/nps_fdm.h b/sw/simulator/nps_fdm.h index 506643e1bf..6df67dc036 100644 --- a/sw/simulator/nps_fdm.h +++ b/sw/simulator/nps_fdm.h @@ -5,6 +5,45 @@ #include +/* Vehicle specific descriptions */ + +struct NpsDummy { + /* force applied to the ball in Newton */ + double f_input; +}; + + +#define NPS_QUAD_MOTOR_FRONT 0 +#define NPS_QUAD_MOTOR_BACK 1 +#define NPS_QUAD_MOTOR_RIGHT 2 +#define NPS_QUAD_MOTOR_LEFT 3 +#define NPS_QUAD_MOTOR_NB 4 + +struct NpsQuad { + /* battery voltage in V */ + double battery; + /* motor commands [0:1] */ + VEC* motor_commands; + /* propeller rotation speed in rad/s */ + VEC* prop_omega; +}; + + +#define NPS_SFW_ACTUATOR_THROTTLE 0 +#define NPS_SFW_ACTUATOR_AILERON_R 1 +#define NPS_SFW_ACTUATOR_AILERON_L 2 +#define NPS_SFW_ACTUATOR_NB 3 + +struct NpsSFW { + + double prop_omega; + /* + Deflection of control surfaces in radian + Normalized throttle [0:1] + */ + VEC* actuators; +}; + struct NpsFdmState { @@ -22,54 +61,17 @@ struct NpsFdmState { VEC* ecef_to_ltp_quat; - // vehicle specific + /* vehicle specific */ union { struct NpsDummy dummy; struct NpsQuad quad; struct NpsSFW fw; - }; + } vehicle; }; -struct NpsDummy { - /* force applied to the ball in Newton */ - double f_input; -}; - - -#define NPS_QUAD_MOTOR_FRONT 0 -#define NPS_QUAD_MOTOR_BACK 1 -#define NPS_QUAD_MOTOR_RIGHT 2 -#define NPS_QUAD_MOTOR_LEFT 3 -#define NPS_QUAD_MOTOR_NB 4 - -struct NpsQuad { - /* battery voltage in V */ - double battery; - /* motor commands [0:1] - VEC* motor_commands; - /* propeller rotation speed in rad/s */ - VEC* prop_omega; -}; - - - -#define NPS_SFW_ACTUATOR_THROTTLE 0 -#define NPS_SFW_ACTUATOR_AILERON_R 1 -#define NPS_SFW_ACTUATOR_AILERON_L 2 -#define NPS_SFW_ACTUATOR_NB 3 - -struct NpsSFW { - - double prop_omega; - /* - deflection of control surfaces in radian - normalized throttle [0:1] - */ - VEC* actuators; -} diff --git a/sw/simulator/nps_test1.c b/sw/simulator/nps_test1.c index 0a64d508db..2917f78149 100644 --- a/sw/simulator/nps_test1.c +++ b/sw/simulator/nps_test1.c @@ -1,7 +1,8 @@ -#include "nps_fdm.h" #include #include +#include "nps_fdm.h" + string RootDir = "/home/violato/JSBSim/"; string AircraftName = "ball"; string ResetName = "reset00"; @@ -9,14 +10,12 @@ string ResetName = "reset00"; static struct NpsFdmState fdm_state; - static void feed_inputs(JSBSim::FGFDMExec* fdmex) { //double hover_force = 0.; - fdmex->SetPropertyValue("/fdm/jsbsim/fcs/parachute_reef_pos_norm", fdm_state.dummy.f_input); + fdmex->SetPropertyValue("/fdm/jsbsim/fcs/parachute_reef_pos_norm", fdm_state.vehicle.dummy.f_input); - } static void fetch_state(JSBSim::FGFDMExec* fdmex) {