mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-25 06:15:43 +08:00
[nps] if NPS_JS_MODE_AXIS is defined: use it as axis for the mode channel instead of buttons
add fraser jsbsim quadrotor model with front/back motors turning CCW, left/right CW
This commit is contained in:
@@ -225,6 +225,7 @@
|
||||
<define name="ACTUATOR_NAMES" value="{"front_motor", "back_motor", "right_motor", "left_motor"}"/>
|
||||
<define name="INITIAL_CONDITITONS" value=""reset00""/>
|
||||
<define name="SENSORS_PARAMS" value=""nps_sensors_params_default.h""/>
|
||||
<define name="JS_MODE_AXIS" value="4"/>
|
||||
</section>
|
||||
|
||||
<section name="AUTOPILOT">
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<fdm_config name="QUAD COMPLETE EXT" version="2.0" release="BETA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd">
|
||||
|
||||
<fileheader>
|
||||
<author> Gustavo Violato & Antoine Drouin</author>
|
||||
<filecreationdate> 24-02-2009 </filecreationdate>
|
||||
<version> Version 0.9 - beta</version>
|
||||
<description> Simple Quadrotor without rotor dynamic </description>
|
||||
<author>Gustavo Violato & Antoine Drouin</author>
|
||||
<filecreationdate>24-02-2009</filecreationdate>
|
||||
<version>Version 0.9 - beta</version>
|
||||
<description>Simple Quadrotor without rotor dynamic (front/back motors turning CW, left/right CCW)</description>
|
||||
</fileheader>
|
||||
|
||||
<metrics>
|
||||
|
||||
@@ -0,0 +1,396 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl" href="http://jsbsim.sourceforge.net/JSBSim.xsl"?>
|
||||
<fdm_config name="QUAD COMPLETE EXT" version="2.0" release="BETA" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jsbsim.sourceforge.net/JSBSim.xsd">
|
||||
|
||||
<fileheader>
|
||||
<author>Gustavo Violato & Antoine Drouin</author>
|
||||
<filecreationdate>24-02-2009</filecreationdate>
|
||||
<version>Version 0.9 - beta</version>
|
||||
<description>Simple Quadrotor without rotor dynamic (front/back motors turning CCW, left/right CW)</description>
|
||||
</fileheader>
|
||||
|
||||
<metrics>
|
||||
<wingarea unit="IN2"> 78.53 </wingarea>
|
||||
<wingspan unit="IN"> 10 </wingspan>
|
||||
<chord unit="IN"> 6.89 </chord>
|
||||
<htailarea unit="FT2"> 0 </htailarea>
|
||||
<htailarm unit="FT"> 0 </htailarm>
|
||||
<vtailarea unit="FT2"> 0 </vtailarea>
|
||||
<vtailarm unit="FT"> 0 </vtailarm>
|
||||
<location name="AERORP" unit="IN">
|
||||
<x> 0 </x>
|
||||
<y> 0 </y>
|
||||
<z> 0 </z>
|
||||
</location>
|
||||
<location name="EYEPOINT" unit="IN">
|
||||
<x> 0 </x>
|
||||
<y> 0 </y>
|
||||
<z> 0 </z>
|
||||
</location>
|
||||
<location name="VRP" unit="IN">
|
||||
<x> 0 </x>
|
||||
<y> 0 </y>
|
||||
<z> 0 </z>
|
||||
</location>
|
||||
</metrics>
|
||||
|
||||
<mass_balance>
|
||||
<ixx unit="SLUG*FT2"> 0.005 </ixx>
|
||||
<iyy unit="SLUG*FT2"> 0.005 </iyy>
|
||||
<izz unit="SLUG*FT2"> 0.010 </izz>
|
||||
<ixy unit="SLUG*FT2"> 0. </ixy>
|
||||
<ixz unit="SLUG*FT2"> 0. </ixz>
|
||||
<iyz unit="SLUG*FT2"> 0. </iyz>
|
||||
<emptywt unit="LBS"> 0.84 </emptywt>
|
||||
<location name="CG" unit="M">
|
||||
<x> 0 </x>
|
||||
<y> 0 </y>
|
||||
<z> 0 </z>
|
||||
</location>
|
||||
</mass_balance>
|
||||
|
||||
<ground_reactions>
|
||||
<contact type="STRUCTURE" name="CONTACT_FRONT">
|
||||
<location unit="M">
|
||||
<x>-0.15 </x>
|
||||
<y> 0 </y>
|
||||
<z>-0.1 </z>
|
||||
</location>
|
||||
<static_friction> 0.8 </static_friction>
|
||||
<dynamic_friction> 0.5 </dynamic_friction>
|
||||
<spring_coeff unit="N/M"> 500 </spring_coeff>
|
||||
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
|
||||
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
|
||||
<max_steer unit="DEG"> 0.0 </max_steer>
|
||||
<brake_group> NONE </brake_group>
|
||||
<retractable>0</retractable>
|
||||
</contact>
|
||||
|
||||
<contact type="STRUCTURE" name="CONTACT_BACK">
|
||||
<location unit="M">
|
||||
<x> 0.15</x>
|
||||
<y> 0 </y>
|
||||
<z>-0.1 </z>
|
||||
</location>
|
||||
<static_friction> 0.8 </static_friction>
|
||||
<dynamic_friction> 0.5 </dynamic_friction>
|
||||
<spring_coeff unit="N/M"> 500 </spring_coeff>
|
||||
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
|
||||
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
|
||||
<max_steer unit="DEG"> 0.0 </max_steer>
|
||||
<brake_group> NONE </brake_group>
|
||||
<retractable>0</retractable>
|
||||
</contact>
|
||||
|
||||
<contact type="STRUCTURE" name="CONTACT_RIGHT">
|
||||
<location unit="M">
|
||||
<x> 0. </x>
|
||||
<y> 0.15</y>
|
||||
<z>-0.1 </z>
|
||||
</location>
|
||||
<static_friction> 0.8 </static_friction>
|
||||
<dynamic_friction> 0.5 </dynamic_friction>
|
||||
<spring_coeff unit="N/M"> 500 </spring_coeff>
|
||||
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
|
||||
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
|
||||
<max_steer unit="DEG"> 0.0 </max_steer>
|
||||
<brake_group> NONE </brake_group>
|
||||
<retractable>0</retractable>
|
||||
</contact>
|
||||
|
||||
<contact type="STRUCTURE" name="CONTACT_LEFT">
|
||||
<location unit="M">
|
||||
<x> 0. </x>
|
||||
<y>-0.15</y>
|
||||
<z>-0.1 </z>
|
||||
</location>
|
||||
<static_friction> 0.8 </static_friction>
|
||||
<dynamic_friction> 0.5 </dynamic_friction>
|
||||
<spring_coeff unit="N/M"> 500 </spring_coeff>
|
||||
<damping_coeff unit="N/M/SEC"> 100 </damping_coeff>
|
||||
<damping_coeff_rebound type="SQUARE" unit="N/M2/SEC2"> 1000 </damping_coeff_rebound>
|
||||
<max_steer unit="DEG"> 0.0 </max_steer>
|
||||
<brake_group> NONE </brake_group>
|
||||
<retractable>0</retractable>
|
||||
</contact>
|
||||
</ground_reactions>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<external_reactions>
|
||||
|
||||
<property>fcs/front_motor</property>
|
||||
<property>fcs/back_motor</property>
|
||||
<property>fcs/right_motor</property>
|
||||
<property>fcs/left_motor</property>
|
||||
|
||||
<!-- First the lift forces produced by each propeller -->
|
||||
|
||||
<force name="front_motor" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/front_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>-6.89</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<z>-1</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="back_motor" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/back_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>6.89</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<z>-1</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="right_motor" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/right_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>0</x>
|
||||
<y>6.89</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<z>-1</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="left_motor" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/left_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>0</x>
|
||||
<y>-6.89</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<z>-1</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<!-- Then the Moment Couples -->
|
||||
|
||||
<!-- Front Engine -->
|
||||
|
||||
<force name="front_couple1" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/front_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>-6.89</x>
|
||||
<!-- Necessary arm in IN to produce a moment ten times
|
||||
"weaker" then the force when both are measured in the SI.
|
||||
front and back motors turning clockwise, left and right motors
|
||||
turning anti-clockwise when view from up-->
|
||||
<y>1.9685</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>-1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="front_couple2" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/front_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>-6.89</x>
|
||||
<y>-1.9685</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<!-- Back Engine -->
|
||||
|
||||
<force name="back_couple1" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/back_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>6.89</x>
|
||||
<y>1.9685</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>-1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="back_couple2" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/back_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>6.89</x>
|
||||
<y>-1.9685</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>1</x>
|
||||
<y>0</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<!-- Right Engine -->
|
||||
|
||||
<force name="right_couple1" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/right_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>-1.9685</x>
|
||||
<y>6.89</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="right_couple2" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/right_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>1.9685</x>
|
||||
<y>6.89</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<!-- Left Engine -->
|
||||
|
||||
<force name="left_couple1" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/left_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>-1.9685</x>
|
||||
<y>-6.89</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>-1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
<force name="left_couple2" frame="BODY" unit="LBS">
|
||||
<function>
|
||||
<product>
|
||||
<property>fcs/left_motor</property>
|
||||
<value> 0.84 </value>
|
||||
</product>
|
||||
</function>
|
||||
<location unit="IN">
|
||||
<x>1.9685</x>
|
||||
<y>-6.89</y>
|
||||
<z>0</z>
|
||||
</location>
|
||||
<direction>
|
||||
<x>0</x>
|
||||
<y>1</y>
|
||||
<z>0</z>
|
||||
</direction>
|
||||
</force>
|
||||
|
||||
</external_reactions>
|
||||
|
||||
<propulsion/>
|
||||
|
||||
<flight_control name="FGFCS"/>
|
||||
|
||||
<aerodynamics>
|
||||
<axis name="DRAG">
|
||||
<function name="aero/coefficient/CD">
|
||||
<description>Drag</description>
|
||||
<product>
|
||||
<property>aero/qbar-psf</property>
|
||||
<value>47.9</value> <!-- Conversion to pascals -->
|
||||
<value>0.0151</value> <!-- CD x Area (m^2) -->
|
||||
<value>0.224808943</value> <!-- N to LBS -->
|
||||
</product>
|
||||
</function>
|
||||
</axis>
|
||||
</aerodynamics>
|
||||
|
||||
</fdm_config>
|
||||
@@ -33,6 +33,9 @@
|
||||
#include "nps_radio_control.h"
|
||||
#include "nps_radio_control_joystick.h"
|
||||
|
||||
// for NPS_JS_MODE_AXIS
|
||||
#include "generated/airframe.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -43,13 +46,22 @@
|
||||
#define JS_PITCH 1
|
||||
#define JS_YAW 2
|
||||
#define JS_THROTTLE 3
|
||||
|
||||
#ifndef NPS_JS_MODE_AXIS
|
||||
#define JS_NB_AXIS 4
|
||||
#else
|
||||
#define JS_NB_AXIS 5
|
||||
#endif
|
||||
|
||||
// buttons to switch modes
|
||||
#define JS_MODE_MANUAL 4
|
||||
#define JS_MODE_AUTO1 5
|
||||
#define JS_MODE_AUTO2 6
|
||||
#define JS_BUTTON_MODE_MANUAL 4
|
||||
#define JS_BUTTON_MODE_AUTO1 5
|
||||
#define JS_BUTTON_MODE_AUTO2 6
|
||||
#ifndef NPS_JS_MODE_AXIS
|
||||
#define JS_NB_BUTTONS 3
|
||||
#else
|
||||
#define JS_NB_BUTTONS 0
|
||||
#endif
|
||||
|
||||
NpsJoystick nps_joystick;
|
||||
SDL_Joystick *sdl_joystick;
|
||||
@@ -126,6 +138,7 @@ int nps_radio_control_joystick_init(const char* device) {
|
||||
else if (SDL_JoystickNumButtons(sdl_joystick) < JS_NB_BUTTONS)
|
||||
{
|
||||
printf("Selected joystick does not support enough buttons!\n");
|
||||
printf("Buttons supported: %d needed: %d\n", SDL_JoystickNumButtons(sdl_joystick), JS_NB_BUTTONS);
|
||||
SDL_JoystickClose(sdl_joystick);
|
||||
exit(-1);
|
||||
}
|
||||
@@ -146,43 +159,48 @@ void nps_radio_control_joystick_update(void) {
|
||||
nps_joystick.roll = (float)(SDL_JoystickGetAxis(sdl_joystick,JS_ROLL))/32767.;
|
||||
nps_joystick.pitch = (float)(SDL_JoystickGetAxis(sdl_joystick,JS_PITCH))/32767.;
|
||||
nps_joystick.yaw = (float)(SDL_JoystickGetAxis(sdl_joystick,JS_YAW))/32767.;
|
||||
// if an axis is asigned to the mode, use it instead of the buttons
|
||||
#ifdef NPS_JS_MODE_AXIS
|
||||
nps_joystick.mode = (float)(SDL_JoystickGetAxis(sdl_joystick,NPS_JS_MODE_AXIS))/32767.;
|
||||
#endif
|
||||
|
||||
while(SDL_PollEvent(&sdl_event))
|
||||
{
|
||||
switch(sdl_event.type)
|
||||
{
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
{
|
||||
switch(sdl_event.jbutton.button)
|
||||
{
|
||||
case JS_MODE_MANUAL:
|
||||
nps_joystick.mode = MODE_SWITCH_MANUAL;
|
||||
break;
|
||||
{
|
||||
switch(sdl_event.jbutton.button)
|
||||
{
|
||||
#ifndef NPS_JS_MODE_AXIS
|
||||
case JS_BUTTON_MODE_MANUAL:
|
||||
nps_joystick.mode = MODE_SWITCH_MANUAL;
|
||||
break;
|
||||
|
||||
case JS_MODE_AUTO1:
|
||||
nps_joystick.mode = MODE_SWITCH_AUTO1;
|
||||
break;
|
||||
case JS_BUTTON_MODE_AUTO1:
|
||||
nps_joystick.mode = MODE_SWITCH_AUTO1;
|
||||
break;
|
||||
|
||||
case JS_MODE_AUTO2:
|
||||
nps_joystick.mode = MODE_SWITCH_AUTO2;
|
||||
break;
|
||||
|
||||
default:
|
||||
//ignore
|
||||
break;
|
||||
case JS_BUTTON_MODE_AUTO2:
|
||||
nps_joystick.mode = MODE_SWITCH_AUTO2;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
//ignore
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
printf("Quitting...\n");
|
||||
exit(-1);
|
||||
break;
|
||||
printf("Quitting...\n");
|
||||
exit(-1);
|
||||
break;
|
||||
|
||||
default:
|
||||
//do nothing
|
||||
printf("unknown SDL event!!!\n");
|
||||
break;
|
||||
//do nothing
|
||||
printf("unknown SDL event!!!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user