From 4146e23ca7d9b2a036ff11c5152f2445db301621 Mon Sep 17 00:00:00 2001
From: Angel <roangel@student.ethz.ch>
Date: Mon, 23 Oct 2017 14:10:47 +0200
Subject: [PATCH] added battery polling period to yaml file. Need to test

---
 pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py | 7 ++++++-
 pps_ws/src/d_fall_pps/param/ClientConfig.yaml  | 5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py b/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py
index 3cbcf150..69dd2b6e 100755
--- a/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py
+++ b/pps_ws/src/d_fall_pps/crazyradio/CrazyRadio.py
@@ -180,7 +180,7 @@ class PPSRadioClient:
     # def _init_logging(self):
 
     def _start_logging(self):
-        self.logconf = LogConfig("LoggingTest", 100) # second variable is freq in ms
+        self.logconf = LogConfig("LoggingTest", battery_polling_period) # second variable is period in ms
         self.logconf.add_variable("stabilizer.roll", "float");
         self.logconf.add_variable("stabilizer.pitch", "float");
         self.logconf.add_variable("stabilizer.yaw", "float");
@@ -305,6 +305,9 @@ if __name__ == '__main__':
     global node_name
     node_name = "CrazyRadio"
     rospy.init_node(node_name, anonymous=True)
+
+    global ros_namespace
+    ros_namespace = rospy.get_namespace()
     # Initialize the low-level drivers (don't list the debug drivers)
     cflib.crtp.init_drivers(enable_debug_driver=False)
 
@@ -315,6 +318,8 @@ if __name__ == '__main__':
     #use this following two lines to connect without data from CentralManager
     # radio_address = "radio://0/72/2M"
     # rospy.loginfo("manual address loaded")
+    global battery_polling_period
+    battery_polling_period = rospy.get_param(ros_namespace + "/CrazyRadio/battery_polling_period")
 
     global cfbattery_pub
     cfbattery_pub = rospy.Publisher(node_name + '/CFBattery', Float32, queue_size=10)
diff --git a/pps_ws/src/d_fall_pps/param/ClientConfig.yaml b/pps_ws/src/d_fall_pps/param/ClientConfig.yaml
index 0f22bead..07c6cbed 100755
--- a/pps_ws/src/d_fall_pps/param/ClientConfig.yaml
+++ b/pps_ws/src/d_fall_pps/param/ClientConfig.yaml
@@ -2,6 +2,7 @@ safeController: "SafeControllerService/RateController"
 customController: "CustomControllerService/CustomController"
 strictSafety: true
 angleMargin: 0.6
-battery_threshold_while_flying: 2.9
-battery_threshold_while_motors_off: 3.3
+battery_threshold_while_flying: 2.9      # in V
+battery_threshold_while_motors_off: 3.34 # in V
+battery_polling_period: 100         # in ms
 
-- 
GitLab