Browse Source

将infrared_maze软件包移动到robot_demo中

corvin rasp melodic 2 years ago
parent
commit
8791d98ed3

+ 0 - 209
src/infrared_maze/CMakeLists.txt

@@ -1,209 +0,0 @@
-cmake_minimum_required(VERSION 2.8.3)
-project(infrared_maze)
-
-## Compile as C++11, supported in ROS Kinetic and newer
-# add_compile_options(-std=c++11)
-
-## Find catkin macros and libraries
-## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
-## is used, also find other catkin packages
-find_package(catkin REQUIRED COMPONENTS
-  ros_arduino_msgs
-  roscpp
-  geometry_msgs
-  nav_msgs
-  tf
-  std_msgs
-)
-
-## System dependencies are found with CMake's conventions
-# find_package(Boost REQUIRED COMPONENTS system)
-
-
-## Uncomment this if the package has a setup.py. This macro ensures
-## modules and global scripts declared therein get installed
-## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
-# catkin_python_setup()
-
-################################################
-## Declare ROS messages, services and actions ##
-################################################
-
-## To declare and build messages, services or actions from within this
-## package, follow these steps:
-## * Let MSG_DEP_SET be the set of packages whose message types you use in
-##   your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
-## * In the file package.xml:
-##   * add a build_depend tag for "message_generation"
-##   * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
-##   * If MSG_DEP_SET isn't empty the following dependency has been pulled in
-##     but can be declared for certainty nonetheless:
-##     * add a exec_depend tag for "message_runtime"
-## * In this file (CMakeLists.txt):
-##   * add "message_generation" and every package in MSG_DEP_SET to
-##     find_package(catkin REQUIRED COMPONENTS ...)
-##   * add "message_runtime" and every package in MSG_DEP_SET to
-##     catkin_package(CATKIN_DEPENDS ...)
-##   * uncomment the add_*_files sections below as needed
-##     and list every .msg/.srv/.action file to be processed
-##   * uncomment the generate_messages entry below
-##   * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
-
-## Generate messages in the 'msg' folder
-# add_message_files(
-#   FILES
-#   Message1.msg
-#   Message2.msg
-# )
-
-## Generate services in the 'srv' folder
-# add_service_files(
-#   FILES
-#   Service1.srv
-#   Service2.srv
-# )
-
-## Generate actions in the 'action' folder
-# add_action_files(
-#   FILES
-#   Action1.action
-#   Action2.action
-# )
-
-## Generate added messages and services with any dependencies listed here
-# generate_messages(
-#   DEPENDENCIES
-#   ros_arduino_msgs
-# )
-
-################################################
-## Declare ROS dynamic reconfigure parameters ##
-################################################
-
-## To declare and build dynamic reconfigure parameters within this
-## package, follow these steps:
-## * In the file package.xml:
-##   * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
-## * In this file (CMakeLists.txt):
-##   * add "dynamic_reconfigure" to
-##     find_package(catkin REQUIRED COMPONENTS ...)
-##   * uncomment the "generate_dynamic_reconfigure_options" section below
-##     and list every .cfg file to be processed
-
-## Generate dynamic reconfigure parameters in the 'cfg' folder
-# generate_dynamic_reconfigure_options(
-#   cfg/DynReconf1.cfg
-#   cfg/DynReconf2.cfg
-# )
-
-###################################
-## catkin specific configuration ##
-###################################
-## The catkin_package macro generates cmake config files for your package
-## Declare things to be passed to dependent projects
-## INCLUDE_DIRS: uncomment this if your package contains header files
-## LIBRARIES: libraries you create in this project that dependent projects also need
-## CATKIN_DEPENDS: catkin_packages dependent projects also need
-## DEPENDS: system dependencies of this project that dependent projects also need
-catkin_package(
-#  INCLUDE_DIRS include
-#  LIBRARIES infrared_maze
-#  CATKIN_DEPENDS ros_arduino_msgs roscpp
-#  DEPENDS system_lib
-)
-
-###########
-## Build ##
-###########
-
-## Specify additional locations of header files
-## Your package locations should be listed before other locations
-include_directories(
- include
- ${catkin_INCLUDE_DIRS}
-)
-
-## Declare a C++ library
-# add_library(${PROJECT_NAME}
-#   src/${PROJECT_NAME}/infrared_maze.cpp
-# )
-
-## Add cmake target dependencies of the library
-## as an example, code may need to be generated before libraries
-## either from message generation or dynamic reconfigure
-# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
-
-## Declare a C++ executable
-## With catkin_make all packages are built within a single CMake context
-## The recommended prefix ensures that target names across packages don't collide
-add_executable(${PROJECT_NAME}_node src/infrared_maze.cpp)
-
-## Rename C++ executable without prefix
-## The above recommended prefix causes long target names, the following renames the
-## target back to the shorter version for ease of user use
-## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
-# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
-
-## Add cmake target dependencies of the executable
-## same as for the library above
-add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
-
-## Specify libraries to link a library or executable target against
-target_link_libraries(${PROJECT_NAME}_node
-   ${catkin_LIBRARIES}
- )
-
-#############
-## Install ##
-#############
-
-# all install targets should use catkin DESTINATION variables
-# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
-
-## Mark executable scripts (Python etc.) for installation
-## in contrast to setup.py, you can choose the destination
-# install(PROGRAMS
-#   scripts/my_python_script
-#   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
-# )
-
-## Mark executables for installation
-## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
-# install(TARGETS ${PROJECT_NAME}_node
-#   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
-# )
-
-## Mark libraries for installation
-## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
-# install(TARGETS ${PROJECT_NAME}
-#   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
-#   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
-#   RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
-# )
-
-## Mark cpp header files for installation
-# install(DIRECTORY include/${PROJECT_NAME}/
-#   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
-#   FILES_MATCHING PATTERN "*.h"
-#   PATTERN ".svn" EXCLUDE
-# )
-
-## Mark other files for installation (e.g. launch and bag files, etc.)
-# install(FILES
-#   # myfile1
-#   # myfile2
-#   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
-# )
-
-#############
-## Testing ##
-#############
-
-## Add gtest based cpp test target and link libraries
-# catkin_add_gtest(${PROJECT_NAME}-test test/test_infrared_maze.cpp)
-# if(TARGET ${PROJECT_NAME}-test)
-#   target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
-# endif()
-
-## Add folders to be run by python nosetests
-# catkin_add_nosetests(test)

