Q

Dependencies:   SRF05 ros_lib_kinetic TinyGPSPlus

Revision:
11:955c2ed70de2
Parent:
10:7d954fba5e7a
Child:
12:1a3272d67500
diff -r 7d954fba5e7a -r 955c2ed70de2 PROJ515.cpp
--- a/PROJ515.cpp	Wed May 08 13:55:17 2019 +0000
+++ b/PROJ515.cpp	Wed May 08 14:50:32 2019 +0000
@@ -15,6 +15,19 @@
 char gps_c = 0;                                    // GPS serial character
 int  sats_n = 0;                                    // GPS Satelite count
 
+void AudioStatusCB(const std_msgs::String &status) {
+    audio_state = status.data;
+}
+
+void VelocityCB(const nav_msgs::Odometry &odom) {
+    vel = odom.twist.twist.linear.x;
+    ang = odom.twist.twist.angular.z;
+}
+
+// Instance for ROS subscribers
+ros::Subscriber<std_msgs::String> AudioStatus("audio_status", &AudioStatusCB);
+ros::Subscriber<nav_msgs::Odometry> Velocity("wheel_odom/exact_odom", &VelocityCB);
+
 int main()
 {
     nh.getHardware()->setBaud(ROS_Baud);    // Set Baud Rate for ROS Serial
@@ -300,14 +313,7 @@
     wait_ms(wPeriod);
 }
 
-void AudioStatusCB(const std_msgs::String &status) {
-    audio_state = status.data;
-}
 
-oid VelocityCB(const nav_msgs::Odometry &odom) {
-    vel = odom.twist.twist.linear.x;
-    ang = odom.twist.twist.angular.z;
-}
 
 float Map(float x, float in_min, float in_max, float out_min, float out_max){
     return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;