Browse Source

优化snowboy_wakeup的节点名,配置文件

corvin 5 years ago
parent
commit
b4b76b3a49

+ 3 - 22
catkin_ws/src/snowboy_wakeup/CMakeLists.txt

@@ -62,31 +62,12 @@ target_link_libraries(hotword_detector
     -lwiringPi
 )
 
-add_executable(hotword_detector_node
+add_executable(wakeup_detector
     src/hotword_detector_node.cpp
 )
-target_link_libraries(hotword_detector_node
+target_link_libraries(wakeup_detector
     hotword_detector
     ${catkin_LIBRARIES}
 )
-add_dependencies(hotword_detector_node ${PROJECT_NAME}_gencfg)
-
-install(
-  TARGETS
-  hotword_detector
-  hotword_detector_node
-  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
-  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
-  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
-)
-
-install(
-  DIRECTORY launch/
-  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
-)
-
-install(
-  DIRECTORY resources/
-  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/resources
-)
+add_dependencies(wakeup_detector ${PROJECT_NAME}_gencfg)
 

+ 2 - 4
catkin_ws/src/snowboy_wakeup/launch/snowboy_wakeup.launch

@@ -17,20 +17,18 @@ History:
     <arg name="WAKEUP_Topic" default="wakeup_topic" />
 
     <group ns="$(arg namespace)">
-        <node name="audio_capture" pkg="audio_capture" type="audio_capture" output="screen" required="true">
+        <node pkg="audio_capture" type="audio_capture" name="audio_capture" output="screen" required="true">
             <param name="format" value="wave" />
             <param name="channels" value="1" />
             <param name="depth" value="16" />
             <param name="sample_rate" value="16000" />
-
             <remap from="audio" to="$(arg AUDIO_Topic)" />
         </node>
 
-        <node pkg="snowboy_wakeup" type="hotword_detector_node" name="snowboy_wakeup" respawn="true">
+        <node pkg="snowboy_wakeup" type="wakeup_detector" name="snowboy_wakeup" output="screen" respawn="true">
             <param name="resource_filename" value="$(find snowboy_wakeup)/resources/common.res" />
             <param name="model_filename" value="$(find snowboy_wakeup)/resources/snowboy.umdl" />
             <param name="beep_filename" value="$(find snowboy_wakeup)/resources/ding.wav" />
-
             <param name="sensitivity_str" value="0.7" />
             <param name="audio_gain" value="1.0" />
             <param name="wakeup_topic" value="$(arg WAKEUP_Topic)" />

+ 2 - 17
catkin_ws/src/snowboy_wakeup/src/hotword_detector_node.cpp

@@ -15,9 +15,7 @@ namespace snowboy_wakeup
     std::string pre_param = "play -q --multi-threaded ";
     std::string all_param;
 
-    //!
     //! \brief The HotwordDetectorNode class Wraps the C++ 11 Snowboy detector in a ROS node
-    //!
     class HotwordDetectorNode
     {
         public:
@@ -26,7 +24,6 @@ namespace snowboy_wakeup
 
             bool initialize()
             {
-
                 std::string resource_filename;
                 if (!nh_p_.getParam("resource_filename", resource_filename))
                 {
@@ -73,40 +70,28 @@ namespace snowboy_wakeup
         private:
             ros::NodeHandle nh_;
 
-            //!
             //! \brief nh_p_ Local nodehandle for parameters
-            //!
             ros::NodeHandle nh_p_;
 
             ros::Subscriber audio_sub_;
             ros::Publisher hotword_pub_;
 
-            //!
             //! \brief dynamic_reconfigure_server_ In order to online tune the sensitivity and audio gain
-            //!
             dynamic_reconfigure::Server<SnowboyReconfigureConfig> dynamic_reconfigure_server_;
 
-            //!
             //! \brief detector_ C++ 11 Wrapped Snowboy detect
-            //!
             HotwordDetector detector_;
 
-
-            //!
             //! \brief reconfigureCallback Reconfigure update for sensitiviy and audio level
             //! \param cfg The updated config
-            //!
             void reconfigureCallback(SnowboyReconfigureConfig cfg, uint32_t)
             {
                 detector_.configure(cfg.sensitivity, cfg.audio_gain);
-                ROS_INFO("SnowboyROS (Re)Configured");
+                ROS_INFO("SnowboyROS ReConfigured callback init");
             }
 
-
-            //!
             //! \brief audioCallback Audio stream callback
             //! \param msg The audo data
-            //!
             void audioCallback(const audio_common_msgs::AudioDataConstPtr& msg)
             {
                 if (msg->data.size() != 0)
@@ -127,7 +112,7 @@ namespace snowboy_wakeup
                     if (result == 1 || btn_click == 1)
                     {
                         btn_click = 0;
-                        ROS_DEBUG("wakeUp detected!");
+                        ROS_INFO("wakeUp detected!");
                         hotword_msg.data = 1;
                         hotword_pub_.publish(hotword_msg);
                         system(all_param.data());