+ 0 - 19
src/infrared_maze/README.md

@@ -1,19 +0,0 @@
-# blackTornadoRobot红外走迷宫功能
-走迷宫功能包,可通过红外传感器数据使小车在迷宫中行进。
-
-在param.yaml文件中可调整一些走迷宫时用到的参数。
-
-小车走迷宫的主要逻辑为:将迷宫看作由50cmX50cm方格添加障碍墙之后组成的环境,小车每次行进皆为50cm即行走一格,转弯角度为90度。小车每行进一格后会获取当前红外传感器数据,优先左转,其次直行,最后右转。
-
-### 建图运行方法
-首先启动小车
-
-```sh
-$ roslaunch robot_bringup robot_bringup.launch
-```
-
-然后运行走迷宫程序
-```sh
-$ roslaunch infrared_maze infrared_maze.launch
-```
-

+ 0 - 15
src/infrared_maze/launch/infrared_maze.launch

@@ -1,15 +0,0 @@
-<!--
-  Author: jally, corvin
-  Description:
-    maze with infrared
-  History:
-    20200325: intial this file.
--->
-<launch>
-  <arg name="cfg_file" default="$(find infrared_maze)/cfg/param.yaml" />
-
-  <!-- startup infrared_obstacle_avoidance_node -->
-  <node pkg="infrared_maze" type="infrared_maze_node" name="infrared_maze_node" output="screen">
-    <rosparam file="$(arg cfg_file)" command="load" />
-  </node>
-</launch>

