paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [4294] add deadband handling


From: Pascal Brisset
Subject: [paparazzi-commits] [4294] add deadband handling
Date: Tue, 20 Oct 2009 11:58:35 +0000

Revision: 4294
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=4294
Author:   hecto
Date:     2009-10-20 11:58:35 +0000 (Tue, 20 Oct 2009)
Log Message:
-----------
 add deadband handling

Modified Paths:
--------------
    paparazzi3/trunk/sw/ground_segment/joystick/input2ivy.ml
    paparazzi3/trunk/sw/ground_segment/joystick/xbox_booz_nav.xml

Modified: paparazzi3/trunk/sw/ground_segment/joystick/input2ivy.ml
===================================================================
--- paparazzi3/trunk/sw/ground_segment/joystick/input2ivy.ml    2009-10-20 
11:41:34 UTC (rev 4293)
+++ paparazzi3/trunk/sw/ground_segment/joystick/input2ivy.ml    2009-10-20 
11:58:35 UTC (rev 4294)
@@ -58,7 +58,7 @@
 
 (** Representation of an input value *)
 type input =
-    Axis of int
+    Axis of int * int (* (index, deadband) *)
   | Button of int
 
 (** Description of a message *)
@@ -158,7 +158,9 @@
       and index = ExtXml.int_attrib x "index" in
       let value =
        match Xml.tag x with
-         "axis" -> Axis index
+         "axis" -> 
+             let deadband = try ExtXml.int_attrib x "deadband" with _ -> 0 in
+             Axis (index, deadband)
        | "button" -> Button index
        | _ -> failwith "parse_input: unexepcted tag" in
       (name, value))
@@ -211,10 +213,13 @@
   try List.assoc x l with Not_found ->
     failwith (sprintf "my_assoc: %s not found" x)
 
+let apply_deadband = fun x min ->
+  if abs x < min then 0 else x
+
 (** Access to an input value, button or axis *)
 let eval_input = fun buttons axis input ->
   match input with
-    Axis i -> axis.(i)
+    Axis (i, deadband) -> apply_deadband axis.(i) deadband
   | Button i -> (buttons lsr i) land 0x1
 
 (** Scale a value in the given bounds *)
@@ -287,7 +292,7 @@
   done;
   fprintf stderr "\naxis: ";
   for i = 0 to Array.length axis - 1 do
-    fprintf stderr "%d:%d " i (eval_input buttons axis (Axis i))
+    fprintf stderr "%d:%d " i (eval_input buttons axis (Axis (i, 0)))
   done;
   fprintf stderr "\n%!"
   

Modified: paparazzi3/trunk/sw/ground_segment/joystick/xbox_booz_nav.xml
===================================================================
--- paparazzi3/trunk/sw/ground_segment/joystick/xbox_booz_nav.xml       
2009-10-20 11:41:34 UTC (rev 4293)
+++ paparazzi3/trunk/sw/ground_segment/joystick/xbox_booz_nav.xml       
2009-10-20 11:58:35 UTC (rev 4294)
@@ -1,8 +1,8 @@
 <joystick>
  <input>
-  <axis index="0" name="roll"/>
-  <axis index="1" name="pitch"/>
-  <axis index="3" name="yaw"/>
+  <axis index="0" name="roll" deadband="15"/>
+  <axis index="1" name="pitch" deadband="15"/>
+  <axis index="3" name="yaw" deadband="15"/>
   <axis index="4" name="tilt"/>
   <button index="3" name="X"/>
   <button index="0" name="down"/>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]