+ 0 - 67
src/infrared_maze/package.xml

@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-<package format="2">
-  <name>infrared_maze</name>
-  <version>0.0.0</version>
-  <description>The infrared_maze package</description>
-
-  <!-- One maintainer tag required, multiple allowed, one person per tag -->
-  <!-- Example:  -->
-  <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
-  <maintainer email="jally_zhang@corvin.cn">jally</maintainer>
-
-
-  <!-- One license tag required, multiple allowed, one license per tag -->
-  <!-- Commonly used license strings: -->
-  <!--   BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
-  <license>TODO</license>
-
-
-  <!-- Url tags are optional, but multiple are allowed, one per tag -->
-  <!-- Optional attribute type can be: website, bugtracker, or repository -->
-  <!-- Example: -->
-  <!-- <url type="website">http://wiki.ros.org/infrared_maze</url> -->
-
-
-  <!-- Author tags are optional, multiple are allowed, one per tag -->
-  <!-- Authors do not have to be maintainers, but could be -->
-  <!-- Example: -->
-  <!-- <author email="jane.doe@example.com">Jane Doe</author> -->
-
-
-  <!-- The *depend tags are used to specify dependencies -->
-  <!-- Dependencies can be catkin packages or system dependencies -->
-  <!-- Examples: -->
-  <!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
-  <!--   <depend>roscpp</depend> -->
-  <!--   Note that this is equivalent to the following: -->
-  <!--   <build_depend>roscpp</build_depend> -->
-  <!--   <exec_depend>roscpp</exec_depend> -->
-  <!-- Use build_depend for packages you need at compile time: -->
-  <!--   <build_depend>message_generation</build_depend> -->
-  <!-- Use build_export_depend for packages you need in order to build against this package: -->
-  <!--   <build_export_depend>message_generation</build_export_depend> -->
-  <!-- Use buildtool_depend for build tool packages: -->
-  <!--   <buildtool_depend>catkin</buildtool_depend> -->
-  <!-- Use exec_depend for packages you need at runtime: -->
-  <!--   <exec_depend>message_runtime</exec_depend> -->
-  <!-- Use test_depend for packages you need only for testing: -->
-  <!--   <test_depend>gtest</test_depend> -->
-  <!-- Use doc_depend for packages you need only for building documentation: -->
-  <!--   <doc_depend>doxygen</doc_depend> -->
-  <buildtool_depend>catkin</buildtool_depend>
-  <build_depend>ros_arduino_msgs</build_depend>
-  <build_depend>roscpp</build_depend>
-  <build_depend>tf</build_depend>
-  <build_export_depend>ros_arduino_msgs</build_export_depend>
-  <build_export_depend>roscpp</build_export_depend>
-  <exec_depend>ros_arduino_msgs</exec_depend>
-  <exec_depend>roscpp</exec_depend>
-  <exec_depend>tf</exec_depend>
-
-
-  <!-- The export tag contains other, unspecified, tags -->
-  <export>
-    <!-- Other tools can request additional information be placed here -->
-
-  </export>
-</package>

+ 6 - 0
src/robot_demo/CMakeLists.txt

@@ -13,6 +13,7 @@ find_package(catkin REQUIRED COMPONENTS
   tf
   roscpp
   std_msgs
+  nav_msgs
   sensor_msgs
   geometry_msgs
   cv_bridge
@@ -149,6 +150,7 @@ add_executable(${PROJECT_NAME}_imu_node src/imu_demo_node.cpp)
 add_executable(${PROJECT_NAME}_infrared_node src/infrared_demo_node.cpp)
 add_executable(${PROJECT_NAME}_drive_circle_node src/drive_circle_node.cpp)
 add_executable(${PROJECT_NAME}_drive_square_node src/drive_square_node.cpp)
+add_executable(${PROJECT_NAME}_infrared_maze_node src/infrared_maze_node.cpp)
 
 
 ## Rename C++ executable without prefix
@@ -161,6 +163,7 @@ add_executable(${PROJECT_NAME}_drive_square_node src/drive_square_node.cpp)
 ## same as for the library above
 # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
 add_dependencies(${PROJECT_NAME}_infrared_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
+add_dependencies(${PROJECT_NAME}_infrared_maze_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
 
 ## Specify libraries to link a library or executable target against
 # target_link_libraries(${PROJECT_NAME}_node
@@ -187,6 +190,9 @@ target_link_libraries(${PROJECT_NAME}_drive_square_node
    ${catkin_LIBRARIES}
 )
 
+target_link_libraries(${PROJECT_NAME}_infrared_maze_node
+   ${catkin_LIBRARIES}
+)
 #############
 ## Install ##
 #############

+ 0 - 0
src/infrared_maze/cfg/param.yaml → src/robot_demo/cfg/infrared_maze_param.yaml


+ 19 - 0
src/robot_demo/launch/infrared_maze.launch

@@ -0,0 +1,19 @@
+<!--
+  Author: jally, corvin
+  Description:
+    maze with infrared sensor.
+  History:
+    20200325: intial this file.
+-->
+<launch>
+  <arg name="cfg_file" default="$(find robot_demo)/cfg/infrared_maze_param.yaml" />
+
+  <!-- launch robot_bringup.launch -->
+  <include file="$(find robot_bringup)/launch/robot_bringup.launch" />
+
+  <!-- startup infrared_obstacle_avoidance_node -->
+  <node pkg="robot_demo" type="robot_demo_infrared_maze_node" name="infrared_maze_node" output="screen">
+    <rosparam file="$(arg cfg_file)" command="load" />
+  </node>
+</launch>
+

+ 1 - 6
src/robot_demo/package.xml

@@ -5,10 +5,7 @@
   <description>The robot_demo package</description>
 
   <!-- One maintainer tag required, multiple allowed, one person per tag -->
-  <!-- Example:  -->
-  <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
-  <maintainer email="adam_zhuo@corvin.cn">adam_zhuo</maintainer>
-
+  <maintainer email="corvin_zhang@corvin.cn">corvin_zhang</maintainer>
 
   <!-- One license tag required, multiple allowed, one license per tag -->
   <!-- Commonly used license strings: -->
@@ -27,7 +24,6 @@
   <!-- Example: -->
   <!-- <author email="jane.doe@example.com">Jane Doe</author> -->
 
-
   <!-- The *depend tags are used to specify dependencies -->
   <!-- Dependencies can be catkin packages or system dependencies -->
   <!-- Examples: -->
@@ -75,6 +71,5 @@
   <!-- The export tag contains other, unspecified, tags -->
   <export>
     <!-- Other tools can request additional information be placed here -->
-
   </export>
 </package>

+ 8 - 10
src/infrared_maze/src/infrared_maze.cpp → src/robot_demo/src/infrared_maze_node.cpp

@@ -13,7 +13,7 @@
 #include <nav_msgs/Odometry.h>
 #include <geometry_msgs/Twist.h>
 #include <tf/transform_listener.h>
-#include "rasp_imu_hat_6dof/GetYawData.h"
+#include "serial_imu_hat_6dof/getYawData.h"
 #include "ros_arduino_msgs/InfraredSensors.h"
 #include "ros_arduino_msgs/GetInfraredDistance.h"
 
@@ -29,7 +29,7 @@
 //global variable
 ros::Publisher twist_pub;
 ros::ServiceClient yawSrvClient;
-rasp_imu_hat_6dof::GetYawData yawSrv;
+serial_imu_hat_6dof::getYawData yawSrv;
 
 //红外测距相关的服务
 ros::ServiceClient distSrvClient;
@@ -152,7 +152,7 @@ void goForward(const float check_dist)
 {
     tf::TransformListener tf_Listener;
     tf::StampedTransform tf_Transform;
-    float dist = 0.0; //每次前进移动的距离
+    float dist = 0.0;  //每次前进移动的距离
     float front_dist = 0.0;
 
     try
@@ -241,7 +241,6 @@ int controlTurn(int flag)
         ROS_ERROR("tf_Listener.waitForTransform timeout error !");
         ROS_ERROR("%s", ex.what());
         ros::shutdown();
-
         return -2;
     }
 
@@ -271,7 +270,7 @@ int controlTurn(int flag)
         last_angle = rotation;
         ROS_INFO("Turn angle:%f", turn_angle);
     }
-    publishTwistCmd(0, 0); //原地转弯完成后,需要立刻停止小车的旋转
+    publishTwistCmd(0, 0);  //原地转弯完成后,需要立刻停止小车的旋转
     ROS_INFO("Turning finish !!!");
     ros::Duration(0.1).sleep(); //100 ms
 
@@ -288,7 +287,7 @@ int controlTurn(int flag)
 void checkInfraredDist(float infrared_f,float infrared_l,float infrared_r,
         float tolerance, float warn_distance)
 {
-    static int flag = 0; //记录是否转过弯的标志
+    static int flag = 0;  //记录是否转过弯的标志
 
     yawSrvClient.call(yawSrv); //通过服务调用来获取yaw值
     start_yaw_data = yawSrv.response.yaw; //记录当前yaw值,用于后面修正
@@ -319,7 +318,7 @@ void checkInfraredDist(float infrared_f,float infrared_l,float infrared_r,
         turnFlag = TURN_BACK;
     }
 
-    controlTurn(turnFlag); //开始执行动作
+    controlTurn(turnFlag);  //开始执行动作
 }
 
 /*****************************************************************************
@@ -336,7 +335,7 @@ void infrared_callback(const ros_arduino_msgs::InfraredSensors::ConstPtr& msg)
 
     //根据三个传感器反馈的测距值开始移动
     checkInfraredDist(front_dist, left_dist, right_dist, tolerance_dist, warn_dist);
-    yawUpdate(start_yaw_data); //移动完成后开始更新yaw值
+    yawUpdate(start_yaw_data);  //移动完成后开始更新yaw值
 }
 
 /************************************************************
@@ -368,10 +367,9 @@ int main(int argc, char **argv)
 
     ros::Subscriber sub_infrared = handle.subscribe(infrared_topic, 1, infrared_callback);
     twist_pub = handle.advertise<geometry_msgs::Twist>(cmd_topic, 1);
-    yawSrvClient = handle.serviceClient<rasp_imu_hat_6dof::GetYawData>(yaw_service);
+    yawSrvClient  = handle.serviceClient<serial_imu_hat_6dof::getYawData>(yaw_service);
     distSrvClient = handle.serviceClient<ros_arduino_msgs::GetInfraredDistance>(infrared_service);
 
     ros::spin();
     return 0;
 }
-

+ 1 - 1
src/ros_arduino_bridge/ros_arduino_python/src/ros_arduino_python/base_controller.py

@@ -35,7 +35,7 @@ class BaseController:
 
         pid_params = dict()
         pid_params['wheel_diameter']     = rospy.get_param("~wheel_diameter", 0.067)
-        pid_params['wheel_track']        = rospy.get_param("~wheel_track", 0.126)
+        pid_params['wheel_track']        = rospy.get_param("~wheel_track", 0.19)
         pid_params['encoder_resolution'] = rospy.get_param("~encoder_resolution", 11)
         pid_params['gear_reduction']     = rospy.get_param("~gear_reduction", 30)
         pid_params['AWheel_Kp'] = rospy.get_param("~AWheel_Kp", 18)