diff --git a/src/Prometheus/.gitignore b/src/Prometheus/.gitignore
new file mode 100644
index 00000000..56481e16
--- /dev/null
+++ b/src/Prometheus/.gitignore
@@ -0,0 +1,44 @@
+# compilation and distribution
+__pycache__
+_ext
+*.pyc
+nano.save
+.catkin_workspace
+
+build/
+devel/
+dist/
+.vscode/
+Modules/object_detection_landing/
+Modules/object_detection_persistence/
+Modules/object_detection_yolov5openvino/
+Modules/object_detection_yolov5tensorrt/
+Modules/object_detection_circlex/
+Modules/data/
+Modules/object_detection_oneshot/
+
+
+# pytorch/python/numpy formats
+# *.pth
+*.pkl
+*.npy
+
+# ipython/jupyter notebooks
+*.ipynb
+**/.ipynb_checkpoints/
+
+# Editor temporaries
+*.swn
+*.swo
+*.swp
+*~
+
+# Pycharm editor settings
+.idea
+
+# project dirs
+/datasets
+/models
+
+ORBvoc.txt
+
diff --git a/src/Prometheus/.gitmodules b/src/Prometheus/.gitmodules
new file mode 100644
index 00000000..36ec78b3
--- /dev/null
+++ b/src/Prometheus/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "Modules/swarm_control"]
+ path = Modules/swarm_control
+ url = https://gitee.com/amovlab/swarm_control.git
+[submodule "Modules/matlab_bridge"]
+ path = Modules/matlab_bridge
+ url = https://gitee.com/amovlab1/matlab_bridge.git
diff --git a/src/Prometheus/Experiment/CMakeLists.txt b/src/Prometheus/Experiment/CMakeLists.txt
new file mode 100644
index 00000000..bd32d374
--- /dev/null
+++ b/src/Prometheus/Experiment/CMakeLists.txt
@@ -0,0 +1,118 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(prometheus_experiment)
+
+## 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
+ message_generation
+ roscpp
+ geometry_msgs
+ nav_msgs
+ sensor_msgs
+ mavros
+ std_msgs
+ std_srvs
+ tf2_ros
+ tf2_eigen
+ mavros_msgs
+ prometheus_msgs
+)
+
+## System dependencies are found with CMake's conventions
+find_package(Boost REQUIRED COMPONENTS system)
+
+
+
+################################################
+## Declare ROS messages, services and actions ##
+################################################
+
+## Generate added messages and services with any dependencies listed here
+generate_messages(
+ DEPENDENCIES
+ geometry_msgs
+ nav_msgs
+ sensor_msgs
+ std_msgs
+)
+
+
+
+###########
+## Build ##
+###########
+
+## Specify additional locations of header files
+## Your package locations should be listed before other locations
+include_directories(
+ include
+ ${catkin_INCLUDE_DIRS}
+)
+
+
+###############################
+## 声明可执行cpp文件 ##
+###############################
+
+###### Main File ##########
+
+##px4_pos_controller.cpp
+#add_executable(px4_pos_controller src/px4_pos_controller.cpp)
+#add_dependencies(px4_pos_controller prometheus_control_gencpp)
+#target_link_libraries(px4_pos_controller ${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 and/or libraries for installation
+# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
+# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+# RUNTIME DESTINATION ${CATKIN_PACKAGE_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 cpp header files for installation
+install(DIRECTORY include/${PROJECT_NAME}/
+ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
+ FILES_MATCHING PATTERN "*.h"
+)
+
+## Mark other files for installation (e.g. launch and bag files, etc.)
+install(DIRECTORY launch/
+ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
+)
+
+#############
+## Testing ##
+#############
+
+## Add gtest based cpp test target and link libraries
+# catkin_add_gtest(${PROJECT_NAME}-test test/test_prometheus_control.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)
diff --git a/src/Prometheus/Experiment/config/px4_config.yaml b/src/Prometheus/Experiment/config/px4_config.yaml
new file mode 100644
index 00000000..d9fd0eee
--- /dev/null
+++ b/src/Prometheus/Experiment/config/px4_config.yaml
@@ -0,0 +1,260 @@
+# Common configuration for PX4 autopilot
+#
+# node:
+startup_px4_usb_quirk: true
+
+# --- system plugins ---
+
+# sys_status & sys_time connection options
+conn:
+ heartbeat_rate: 1.0 # send hertbeat rate in Hertz
+ timeout: 10.0 # hertbeat timeout in seconds
+ timesync_rate: 10.0 # TIMESYNC rate in Hertz (feature disabled if 0.0)
+ system_time_rate: 1.0 # send system time to FCU rate in Hertz (disabled if 0.0)
+
+# sys_status
+sys:
+ min_voltage: 10.0 # diagnostics min voltage
+ disable_diag: false # disable all sys_status diagnostics, except heartbeat
+
+# sys_time
+time:
+ time_ref_source: "fcu" # time_reference source
+ timesync_mode: MAVLINK
+ timesync_avg_alpha: 0.6 # timesync averaging factor
+
+# --- mavros plugins (alphabetical order) ---
+
+# 3dr_radio
+tdr_radio:
+ low_rssi: 40 # raw rssi lower level for diagnostics
+
+# actuator_control
+# None
+
+# command
+cmd:
+ use_comp_id_system_control: false # quirk for some old FCUs
+
+# dummy
+# None
+
+# ftp
+# None
+
+# global_position
+global_position:
+ frame_id: "map" # origin frame
+ child_frame_id: "base_link" # body-fixed frame
+ rot_covariance: 99999.0 # covariance for attitude?
+ gps_uere: 1.0 # User Equivalent Range Error (UERE) of GPS sensor (m)
+ use_relative_alt: true # use relative altitude for local coordinates
+ tf:
+ send: false # send TF?
+ frame_id: "map" # TF frame_id
+ global_frame_id: "earth" # TF earth frame_id
+ child_frame_id: "base_link" # TF child_frame_id
+
+# imu_pub
+imu:
+ frame_id: "base_link"
+ # need find actual values
+ linear_acceleration_stdev: 0.0003
+ angular_velocity_stdev: 0.0003490659 // 0.02 degrees
+ orientation_stdev: 1.0
+ magnetic_stdev: 0.0
+
+# local_position
+local_position:
+ frame_id: "world"
+ tf:
+ send: true
+ frame_id: "world"
+ child_frame_id: "base_link"
+ send_fcu: false
+
+# param
+# None, used for FCU params
+
+# rc_io
+# None
+
+# safety_area
+safety_area:
+ p1: {x: 1.0, y: 1.0, z: 1.0}
+ p2: {x: -1.0, y: -1.0, z: -1.0}
+
+# setpoint_accel
+setpoint_accel:
+ send_force: false
+
+# setpoint_attitude
+setpoint_attitude:
+ reverse_thrust: false # allow reversed thrust
+ use_quaternion: false # enable PoseStamped topic subscriber
+ tf:
+ listen: false # enable tf listener (disable topic subscribers)
+ frame_id: "map"
+ child_frame_id: "target_attitude"
+ rate_limit: 50.0
+
+setpoint_raw:
+ thrust_scaling: 1.0 # used in setpoint_raw attitude callback.
+ # Note: PX4 expects normalized thrust values between 0 and 1, which means that
+ # the scaling needs to be unitary and the inputs should be 0..1 as well.
+
+# setpoint_position
+setpoint_position:
+ tf:
+ listen: false # enable tf listener (disable topic subscribers)
+ frame_id: "map"
+ child_frame_id: "target_position"
+ rate_limit: 50.0
+ mav_frame: LOCAL_NED
+
+# setpoint_velocity
+setpoint_velocity:
+ mav_frame: LOCAL_NED
+
+# vfr_hud
+# None
+
+# waypoint
+mission:
+ pull_after_gcs: true # update mission if gcs updates
+
+# --- mavros extras plugins (same order) ---
+
+# adsb
+# None
+
+# debug_value
+# None
+
+# distance_sensor
+## Currently available orientations:
+# Check http://wiki.ros.org/mavros/Enumerations
+##
+distance_sensor:
+ hrlv_ez4_pub:
+ id: 0
+ frame_id: "hrlv_ez4_sonar"
+ orientation: PITCH_270 # RPY:{0.0, 270.0, 0.0} - downward-facing
+ field_of_view: 0.0 # XXX TODO
+ send_tf: true
+ sensor_position: {x: 0.0, y: 0.0, z: -0.1}
+ lidarlite_pub:
+ id: 1
+ frame_id: "lidarlite_laser"
+ orientation: PITCH_270
+ field_of_view: 0.0 # XXX TODO
+ send_tf: true
+ sensor_position: {x: 0.0, y: 0.0, z: -0.1}
+ sonar_1_sub:
+ subscriber: true
+ id: 2
+ orientation: PITCH_270
+ laser_1_sub:
+ subscriber: true
+ id: 3
+ orientation: PITCH_270
+
+# image_pub
+image:
+ frame_id: "px4flow"
+
+# fake_gps
+fake_gps:
+ # select data source
+ use_mocap: true # ~mocap/pose
+ mocap_transform: true # ~mocap/tf instead of pose
+ use_vision: false # ~vision (pose)
+ # origin (default: Zürich)
+ geo_origin:
+ lat: 47.3667 # latitude [degrees]
+ lon: 8.5500 # longitude [degrees]
+ alt: 408.0 # altitude (height over the WGS-84 ellipsoid) [meters]
+ eph: 2.0
+ epv: 2.0
+ satellites_visible: 5 # virtual number of visible satellites
+ fix_type: 3 # type of GPS fix (default: 3D)
+ tf:
+ listen: false
+ send: false # send TF?
+ frame_id: "map" # TF frame_id
+ child_frame_id: "fix" # TF child_frame_id
+ rate_limit: 10.0 # TF rate
+ gps_rate: 5.0 # GPS data publishing rate
+
+# landing_target
+landing_target:
+ listen_lt: false
+ mav_frame: "LOCAL_NED"
+ land_target_type: "VISION_FIDUCIAL"
+ image:
+ width: 640 # [pixels]
+ height: 480
+ camera:
+ fov_x: 2.0071286398 # default: 115 [degrees]
+ fov_y: 2.0071286398
+ tf:
+ send: true
+ listen: false
+ frame_id: "landing_target"
+ child_frame_id: "camera_center"
+ rate_limit: 10.0
+ target_size: {x: 0.3, y: 0.3}
+
+# mocap_pose_estimate
+mocap:
+ # select mocap source
+ use_tf: false # ~mocap/tf
+ use_pose: true # ~mocap/pose
+
+# odom
+odometry:
+ fcu:
+ odom_parent_id_des: "map" # desired parent frame rotation of the FCU's odometry
+ odom_child_id_des: "base_link" # desired child frame rotation of the FCU's odometry
+
+# px4flow
+px4flow:
+ frame_id: "px4flow"
+ ranger_fov: 0.118682 # 6.8 degrees at 5 meters, 31 degrees at 1 meter
+ ranger_min_range: 0.3 # meters
+ ranger_max_range: 5.0 # meters
+
+# vision_pose_estimate
+vision_pose:
+ tf:
+ listen: false # enable tf listener (disable topic subscribers)
+ frame_id: "map"
+ child_frame_id: "vision_estimate"
+ rate_limit: 10.0
+
+# vision_speed_estimate
+vision_speed:
+ listen_twist: true # enable listen to twist topic, else listen to vec3d topic
+ twist_cov: true # enable listen to twist with covariance topic
+
+# vibration
+vibration:
+ frame_id: "base_link"
+
+# wheel_odometry
+wheel_odometry:
+ count: 2 # number of wheels to compute odometry
+ use_rpm: false # use wheel's RPM instead of cumulative distance to compute odometry
+ wheel0: {x: 0.0, y: -0.15, radius: 0.05} # x-, y-offset (m,NED) and radius (m)
+ wheel1: {x: 0.0, y: 0.15, radius: 0.05} # x-, y-offset (m,NED) and radius (m)
+ send_raw: true # send wheel's RPM and cumulative distance (~/wheel_odometry/rpm, ~/wheel_odometry/distance)
+ send_twist: false # send geometry_msgs/TwistWithCovarianceStamped instead of nav_msgs/Odometry
+ frame_id: "map" # origin frame
+ child_frame_id: "base_link" # body-fixed frame
+ vel_error: 0.1 # wheel velocity measurement error 1-std (m/s)
+ tf:
+ send: false
+ frame_id: "map"
+ child_frame_id: "base_link"
+
+# vim:set ts=2 sw=2 et:
diff --git a/src/Prometheus/Experiment/config/px4_pluginlists.yaml b/src/Prometheus/Experiment/config/px4_pluginlists.yaml
new file mode 100644
index 00000000..145d2629
--- /dev/null
+++ b/src/Prometheus/Experiment/config/px4_pluginlists.yaml
@@ -0,0 +1,33 @@
+plugin_blacklist:
+- actuator_control
+- adsb
+- safety_area
+- 3dr_radio
+- cam_imu_sync
+- altitude
+- distance_sensor
+- fake_gps
+- gps_rtk
+- hil
+- home_position
+- landing_target
+- mocap_pose_estimate
+- mount_control
+- obstacle_distance
+- rc_io
+- vfr_hud
+- waypoint
+- wind_estimation
+- px4flow
+- global_position
+- companion_process_status
+- debug_value
+- wheel_odometry
+- vibration
+- odom
+- setpoint_attitude
+- setpoint_position
+- setpoint_accel
+- setpoint_velocity
+plugin_whitelist: []
+#- 'sys_*'
\ No newline at end of file
diff --git a/src/Prometheus/Experiment/config/uav_control_indoor.yaml b/src/Prometheus/Experiment/config/uav_control_indoor.yaml
new file mode 100644
index 00000000..4e751727
--- /dev/null
+++ b/src/Prometheus/Experiment/config/uav_control_indoor.yaml
@@ -0,0 +1,29 @@
+## parameter for uav_control
+
+control:
+ ## 控制器编号:0 for PX4_ORIGIN, 1 for PID, 2 for UDE, 3 for NE
+ pos_controller : 0
+ # 是否支持外部控制
+ enable_external_control : false
+ ## 起飞高度
+ Takeoff_height : 1.5
+ ## 降落速度
+ Land_speed : 0.2
+ ## 上锁高度
+ Disarm_height : 0.1
+ ## 定位源: 0 for MOCAP, 1 for T265, 2 for GAZEBO, 3 for FAKE_ODOM, 4 for GPS, 5 for RTK, 6 for UWB
+ location_source : 2
+ ## 最大安全速度
+ maximum_safe_vel_xy : 2.0
+ maximum_safe_vel_z : 1.5
+ ## 最大vision/px4速度误差
+ maximum_vel_error_for_vision : 1.0
+
+## 地理围栏
+geo_fence:
+ x_min: -100.0
+ x_max: 100.0
+ y_min: -100.0
+ y_max: 100.0
+ z_min: -0.5
+ z_max: 100.0
diff --git a/src/Prometheus/Experiment/launch/prometheus_experiment.launch b/src/Prometheus/Experiment/launch/prometheus_experiment.launch
new file mode 100755
index 00000000..831b026a
--- /dev/null
+++ b/src/Prometheus/Experiment/launch/prometheus_experiment.launch
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Prometheus/Experiment/package.xml b/src/Prometheus/Experiment/package.xml
new file mode 100644
index 00000000..de76d1d5
--- /dev/null
+++ b/src/Prometheus/Experiment/package.xml
@@ -0,0 +1,29 @@
+
+
+ prometheus_experiment
+ 0.0.0
+ The prometheus_experiment package
+
+
+ Yuhua Qi
+ Yuhua Qi
+ TODO
+
+ https://www.amovlab.com
+ https://github.com/potato77/prometheus_experiment.git
+
+ message_generation
+ message_runtime
+
+ catkin
+ std_msgs
+ std_msgs
+ std_msgs
+
+
+
+
+
+
+
+
diff --git a/src/Prometheus/LICENSE b/src/Prometheus/LICENSE
new file mode 100644
index 00000000..7a61a724
--- /dev/null
+++ b/src/Prometheus/LICENSE
@@ -0,0 +1,60 @@
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ a.You must give any other recipients of the Work or Derivative Works a copy of this License; and
+ b.You must cause any modified files to carry prominent notices stating that You changed the files; and
+ c.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+ d.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+Copyright 2022 AMOVLAB
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/CMakeLists.txt b/src/Prometheus/Modules/common/CMakeLists.txt
new file mode 120000
index 00000000..66dd650a
--- /dev/null
+++ b/src/Prometheus/Modules/common/CMakeLists.txt
@@ -0,0 +1 @@
+/opt/ros/melodic/share/catkin/cmake/toplevel.cmake
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/include/geometry_utils.h b/src/Prometheus/Modules/common/include/geometry_utils.h
new file mode 100644
index 00000000..a9b77726
--- /dev/null
+++ b/src/Prometheus/Modules/common/include/geometry_utils.h
@@ -0,0 +1,248 @@
+#ifndef __GEOMETRY_UTILS_H
+#define __GEOMETRY_UTILS_H
+
+#include
+
+/* clang-format off */
+namespace geometry_utils {
+
+template
+Scalar_t toRad(const Scalar_t& x) {
+ return x / 180.0 * M_PI;
+}
+
+template
+Scalar_t toDeg(const Scalar_t& x) {
+ return x * 180.0 / M_PI;
+}
+
+template
+Eigen::Matrix rotx(Scalar_t t) {
+ Eigen::Matrix R;
+ R(0, 0) = 1.0;
+ R(0, 1) = 0.0;
+ R(0, 2) = 0.0;
+ R(1, 0) = 0.0;
+ R(1, 1) = std::cos(t);
+ R(1, 2) = -std::sin(t);
+ R(2, 0) = 0.0;
+ R(2, 1) = std::sin(t);
+ R(2, 2) = std::cos(t);
+
+ return R;
+}
+
+template
+Eigen::Matrix roty(Scalar_t t) {
+ Eigen::Matrix R;
+ R(0, 0) = std::cos(t);
+ R(0, 1) = 0.0;
+ R(0, 2) = std::sin(t);
+ R(1, 0) = 0.0;
+ R(1, 1) = 1.0;
+ R(1, 2) = 0;
+ R(2, 0) = -std::sin(t);
+ R(2, 1) = 0.0;
+ R(2, 2) = std::cos(t);
+
+ return R;
+}
+
+template
+Eigen::Matrix rotz(Scalar_t t) {
+ Eigen::Matrix R;
+ R(0, 0) = std::cos(t);
+ R(0, 1) = -std::sin(t);
+ R(0, 2) = 0.0;
+ R(1, 0) = std::sin(t);
+ R(1, 1) = std::cos(t);
+ R(1, 2) = 0.0;
+ R(2, 0) = 0.0;
+ R(2, 1) = 0.0;
+ R(2, 2) = 1.0;
+
+ return R;
+}
+
+template
+Eigen::Matrix ypr_to_R(const Eigen::DenseBase& ypr) {
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
+ EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+ EIGEN_STATIC_ASSERT(Derived::ColsAtCompileTime == 1, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+
+ typename Derived::Scalar c, s;
+
+ Eigen::Matrix Rz = Eigen::Matrix::Zero();
+ typename Derived::Scalar y = ypr(0);
+ c = cos(y);
+ s = sin(y);
+ Rz(0, 0) = c;
+ Rz(1, 0) = s;
+ Rz(0, 1) = -s;
+ Rz(1, 1) = c;
+ Rz(2, 2) = 1;
+
+ Eigen::Matrix Ry = Eigen::Matrix::Zero();
+ typename Derived::Scalar p = ypr(1);
+ c = cos(p);
+ s = sin(p);
+ Ry(0, 0) = c;
+ Ry(2, 0) = -s;
+ Ry(0, 2) = s;
+ Ry(2, 2) = c;
+ Ry(1, 1) = 1;
+
+ Eigen::Matrix Rx = Eigen::Matrix::Zero();
+ typename Derived::Scalar r = ypr(2);
+ c = cos(r);
+ s = sin(r);
+ Rx(1, 1) = c;
+ Rx(2, 1) = s;
+ Rx(1, 2) = -s;
+ Rx(2, 2) = c;
+ Rx(0, 0) = 1;
+
+ Eigen::Matrix R = Rz * Ry * Rx;
+ return R;
+}
+
+template
+Eigen::Matrix R_to_ypr(const Eigen::DenseBase& R) {
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
+ EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+ EIGEN_STATIC_ASSERT(Derived::ColsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+
+ Eigen::Matrix n = R.col(0);
+ Eigen::Matrix o = R.col(1);
+ Eigen::Matrix a = R.col(2);
+
+ Eigen::Matrix ypr(3);
+ typename Derived::Scalar y = atan2(n(1), n(0));
+ typename Derived::Scalar p = atan2(-n(2), n(0) * cos(y) + n(1) * sin(y));
+ typename Derived::Scalar r =
+ atan2(a(0) * sin(y) - a(1) * cos(y), -o(0) * sin(y) + o(1) * cos(y));
+ ypr(0) = y;
+ ypr(1) = p;
+ ypr(2) = r;
+
+ return ypr;
+}
+
+template
+Eigen::Quaternion ypr_to_quaternion(const Eigen::DenseBase& ypr) {
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
+ EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+ EIGEN_STATIC_ASSERT(Derived::ColsAtCompileTime == 1, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+
+ const typename Derived::Scalar cy = cos(ypr(0) / 2.0);
+ const typename Derived::Scalar sy = sin(ypr(0) / 2.0);
+ const typename Derived::Scalar cp = cos(ypr(1) / 2.0);
+ const typename Derived::Scalar sp = sin(ypr(1) / 2.0);
+ const typename Derived::Scalar cr = cos(ypr(2) / 2.0);
+ const typename Derived::Scalar sr = sin(ypr(2) / 2.0);
+
+ Eigen::Quaternion q;
+
+ q.w() = cr * cp * cy + sr * sp * sy;
+ q.x() = sr * cp * cy - cr * sp * sy;
+ q.y() = cr * sp * cy + sr * cp * sy;
+ q.z() = cr * cp * sy - sr * sp * cy;
+
+ return q;
+}
+
+template
+Eigen::Matrix quaternion_to_ypr(const Eigen::Quaternion& q_) {
+ Eigen::Quaternion q = q_.normalized();
+
+ Eigen::Matrix ypr;
+ ypr(2) = atan2(2 * (q.w() * q.x() + q.y() * q.z()), 1 - 2 * (q.x() * q.x() + q.y() * q.y()));
+ ypr(1) = asin(2 * (q.w() * q.y() - q.z() * q.x()));
+ ypr(0) = atan2(2 * (q.w() * q.z() + q.x() * q.y()), 1 - 2 * (q.y() * q.y() + q.z() * q.z()));
+
+ return ypr;
+}
+
+template
+Scalar_t get_yaw_from_quaternion(const Eigen::Quaternion& q) {
+ return quaternion_to_ypr(q)(0);
+}
+
+template
+Eigen::Quaternion yaw_to_quaternion(Scalar_t yaw) {
+ return Eigen::Quaternion(rotz(yaw));
+}
+
+template
+Scalar_t normalize_angle(Scalar_t a) {
+ int cnt = 0;
+ while (true) {
+ cnt++;
+
+ if (a < -M_PI) {
+ a += M_PI * 2.0;
+ } else if (a > M_PI) {
+ a -= M_PI * 2.0;
+ }
+
+ if (-M_PI <= a && a <= M_PI) {
+ break;
+ };
+
+ assert(cnt < 10 && "[geometry_utils/geometry_msgs] INVALID INPUT ANGLE");
+ }
+
+ return a;
+}
+
+template
+Scalar_t angle_add(Scalar_t a, Scalar_t b) {
+ Scalar_t c = a + b;
+ c = normalize_angle(c);
+ assert(-M_PI <= c && c <= M_PI);
+ return c;
+}
+
+template
+Scalar_t yaw_add(Scalar_t a, Scalar_t b) {
+ return angle_add(a, b);
+}
+
+template
+Eigen::Matrix get_skew_symmetric(const Eigen::DenseBase& v) {
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
+ EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+ EIGEN_STATIC_ASSERT(Derived::ColsAtCompileTime == 1, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+
+ Eigen::Matrix M;
+ M.setZero();
+ M(0, 1) = -v(2);
+ M(0, 2) = v(1);
+ M(1, 0) = v(2);
+ M(1, 2) = -v(0);
+ M(2, 0) = -v(1);
+ M(2, 1) = v(0);
+ return M;
+}
+
+template
+Eigen::Matrix from_skew_symmetric(const Eigen::DenseBase& M) {
+ EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
+ EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+ EIGEN_STATIC_ASSERT(Derived::ColsAtCompileTime == 3, THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE);
+
+ Eigen::Matrix v;
+ v(0) = M(2, 1);
+ v(1) = -M(2, 0);
+ v(2) = M(1, 0);
+
+ assert(v.isApprox(Eigen::Matrix(-M(1, 2), M(0, 2), -M(0, 1))));
+
+ return v;
+}
+
+
+} // end of namespace geometry_utils
+/* clang-format on */
+
+#endif
diff --git a/src/Prometheus/Modules/common/include/math_utils.h b/src/Prometheus/Modules/common/include/math_utils.h
new file mode 100644
index 00000000..d46a57ed
--- /dev/null
+++ b/src/Prometheus/Modules/common/include/math_utils.h
@@ -0,0 +1,127 @@
+#ifndef MATH_UTILS_H
+#define MATH_UTILS_H
+
+#include
+#include
+
+using namespace std;
+
+// 四元数转欧拉角
+Eigen::Vector3d quaternion_to_rpy2(const Eigen::Quaterniond &q)
+{
+ // YPR - ZYX
+ return q.toRotationMatrix().eulerAngles(2, 1, 0).reverse();
+}
+
+// 从(roll,pitch,yaw)创建四元数 by a 3-2-1 intrinsic Tait-Bryan rotation sequence
+Eigen::Quaterniond quaternion_from_rpy(const Eigen::Vector3d &rpy)
+{
+ // YPR - ZYX
+ return Eigen::Quaterniond(
+ Eigen::AngleAxisd(rpy.z(), Eigen::Vector3d::UnitZ()) *
+ Eigen::AngleAxisd(rpy.y(), Eigen::Vector3d::UnitY()) *
+ Eigen::AngleAxisd(rpy.x(), Eigen::Vector3d::UnitX())
+ );
+}
+
+// 将四元数转换至(roll,pitch,yaw) by a 3-2-1 intrinsic Tait-Bryan rotation sequence
+// https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
+// q0 q1 q2 q3
+// w x y z
+Eigen::Vector3d quaternion_to_euler(const Eigen::Quaterniond &q)
+{
+ float quat[4];
+ quat[0] = q.w();
+ quat[1] = q.x();
+ quat[2] = q.y();
+ quat[3] = q.z();
+
+ Eigen::Vector3d ans;
+ ans[0] = atan2(2.0 * (quat[3] * quat[2] + quat[0] * quat[1]), 1.0 - 2.0 * (quat[1] * quat[1] + quat[2] * quat[2]));
+ ans[1] = asin(2.0 * (quat[2] * quat[0] - quat[3] * quat[1]));
+ ans[2] = atan2(2.0 * (quat[3] * quat[0] + quat[1] * quat[2]), 1.0 - 2.0 * (quat[2] * quat[2] + quat[3] * quat[3]));
+ return ans;
+}
+
+//旋转矩阵转欧拉角
+void rotation_to_euler(const Eigen::Matrix3d& dcm, Eigen::Vector3d& euler_angle)
+{
+ double phi_val = atan2(dcm(2, 1), dcm(2, 2));
+ double theta_val = asin(-dcm(2, 0));
+ double psi_val = atan2(dcm(1, 0), dcm(0, 0));
+ double pi = M_PI;
+
+ if (fabs(theta_val - pi / 2.0) < 1.0e-3) {
+ phi_val = 0.0;
+ psi_val = atan2(dcm(1, 2), dcm(0, 2));
+
+ } else if (fabs(theta_val + pi / 2.0) < 1.0e-3) {
+ phi_val = 0.0;
+ psi_val = atan2(-dcm(1, 2), -dcm(0, 2));
+ }
+
+ euler_angle(0) = phi_val;
+ euler_angle(1) = theta_val;
+ euler_angle(2) = psi_val;
+}
+
+//constrain_function
+float constrain_function(float data, float Max)
+{
+ if(abs(data)>Max)
+ {
+ return (data > 0) ? Max : -Max;
+ }
+ else
+ {
+ return data;
+ }
+}
+
+//constrain_function2
+float constrain_function2(float data, float Min,float Max)
+{
+ if(data > Max)
+ {
+ return Max;
+ }
+ else if (data < Min)
+ {
+ return Min;
+ }else
+ {
+ return data;
+ }
+}
+
+//sign_function
+float sign_function(float data)
+{
+ if(data>0)
+ {
+ return 1.0;
+ }
+ else if(data<0)
+ {
+ return -1.0;
+ }
+ else if(data == 0)
+ {
+ return 0.0;
+ }
+}
+
+// min function
+float min(float data1,float data2)
+{
+ if(data1>=data2)
+ {
+ return data2;
+ }
+ else
+ {
+ return data1;
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/include/printf_utils.h b/src/Prometheus/Modules/common/include/printf_utils.h
new file mode 100644
index 00000000..941fbf68
--- /dev/null
+++ b/src/Prometheus/Modules/common/include/printf_utils.h
@@ -0,0 +1,132 @@
+#ifndef PRINTF_UTILS_H
+#define PRINTF_UTILS_H
+
+#include
+#include
+#include
+#include
+#include
+using namespace std;
+
+#define NUM_POINT 2 // 打印小数点
+
+#define RED "\033[0;1;31m"
+#define GREEN "\033[0;1;32m"
+#define YELLOW "\033[0;1;33m"
+#define BLUE "\033[0;1;34m"
+#define PURPLE "\033[0;1;35m"
+#define DEEPGREEN "\033[0;1;36m"
+#define WHITE "\033[0;1;37m"
+
+#define RED_IN_WHITE "\033[0;47;31m"
+#define GREEN_IN_WHITE "\033[0;47;32m"
+#define YELLOW_IN_WHITE "\033[0;47;33m"
+
+#define TAIL "\033[0m"
+
+class Print
+{
+public:
+ Print(float interval = 0, std::string color = TAIL)
+ : interval(interval), past_ts(std::chrono::system_clock::now()), color(color)
+ {
+ //固定的浮点显示
+ std::cout.setf(ios::fixed);
+ // setprecision(n) 设显示小数精度为n位
+ std::cout << std::setprecision(2);
+ //左对齐
+ std::cout.setf(ios::left);
+ // 强制显示小数点
+ std::cout.setf(ios::showpoint);
+ // 强制显示符号
+ std::cout.setf(ios::showpos);
+ };
+
+ template
+ void operator()(T &&msg)
+ {
+ std::chrono::system_clock::time_point now_ts = std::chrono::system_clock::now();
+ auto dt = std::chrono::duration_cast(now_ts - past_ts).count();
+
+ if (this != s_object_name)
+ {
+ std::cout << std::endl;
+ s_object_name = this;
+ }
+
+ if (interval >= 0)
+ {
+ // std::cout << this->interval << std::endl;
+ if (dt < this->interval * 1000)
+ return;
+ std::cout << color << msg << TAIL << std::endl;
+ }
+ else
+ {
+ if (dt < 0.1 * 1000)
+ return;
+ char now_char;
+ switch (times)
+ {
+ case 0:
+ now_char = '\\';
+ break;
+ case 1:
+ now_char = '|';
+ break;
+ case 2:
+ now_char = '/';
+ break;
+ case 3:
+ now_char = '-';
+ break;
+ }
+ times = ++times % 4;
+ std::cout << color << "\r " << now_char << " " << msg << TAIL << std::flush;
+ }
+ this->past_ts = now_ts;
+ };
+
+ float interval;
+
+private:
+ std::chrono::system_clock::time_point past_ts;
+ std::string color;
+ static void *s_object_name;
+ unsigned int times = 0;
+};
+
+void *Print::s_object_name = nullptr;
+
+#define PRINTF_UTILS_CONCAT_(x, y) x##y
+#define PRINTF_UTILS_CONCAT(x, y) PRINTF_UTILS_CONCAT_(x, y)
+
+#define PRINTF_UTILS_PCOUT_(interval, color, msg, sign) \
+ static Print PRINTF_UTILS_CONCAT(print, sign)(interval, color); \
+ PRINTF_UTILS_CONCAT(print, sign) \
+ (msg)
+
+#define PCOUT(interval, color, msg) PRINTF_UTILS_PCOUT_(interval, color, msg, __LINE__)
+
+// Example:
+// cout << GREEN << "Test for Green text." << TAIL < Hightlight color.\033[0m");
+// 其中41的位置代表字的背景色, 30的位置是代表字的颜色,0 是字的一些特殊属性,0代表默认关闭,一些其他属性如闪烁、下划线等。
+
+// ROS_INFO_STREAM_ONCE ("\033[1;32m---->Setting to OFFBOARD Mode....\033[0m");//绿色只打印一次
+
+#endif
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/CMakeLists.txt b/src/Prometheus/Modules/common/prometheus_msgs/CMakeLists.txt
new file mode 100644
index 00000000..3c852583
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/CMakeLists.txt
@@ -0,0 +1,92 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(prometheus_msgs)
+
+find_package(catkin REQUIRED COMPONENTS
+ message_generation
+ roscpp
+ geometry_msgs
+ actionlib_msgs
+ sensor_msgs
+ nav_msgs
+ std_msgs
+ std_srvs
+ tf2_ros
+ tf2_eigen
+ mavros_msgs
+)
+
+find_package(Boost REQUIRED COMPONENTS system)
+
+add_message_files(
+ DIRECTORY msg
+ FILES
+ UAVState.msg
+ MultiUAVState.msg
+ UAVCommand.msg
+ UAVControlState.msg
+ UAVSetup.msg
+ TextInfo.msg
+ GlobalAruco.msg
+
+ ArucoInfo.msg
+ MultiArucoInfo.msg
+ DetectionInfo.msg
+ MultiDetectionInfo.msg
+ BoundingBox.msg
+ BoundingBoxes.msg
+
+ SwarmCommand.msg
+ FormationAssign.msg
+ OffsetPose.msg
+ GPSData.msg
+
+#communication
+ DetectionInfoSub.msg
+ GimbalControl.msg
+ GimbalState.msg
+ MultiDetectionInfoSub.msg
+ RheaCommunication.msg
+ RheaGPS.msg
+ RheaState.msg
+ VisionDiff.msg
+ WindowPosition.msg
+)
+
+add_action_files(
+ DIRECTORY action
+ FILES
+ CheckForObjects.action
+)
+
+generate_messages(
+ DEPENDENCIES
+ actionlib_msgs
+ geometry_msgs
+ sensor_msgs
+ std_msgs
+)
+
+catkin_package(
+ CATKIN_DEPENDS
+ message_runtime
+ actionlib_msgs
+ geometry_msgs
+ sensor_msgs
+ message_runtime
+ std_msgs
+)
+
+include_directories(
+ include
+ ${catkin_INCLUDE_DIRS}
+)
+
+
+install(DIRECTORY include/${PROJECT_NAME}/
+ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
+ FILES_MATCHING PATTERN "*.h"
+)
+
+install(DIRECTORY launch/
+ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
+)
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/action/CheckForObjects.action b/src/Prometheus/Modules/common/prometheus_msgs/action/CheckForObjects.action
new file mode 100755
index 00000000..ab6b2b6a
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/action/CheckForObjects.action
@@ -0,0 +1,13 @@
+# Check if objects in image
+
+# Goal definition
+int16 id
+sensor_msgs/Image image
+
+---
+# Result definition
+int16 id
+prometheus_msgs/BoundingBoxes bounding_boxes
+
+---
+# Feedback definition
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/ArucoInfo.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/ArucoInfo.msg
new file mode 100755
index 00000000..afd65e01
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/ArucoInfo.msg
@@ -0,0 +1,17 @@
+std_msgs/Header header
+
+## aruco编码
+int32 aruco_num
+
+## 是否检测到目标
+bool detected
+
+## 目标位置-相机坐标系-(x,y,z)
+## 从相机往前看,物体在相机右方x为正,下方y为正,前方z为正
+float32[3] position
+
+## 目标姿态-四元数-(qx,qy,qz,qw)
+float32[4] orientation
+
+## 视线角度-相机系下-(右方x角度为正,下方y角度为正)
+float32[2] sight_angle
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/BoundingBox.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/BoundingBox.msg
new file mode 100755
index 00000000..9b738721
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/BoundingBox.msg
@@ -0,0 +1,8 @@
+# 目标框相关信息
+string Class # 类别
+float64 probability # 置信度
+int64 xmin # 右上角
+int64 ymin
+int64 xmax # 坐下角
+int64 ymax
+
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/BoundingBoxes.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/BoundingBoxes.msg
new file mode 100755
index 00000000..3ec3fe82
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/BoundingBoxes.msg
@@ -0,0 +1,3 @@
+Header header
+Header image_header
+BoundingBox[] bounding_boxes
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/DetectionInfo.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/DetectionInfo.msg
new file mode 100644
index 00000000..452abd6a
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/DetectionInfo.msg
@@ -0,0 +1,33 @@
+# 目标信息
+
+std_msgs/Header header
+
+## 目标类别名称
+string object_name
+
+## 是否检测到目标
+bool detected
+
+## 0表示相机坐标系, 1表示机体坐标系, 2表示惯性坐标系
+int32 frame
+
+## 目标位置[相机系下:右方x为正,下方y为正,前方z为正]
+float32[3] position
+
+## 目标姿态-欧拉角-(z,y,x)
+float32[3] attitude
+
+## 目标姿态-四元数-(qx,qy,qz,qw)
+float32[4] attitude_q
+
+## 视线角度[相机系下:右方x角度为正,下方y角度为正]
+float32[2] sight_angle
+
+## 像素位置[相机系下:右方x为正,下方y为正]
+int32[2] pixel_position
+
+## 偏航角误差
+float32 yaw_error
+
+## 类别
+int32 category
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/DetectionInfoSub.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/DetectionInfoSub.msg
new file mode 100644
index 00000000..779a4bcd
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/DetectionInfoSub.msg
@@ -0,0 +1,9 @@
+#目标框的位置(主要斜对角两个点)
+float32 left
+float32 top
+float32 bot
+float32 right
+
+
+## TRACK TARGET(目标框ID)
+int32 trackIds
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/FormationAssign.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/FormationAssign.msg
new file mode 100644
index 00000000..64f7ccd3
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/FormationAssign.msg
@@ -0,0 +1,5 @@
+#队形位置
+geometry_msgs/Point[] formation_poses
+
+#位置点是否选取
+bool[] assigned
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/GPSData.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/GPSData.msg
new file mode 100644
index 00000000..48cba1d6
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/GPSData.msg
@@ -0,0 +1,3 @@
+float64 latitude
+float64 longitude
+float64 altitude
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/GimbalControl.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/GimbalControl.msg
new file mode 100644
index 00000000..0b32855a
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/GimbalControl.msg
@@ -0,0 +1,33 @@
+Header header
+uint8 Id
+#control mode 0:nothong 1:angle 2:speed 3:home postion
+uint8 rpyMode
+uint8 manual = 1
+uint8 home = 2
+uint8 hold = 3 # 不控制
+uint8 fellow = 4 #fellow吊舱跟随无人机移动
+
+uint8 roll
+uint8 yaw
+uint8 pitch
+
+uint8 noCtl = 0
+uint8 velocityCtl = 1
+uint8 angleCtl = 2
+
+float32 rValue # deg 单位
+float32 yValue # deg
+float32 pValue # deg
+
+
+# focus
+uint8 focusMode # 默认值
+uint8 focusStop = 1
+uint8 focusOut = 2
+uint8 focusIn = 3
+
+# zoom
+uint8 zoomMode # 默认值
+uint8 zoomStop = 1
+uint8 zoomOut = 2
+uint8 zoomIn = 3
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/GimbalState.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/GimbalState.msg
new file mode 100644
index 00000000..1a579d2f
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/GimbalState.msg
@@ -0,0 +1,40 @@
+Header header
+uint8 Id
+
+# 0: 发一句,回一句: 此状态下,相机倍数zoomVal有效,imuAngleVel为估算直
+# 1: 发一句,一直回复: 此状态下,相机倍数zoomVal失效,imuAngleVel为真直
+uint8 feedbackMode
+
+#mode
+# 0: 手动控制
+# 1: home
+# 2: tracking
+# 3: yaw follow 吊舱跟随无人机移动
+# 4: hold 吊舱不跟随无人机
+# 5: search 自动移动旋转
+uint8 mode
+
+# 是否视频录制
+bool isRecording
+
+# 是否开启自动缩放(VisionDiff需要指定面积才能生效)
+# 0: 保持
+# 1: 放大
+# 2: 缩小
+# 3: 自动
+uint8 zoomState
+
+# 当前所处倍数
+float32 zoomVal
+
+#roll,pitch,yaw
+float32[3] imuAngle
+
+#Current gimbal joint angles(roll,pitch,yaw), published at 30 Hz.
+float32[3] rotorAngle
+
+# rpy_vel 角速度
+float32[3] imuAngleVel
+
+# rpy_tgt 目标角度
+float32[3] rotorAngleTarget
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/GlobalAruco.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/GlobalAruco.msg
new file mode 100755
index 00000000..328af1b1
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/GlobalAruco.msg
@@ -0,0 +1,12 @@
+
+std_msgs/Header header
+
+ArucoInfo Aruco1
+ArucoInfo Aruco2
+ArucoInfo Aruco3
+ArucoInfo Aruco4
+ArucoInfo Aruco5
+ArucoInfo Aruco6
+ArucoInfo Aruco7
+ArucoInfo Aruco8
+ArucoInfo Aruco9
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiArucoInfo.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiArucoInfo.msg
new file mode 100755
index 00000000..47310801
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiArucoInfo.msg
@@ -0,0 +1,7 @@
+std_msgs/Header header
+
+## 检测到的aruco码数量
+int32 num_arucos
+
+## 每个aruco码的检测结果
+ArucoInfo[] aruco_infos
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiDetectionInfo.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiDetectionInfo.msg
new file mode 100644
index 00000000..640d91f2
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiDetectionInfo.msg
@@ -0,0 +1,10 @@
+Header header
+
+## 检测到的目标数量
+int32 num_objs
+
+## Detecting or Tracking (0:detect, 1:track)
+int32 detect_or_track
+
+## 每个目标的检测结果
+DetectionInfo[] detection_infos
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiDetectionInfoSub.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiDetectionInfoSub.msg
new file mode 100644
index 00000000..bc9cd466
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiDetectionInfoSub.msg
@@ -0,0 +1,10 @@
+std_msgs/Header header
+
+#模式:0:空闲 2.simaRPN 3.deepsort/sort
+uint8 mode
+
+## 检测到的目标数量
+int32 num_objs
+
+## 每个目标的检测结果
+DetectionInfoSub[] detection_infos
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiUAVState.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiUAVState.msg
new file mode 100755
index 00000000..81b2762e
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/MultiUAVState.msg
@@ -0,0 +1,7 @@
+std_msgs/Header header
+
+##
+int32 uav_num
+
+## 从1开始
+UAVState[] uav_state_all
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/OffsetPose.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/OffsetPose.msg
new file mode 100644
index 00000000..776467e3
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/OffsetPose.msg
@@ -0,0 +1,3 @@
+uint8 uav_id
+float32 x
+float32 y
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaCommunication.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaCommunication.msg
new file mode 100644
index 00000000..dff2f07e
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaCommunication.msg
@@ -0,0 +1,18 @@
+std_msgs/Header header
+
+uint8 Mode #控制模式
+
+##控制模式类型枚举
+uint8 Stop=0
+uint8 Forward=1
+uint8 Left=2
+uint8 Right=3
+uint8 Back=4
+uint8 CMD=5
+uint8 Waypoint=6
+
+float64 linear
+float64 angular
+
+## 航点
+RheaGPS[] waypoint
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaGPS.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaGPS.msg
new file mode 100644
index 00000000..48cba1d6
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaGPS.msg
@@ -0,0 +1,3 @@
+float64 latitude
+float64 longitude
+float64 altitude
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaState.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaState.msg
new file mode 100644
index 00000000..26cf3bb5
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/RheaState.msg
@@ -0,0 +1,19 @@
+std_msgs/Header header
+uint8 rhea_id
+
+## 速度
+float64 linear
+float64 angular
+
+## 航向角
+float64 yaw
+
+## GPS
+float32 latitude #纬度
+float32 longitude #经度
+float32 altitude #高度
+
+float32[3] position
+
+## Status
+float32 battery_voltage
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/SwarmCommand.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/SwarmCommand.msg
new file mode 100755
index 00000000..0182f750
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/SwarmCommand.msg
@@ -0,0 +1,51 @@
+std_msgs/Header header
+
+## 消息来源
+string source
+
+## 编队套件数量
+uint8 swarm_num
+
+uint8 swarm_location_source
+
+# enum loc 定位来源枚举
+uint8 mocap = 0
+uint8 gps = 4
+uint8 rtk = 5
+uint8 uwb = 6
+
+## 命令
+uint8 Swarm_CMD
+# enum CMD 控制模式枚举
+uint8 Ready=0
+uint8 Init=1
+uint8 Start=2
+uint8 Hold=3
+uint8 Stop=4
+uint8 Formation=5
+
+uint8 Follow=11
+uint8 Search=12
+uint8 Attack=13
+
+## 编队控制参考量
+float32[3] leader_pos
+float32[2] leader_vel
+float32 swarm_size
+uint8 swarm_shape
+uint8 One_column=0
+uint8 Triangle=1
+uint8 Square=2
+uint8 Circular=3
+
+## 搜索控制参考量
+float32 target_area_x_min ## [m]
+float32 target_area_y_min ## [m]
+float32 target_area_x_max ## [m]
+float32 target_area_y_max ## [m]
+
+## 攻击控制参考量
+float32[3] attack_target_pos ## [m]
+
+#队形位置
+geometry_msgs/Point[] formation_poses
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/TextInfo.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/TextInfo.msg
new file mode 100644
index 00000000..25035901
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/TextInfo.msg
@@ -0,0 +1,12 @@
+#INFO:正常运行状况下反馈给地面站的信息,例如程序正常启动,状态切换的提示信息等.
+uint8 INFO=0
+#WARN:无人机或软件程序出现意外情况,依然能正常启动或继续执行任务,小概率会出现危险状况,例如无人机RTK无法维持退出到GPS,视觉跟踪目标突然丢失重新搜寻目标等.
+uint8 WARN=1
+#ERROR:无人机或软件程序出现重大意外情况,无法正常启动或继续执行任务,极有可能会出现危险状况,需要中断任务以及人为接管控制无人机,例如通信中断,无人机定位发散,ROS节点无法正常启动等.
+uint8 ERROR=2
+#FATAL:任务执行过程中,软件崩溃或无人机飞控崩溃导致无人机完全失控,需要迅速人为接管控制无人机降落减少炸机损失.
+uint8 FATAL=3
+
+std_msgs/Header header
+uint8 MessageType
+string Message
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVCommand.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVCommand.msg
new file mode 100755
index 00000000..7bc358ca
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVCommand.msg
@@ -0,0 +1,38 @@
+std_msgs/Header header
+
+## 控制命令的模式
+uint8 Agent_CMD
+# Agent_CMD 枚举
+uint8 Init_Pos_Hover=1 # home点上方悬停
+uint8 Current_Pos_Hover=2 # 当前位置上方悬停
+uint8 Land=3
+uint8 Move=4
+uint8 User_Mode1=5
+
+## 移动命令下的子模式
+uint8 Move_mode
+## 移动命令下的子模式枚举
+uint8 XYZ_POS = 0 ### 惯性系定点控制
+uint8 XY_VEL_Z_POS = 1 ### 惯性系定高速度控制
+uint8 XYZ_VEL = 2 ### 惯性系速度控制
+uint8 XYZ_POS_BODY = 3 ### 机体系位置控制
+uint8 XYZ_VEL_BODY = 4 ### 机体系速度控制
+uint8 XY_VEL_Z_POS_BODY = 5 ### 机体系定高速度控制
+uint8 TRAJECTORY = 6 ### 轨迹追踪控制
+uint8 XYZ_ATT = 7 ### 姿态控制(来自外部控制器)
+uint8 LAT_LON_ALT = 8 ### 绝对坐标系下的经纬度
+
+## 控制参考量
+float32[3] position_ref ## [m]
+float32[3] velocity_ref ## [m/s]
+float32[3] acceleration_ref ## [m/s^2]
+float32 yaw_ref ## [rad]
+bool Yaw_Rate_Mode ## True 代表控制偏航角速率
+float32 yaw_rate_ref ## [rad/s]
+float32[4] att_ref ## [rad] + [0-1]
+float64 latitude ## 无人机经度、纬度、高度
+float64 longitude ## 无人机经度、纬度、高度
+float64 altitude ## 无人机经度、纬度、高度
+
+## 控制命令的编号 防止接收到错误命令, 编号应该逐次递加
+uint32 Command_ID
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVControlState.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVControlState.msg
new file mode 100755
index 00000000..02b0a369
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVControlState.msg
@@ -0,0 +1,23 @@
+std_msgs/Header header
+
+## 无人机编号
+uint8 uav_id
+
+## 无人机控制状态
+uint8 control_state
+## 状态枚举
+uint8 INIT=0
+uint8 RC_POS_CONTROL=1
+uint8 COMMAND_CONTROL=2
+uint8 LAND_CONTROL=3
+
+## 无人机控制器标志量
+uint8 pos_controller
+## 状态枚举
+uint8 PX4_ORIGIN=0
+uint8 PID=1
+uint8 UDE=2
+uint8 NE=3
+
+# 无人机安全保护触发标志量
+bool failsafe
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVSetup.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVSetup.msg
new file mode 100644
index 00000000..982d6fd0
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVSetup.msg
@@ -0,0 +1,17 @@
+std_msgs/Header header
+
+## 无人机Setup类型(可用于模拟遥控器)
+uint8 cmd
+uint8 ARMING = 0
+uint8 SET_PX4_MODE = 1
+uint8 REBOOT_PX4 = 2
+uint8 SET_CONTROL_MODE = 3
+
+bool arming
+
+## PX4模式名查询:http://wiki.ros.org/mavros/CustomModes
+## 常用模式名:OFFBOARD,AUTO.LAND,AUTO.RTL,POSCTL
+string px4_mode
+
+## INIT,MANUAL_CONTROL,HOVER_CONTROL,COMMAND_CONTROL,LAND_CONTROL
+string control_state
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVState.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVState.msg
new file mode 100755
index 00000000..1974c4f1
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/UAVState.msg
@@ -0,0 +1,59 @@
+std_msgs/Header header
+
+## 无人机编号
+uint8 uav_id
+
+## 机载电脑是否连接上飞控,true已连接,false则不是
+bool connected
+## 是否解锁,true为已解锁,false则不是
+bool armed
+## PX4飞控当前飞行模式 int8
+string mode
+## 无人机定位来源
+uint8 location_source
+## 定位来源枚举
+uint8 MOCAP=0
+uint8 T265=1
+uint8 GAZEBO=2
+uint8 FAKE_ODOM=3
+uint8 GPS = 4
+uint8 RTK = 5
+uint8 UWB = 6
+
+## odom标志位
+bool odom_valid
+
+## GPS状态,变量对应状态可参考mavros_msgs/GPSRAW中的fix_type
+uint8 gps_status
+## GPS状态枚举
+uint8 GPS_FIX_TYPE_NO_GPS=0
+uint8 GPS_FIX_TYPE_NO_FIX=1
+uint8 GPS_FIX_TYPE_2D_FIX=2
+uint8 GPS_FIX_TYPE_3D_FIX=3
+uint8 GPS_FIX_TYPE_DGPS=4
+uint8 GPS_FIX_TYPE_RTK_FLOATR=5
+uint8 GPS_FIX_TYPE_RTK_FIXEDR=6
+uint8 GPS_FIX_TYPE_STATIC=7
+uint8 GPS_FIX_TYPE_PPP=8
+
+## 无人机位置、速度、姿态
+float32[3] position ## [m]
+## 无人机经度、纬度、高度
+float32 latitude
+float32 longitude
+float32 altitude
+## 无人机速度、姿态
+float32[3] velocity ## [m/s]
+## 无人机姿态(欧拉角、四元数)
+float32[3] attitude ## [rad]
+geometry_msgs/Quaternion attitude_q ## 四元数
+## 无人机姿态角速度
+float32[3] attitude_rate ## [rad/s]
+## 无人机电池状态
+float32 battery_state ## [V]
+float32 battery_percetage ## [0-1]
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/VisionDiff.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/VisionDiff.msg
new file mode 100644
index 00000000..d47e1aca
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/VisionDiff.msg
@@ -0,0 +1,28 @@
+uint8 Id
+uint8 detect
+
+uint16 objectX # 左上角
+uint16 objectY # 左上角
+uint16 objectWidth
+uint16 objectHeight
+
+uint16 frameWidth
+uint16 frameHeight
+
+# Gimbal 跟踪pid
+float32 kp
+float32 ki
+float32 kd
+
+int8 ctlMode # 0: yaw+pitch, 1: roll+pitch 3:混合(未实现)
+int8 yawPitch = 0
+int8 rollPitch = 1
+int8 mix=3
+
+# 用于自动缩放
+float32 currSize #框选近大远小
+float32 maxSize
+float32 minSize #框选大小
+
+float32 trackIgnoreError
+bool autoZoom
\ No newline at end of file
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/msg/WindowPosition.msg b/src/Prometheus/Modules/common/prometheus_msgs/msg/WindowPosition.msg
new file mode 100644
index 00000000..8b4bcb4b
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/msg/WindowPosition.msg
@@ -0,0 +1,20 @@
+std_msgs/Header header
+
+#模式:0:空闲 1.kcf 3.deepsort/sort(点击的id)
+uint8 mode
+
+
+#波门位置X,#波门位置Y(kcf,点击画面的功能的时候使用),左上角为(0,0)
+int16 origin_x
+int16 origin_y
+int16 width
+int16 height
+
+#波门位置X,#波门位置Y
+#int16 window_position_x = origin_x + width/2
+#int16 window_position_y = origin_y + height/2
+int16 window_position_x
+int16 window_position_y
+
+#算法检测结果的ID
+int32 track_id
diff --git a/src/Prometheus/Modules/common/prometheus_msgs/package.xml b/src/Prometheus/Modules/common/prometheus_msgs/package.xml
new file mode 100644
index 00000000..d9695c65
--- /dev/null
+++ b/src/Prometheus/Modules/common/prometheus_msgs/package.xml
@@ -0,0 +1,30 @@
+
+
+ prometheus_msgs
+ 0.0.0
+ The prometheus_msgs package
+
+ Yuhua Qi
+
+ TODO
+
+ message_generation
+ message_runtime
+ catkin
+ std_msgs
+ actionlib_msgs
+ std_msgs
+ actionlib_msgs
+ std_msgs
+ actionlib_msgs
+ geometry_msgs
+ geometry_msgs
+ geometry_msgs
+ sensor_msgs
+ sensor_msgs
+ sensor_msgs
+
+
+
+
+
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/CMakeLists.txt b/src/Prometheus/Modules/common/quadrotor_msgs/CMakeLists.txt
new file mode 100755
index 00000000..f82385d3
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 2.8.3)
+project(quadrotor_msgs)
+
+find_package(catkin REQUIRED COMPONENTS
+ roscpp
+ nav_msgs
+ geometry_msgs
+ message_generation
+)
+
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+
+include_directories(
+ ${catkin_INCLUDE_DIRS}
+ include
+ )
+
+
+add_message_files(
+ FILES
+ AuxCommand.msg
+ Corrections.msg
+ Gains.msg
+ OutputData.msg
+ PositionCommand.msg
+ PPROutputData.msg
+ Serial.msg
+ SO3Command.msg
+ StatusData.msg
+ TRPYCommand.msg
+ Odometry.msg
+ PolynomialTrajectory.msg
+ LQRTrajectory.msg
+ Px4ctrlDebug.msg
+)
+
+generate_messages(
+ DEPENDENCIES
+ geometry_msgs
+ nav_msgs
+)
+
+catkin_package(
+ CATKIN_DEPENDS message_runtime
+)
+
+find_package(Eigen3 REQUIRED)
+include_directories(${EIGEN3_INCLUDE_DIR})
+
+
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/AuxCommand.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/AuxCommand.msg
new file mode 100755
index 00000000..f59bf356
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/AuxCommand.msg
@@ -0,0 +1,5 @@
+float64 current_yaw
+float64 kf_correction
+float64[2] angle_corrections# Trims for roll, pitch
+bool enable_motors
+bool use_external_yaw
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/Corrections.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Corrections.msg
new file mode 100755
index 00000000..e0f4e888
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Corrections.msg
@@ -0,0 +1,2 @@
+float64 kf_correction
+float64[2] angle_corrections
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/Gains.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Gains.msg
new file mode 100755
index 00000000..f5d10a33
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Gains.msg
@@ -0,0 +1,4 @@
+float64 Kp
+float64 Kd
+float64 Kp_yaw
+float64 Kd_yaw
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/LQRTrajectory.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/LQRTrajectory.msg
new file mode 100755
index 00000000..0a34e9b6
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/LQRTrajectory.msg
@@ -0,0 +1,30 @@
+Header header
+
+# the trajectory id, starts from "1".
+uint32 trajectory_id
+
+# the action command for trajectory server.
+uint32 ACTION_ADD = 1
+uint32 ACTION_ABORT = 2
+uint32 ACTION_WARN_START = 3
+uint32 ACTION_WARN_FINAL = 4
+uint32 ACTION_WARN_IMPOSSIBLE = 5
+uint32 action
+
+# the weight coefficient of the control effort
+float64 r
+
+# the yaw command
+float64 start_yaw
+float64 final_yaw
+
+# the initial and final state
+float64[6] s0
+float64[3] ut
+
+float64[6] sf
+
+# the optimal arrival time
+float64 t_f
+
+string debug_info
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/Odometry.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Odometry.msg
new file mode 100755
index 00000000..3272d71a
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Odometry.msg
@@ -0,0 +1,8 @@
+uint8 STATUS_ODOM_VALID=0
+uint8 STATUS_ODOM_INVALID=1
+uint8 STATUS_ODOM_LOOPCLOSURE=2
+
+nav_msgs/Odometry curodom
+nav_msgs/Odometry kfodom
+uint32 kfid
+uint8 status
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/OutputData.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/OutputData.msg
new file mode 100755
index 00000000..ac958880
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/OutputData.msg
@@ -0,0 +1,12 @@
+Header header
+uint16 loop_rate
+float64 voltage
+geometry_msgs/Quaternion orientation
+geometry_msgs/Vector3 angular_velocity
+geometry_msgs/Vector3 linear_acceleration
+float64 pressure_dheight
+float64 pressure_height
+geometry_msgs/Vector3 magnetic_field
+uint8[8] radio_channel
+#uint8[4] motor_rpm
+uint8 seq
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/PPROutputData.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/PPROutputData.msg
new file mode 100755
index 00000000..70434a02
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/PPROutputData.msg
@@ -0,0 +1,16 @@
+Header header
+uint16 quad_time
+float64 des_thrust
+float64 des_roll
+float64 des_pitch
+float64 des_yaw
+float64 est_roll
+float64 est_pitch
+float64 est_yaw
+float64 est_angvel_x
+float64 est_angvel_y
+float64 est_angvel_z
+float64 est_acc_x
+float64 est_acc_y
+float64 est_acc_z
+uint16[4] pwm
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/PolynomialTrajectory.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/PolynomialTrajectory.msg
new file mode 100755
index 00000000..0aab297a
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/PolynomialTrajectory.msg
@@ -0,0 +1,28 @@
+Header header
+
+# the trajectory id, starts from "1".
+uint32 trajectory_id
+
+# the action command for trajectory server.
+uint32 ACTION_ADD = 1
+uint32 ACTION_ABORT = 2
+uint32 ACTION_WARN_START = 3
+uint32 ACTION_WARN_FINAL = 4
+uint32 ACTION_WARN_IMPOSSIBLE = 5
+uint32 action
+
+# the order of trajectory.
+uint32 num_order
+uint32 num_segment
+
+# the polynomial coecfficients of the trajectory.
+float64 start_yaw
+float64 final_yaw
+float64[] coef_x
+float64[] coef_y
+float64[] coef_z
+float64[] time
+float64 mag_coeff
+uint32[] order
+
+string debug_info
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/PositionCommand.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/PositionCommand.msg
new file mode 100755
index 00000000..49c6fa1d
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/PositionCommand.msg
@@ -0,0 +1,22 @@
+Header header
+geometry_msgs/Point position
+geometry_msgs/Vector3 velocity
+geometry_msgs/Vector3 acceleration
+geometry_msgs/Vector3 jerk
+float64 yaw
+float64 yaw_dot
+float64[3] kx
+float64[3] kv
+
+uint32 trajectory_id
+
+uint8 TRAJECTORY_STATUS_EMPTY = 0
+uint8 TRAJECTORY_STATUS_READY = 1
+uint8 TRAJECTORY_STATUS_COMPLETED = 3
+uint8 TRAJECTROY_STATUS_ABORT = 4
+uint8 TRAJECTORY_STATUS_ILLEGAL_START = 5
+uint8 TRAJECTORY_STATUS_ILLEGAL_FINAL = 6
+uint8 TRAJECTORY_STATUS_IMPOSSIBLE = 7
+
+# Its ID number will start from 1, allowing you comparing it with 0.
+uint8 trajectory_flag
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/Px4ctrlDebug.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Px4ctrlDebug.msg
new file mode 100755
index 00000000..f28ba2c3
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Px4ctrlDebug.msg
@@ -0,0 +1,37 @@
+Header header
+
+float64 des_p_x
+float64 des_p_y
+float64 des_p_z
+
+float64 des_v_x
+float64 des_v_y
+float64 des_v_z
+
+float64 fb_a_x
+float64 fb_a_y
+float64 fb_a_z
+
+float64 des_a_x
+float64 des_a_y
+float64 des_a_z
+
+float64 des_q_x
+float64 des_q_y
+float64 des_q_z
+float64 des_q_w
+
+float64 des_thr
+float64 thr2acc
+float64 thr_scale_compensate
+float64 voltage
+
+float64 err_axisang_x
+float64 err_axisang_y
+float64 err_axisang_z
+float64 err_axisang_ang
+
+float64 fb_rate_x
+float64 fb_rate_y
+float64 fb_rate_z
+
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/SO3Command.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/SO3Command.msg
new file mode 100755
index 00000000..d3868efb
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/SO3Command.msg
@@ -0,0 +1,6 @@
+Header header
+geometry_msgs/Vector3 force
+geometry_msgs/Quaternion orientation
+float64[3] kR
+float64[3] kOm
+quadrotor_msgs/AuxCommand aux
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/Serial.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Serial.msg
new file mode 100755
index 00000000..5a54cce3
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/Serial.msg
@@ -0,0 +1,13 @@
+# Note: These constants need to be kept in sync with the types
+# defined in include/quadrotor_msgs/comm_types.h
+uint8 SO3_CMD = 115 # 's' in base 10
+uint8 TRPY_CMD = 112 # 'p' in base 10
+uint8 STATUS_DATA = 99 # 'c' in base 10
+uint8 OUTPUT_DATA = 100 # 'd' in base 10
+uint8 PPR_OUTPUT_DATA = 116 # 't' in base 10
+uint8 PPR_GAINS = 103 # 'g'
+
+Header header
+uint8 channel
+uint8 type # One of the types listed above
+uint8[] data
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/StatusData.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/StatusData.msg
new file mode 100755
index 00000000..d176e4f0
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/StatusData.msg
@@ -0,0 +1,4 @@
+Header header
+uint16 loop_rate
+float64 voltage
+uint8 seq
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/msg/TRPYCommand.msg b/src/Prometheus/Modules/common/quadrotor_msgs/msg/TRPYCommand.msg
new file mode 100755
index 00000000..0d471a62
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/msg/TRPYCommand.msg
@@ -0,0 +1,6 @@
+Header header
+float32 thrust
+float32 roll
+float32 pitch
+float32 yaw
+quadrotor_msgs/AuxCommand aux
diff --git a/src/Prometheus/Modules/common/quadrotor_msgs/package.xml b/src/Prometheus/Modules/common/quadrotor_msgs/package.xml
new file mode 100755
index 00000000..42e9f76e
--- /dev/null
+++ b/src/Prometheus/Modules/common/quadrotor_msgs/package.xml
@@ -0,0 +1,20 @@
+
+ quadrotor_msgs
+ 0.0.0
+ quadrotor_msgs
+ Kartik Mohta
+ http://ros.org/wiki/quadrotor_msgs
+ BSD
+ catkin
+ geometry_msgs
+ nav_msgs
+ message_generation
+ geometry_msgs
+ nav_msgs
+ message_runtime
+
+
+
+
+
diff --git a/src/Prometheus/Modules/communication/CMakeLists.txt b/src/Prometheus/Modules/communication/CMakeLists.txt
new file mode 100644
index 00000000..e702198b
--- /dev/null
+++ b/src/Prometheus/Modules/communication/CMakeLists.txt
@@ -0,0 +1,63 @@
+cmake_minimum_required(VERSION 3.0.2)
+project(prometheus_communication_bridge)
+
+## 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
+ roscpp
+ std_msgs
+ std_srvs
+ geometry_msgs
+ sensor_msgs
+ message_generation
+ tf2_msgs
+ visualization_msgs
+ mavros
+ mavros_msgs
+ prometheus_msgs
+)
+
+
+generate_messages(
+ DEPENDENCIES
+ std_msgs
+ std_srvs
+ geometry_msgs
+ sensor_msgs
+ tf2_msgs
+ visualization_msgs
+ mavros_msgs
+)
+
+catkin_package(
+ INCLUDE_DIRS include
+ ##CATKIN_DEPENDS roscpp std_msgs sensor_msgs
+ CATKIN_DEPENDS
+ message_runtime
+ std_msgs
+ std_srvs
+ geometry_msgs
+ mavros_msgs
+)
+
+## Specify additional locations of header files
+## Your package locations should be listed before other locations
+include_directories(
+ include ${catkin_INCLUDE_DIRS}
+ include
+ ${catkin_INCLUDE_DIRS}
+ ${PROJECT_SOURCE_DIR}/shard/include
+)
+
+file(GLOB_RECURSE CURRENT_INCLUDE include/*.hpp include/*.h)
+file(GLOB_RECURSE CURRENT_SOURCE src/*.cpp)
+
+## Specify libraries to link a library or executable target against
+add_executable(communication_bridge ${CURRENT_SOURCE} ${CURRENT_INCLUDE})
+add_dependencies(communication_bridge ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
+target_link_libraries(communication_bridge ${catkin_LIBRARIES} ${PROJECT_SOURCE_DIR}/shard/libs/libcommunication.so boost_serialization)
+
diff --git a/src/Prometheus/Modules/communication/include/autonomous_landing_topic.hpp b/src/Prometheus/Modules/communication/include/autonomous_landing_topic.hpp
new file mode 100644
index 00000000..cd7934ec
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/autonomous_landing_topic.hpp
@@ -0,0 +1,50 @@
+#ifndef AUTONOMOUS_LANDING_TOPIC_HPP
+#define AUTONOMOUS_LANDING_TOPIC_HPP
+
+#include
+#include "communication.hpp"
+
+#include "gimbal_basic_topic.hpp"
+
+#include "std_srvs/SetBool.h"
+#include "mavros_msgs/ParamSet.h"
+#include "prometheus_msgs/RheaState.h"
+
+
+class AutonomousLanding
+{
+public:
+ AutonomousLanding(ros::NodeHandle &nh,Communication *communication);
+
+ ~AutonomousLanding();
+
+
+ void gimbalSearchServer(bool is);
+
+ void gimbalRecordVideoServer(bool is);
+
+ void gimbalTrackModeServer(bool is);
+
+ void gimbalParamSetServer(struct GimbalParamSet param_set);
+
+ void rheaStatePub(struct RheaState rhea_state);
+
+private:
+
+ ros::Publisher ugv_state_pub_;
+
+ ros::ServiceClient gimbal_search_client_;
+ ros::ServiceClient gimbal_record_video_client_;
+ ros::ServiceClient gimbal_track_mode_client_;
+ ros::ServiceClient param_set_client_;
+
+ struct GimbalState gimbal_state_;
+ struct VisionDiff vision_diff_;
+
+ int robot_id;
+
+ Communication* communication_ = NULL;
+ std::string multicast_udp_ip;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/communication/include/communication_bridge.hpp b/src/Prometheus/Modules/communication/include/communication_bridge.hpp
new file mode 100644
index 00000000..fcf56d1b
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/communication_bridge.hpp
@@ -0,0 +1,93 @@
+#ifndef COMUNICATION_BRIDGE_HPP
+#define COMUNICATION_BRIDGE_HPP
+
+#include
+#include "communication.hpp"
+
+#include
+
+#include
+#include "Struct.hpp"
+
+#include "uav_basic_topic.hpp"
+#include "ugv_basic_topic.hpp"
+#include "swarm_control_topic.hpp"
+#include "autonomous_landing_topic.hpp"
+#include "gimbal_basic_topic.hpp"
+#include "object_tracking_topic.hpp"
+
+#include
+#include
+
+enum UserType
+{
+ UAV = 1,
+ UGV = 2
+};
+
+class CommunicationBridge : public Communication
+{
+public:
+ CommunicationBridge(ros::NodeHandle &nh);
+
+ ~CommunicationBridge();
+
+ void serverFun();
+
+ //根据协议中MSG_ID的值,将数据段数据转化为正确的结构体
+ void pubMsg(int msg_id);
+
+ void recvData(struct UAVState uav_state);
+ void recvData(struct UAVCommand uav_cmd);
+ void recvData(struct SwarmCommand swarm_command);
+ void recvData(struct ConnectState connect_state);
+ void recvData(struct GimbalControl gimbal_control);
+ void recvData(struct GimbalService gimbal_service);
+ void recvData(struct GimbalParamSet param_set);
+ void recvData(struct WindowPosition window_position);
+ void recvData(struct RheaControl rhea_control);
+ void recvData(struct RheaState rhea_state);
+ void recvData(struct ImageData image_data);
+ void recvData(struct UAVSetup uav_setup);
+ void recvData(struct ModeSelection mode_selection);
+
+ void modeSwitch(struct ModeSelection mode_selection);
+
+ //接收组播地址的数据
+ void multicastUdpFun();
+
+ //给地面站发送心跳包
+ void toGroundStationFun();
+
+ void init();
+ //ros::NodeHandle nh;
+
+ void createImage(struct ImageData image_data);
+
+ bool createMode(struct ModeSelection mode_selection);
+
+ bool deleteMode(struct ModeSelection mode_selection);
+
+private:
+ //std::shared_ptr swarm_control_ ;
+ SwarmControl *swarm_control_ = NULL;
+ UGVBasic *ugv_basic_ = NULL;
+ UAVBasic *uav_basic_ = NULL;
+ //std::vector swarm_control_simulation_;
+ std::map swarm_control_simulation_;
+ AutonomousLanding *autonomous_landing_ = NULL;
+ GimbalBasic *gimbal_basic_ = NULL;
+ ObjectTracking *object_tracking_ = NULL;
+
+ int current_mode_ = 0;
+
+ int is_simulation_, swarm_num_, swarm_data_update_timeout_;
+ ros::NodeHandle nh_;
+
+ bool is_heartbeat_ready_ = false;
+
+ int user_type_;
+
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/communication/include/gimbal_basic_topic.hpp b/src/Prometheus/Modules/communication/include/gimbal_basic_topic.hpp
new file mode 100644
index 00000000..cf7b835d
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/gimbal_basic_topic.hpp
@@ -0,0 +1,39 @@
+#ifndef GimbalBasic_HPP
+#define GimbalBasic_HPP
+
+#include
+#include "communication.hpp"
+
+#include "prometheus_msgs/GimbalState.h"
+#include "prometheus_msgs/VisionDiff.h"
+#include "prometheus_msgs/WindowPosition.h"
+#include "prometheus_msgs/GimbalControl.h"
+
+class GimbalBasic
+{
+public:
+ GimbalBasic(ros::NodeHandle &nh,Communication *communication);
+ ~GimbalBasic();
+
+ void stateCb(const prometheus_msgs::GimbalState::ConstPtr &msg);
+
+ void trackCb(const prometheus_msgs::VisionDiff::ConstPtr &msg);
+
+ void gimbalWindowPositionPub(struct WindowPosition window_position);
+
+ void gimbalControlPub(struct GimbalControl gimbal_control);
+
+protected:
+ ros::Subscriber gimbal_state_sub_;
+ ros::Subscriber vision_diff_sub_;
+ ros::Publisher window_position_pub_;
+ ros::Publisher gimbal_control_pub_;
+
+ struct GimbalState gimbal_state_;
+ struct VisionDiff vision_diff_;
+
+ Communication* communication_ = NULL;
+ std::string multicast_udp_ip;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/communication/include/object_tracking_topic.hpp b/src/Prometheus/Modules/communication/include/object_tracking_topic.hpp
new file mode 100644
index 00000000..901c911e
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/object_tracking_topic.hpp
@@ -0,0 +1,26 @@
+#ifndef OBJECT_TRACKING_TOPIC_HPP
+#define OBJECT_TRACKING_TOPIC_HPP
+
+#include
+#include "communication.hpp"
+#include "prometheus_msgs/MultiDetectionInfoSub.h"
+#include "prometheus_msgs/DetectionInfoSub.h"
+
+class ObjectTracking
+{
+public:
+ ObjectTracking(ros::NodeHandle &nh,Communication *communication);
+ ~ObjectTracking();
+
+ void multiDetectionInfoCb(const prometheus_msgs::MultiDetectionInfoSub::ConstPtr &msg);
+
+
+private:
+ Communication* communication_ = NULL;
+
+ std::string multicast_udp_ip;
+
+ ros::Subscriber multi_detection_info_sub_;
+};
+
+#endif
diff --git a/src/Prometheus/Modules/communication/include/swarm_control_topic.hpp b/src/Prometheus/Modules/communication/include/swarm_control_topic.hpp
new file mode 100644
index 00000000..04ba9960
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/swarm_control_topic.hpp
@@ -0,0 +1,90 @@
+#ifndef SWARM_CONTROL_TOPIC_HPP
+#define SWARM_CONTROL_TOPIC_HPP
+
+#include
+#include "communication.hpp"
+#include "uav_basic_topic.hpp"
+
+#include "std_msgs/Bool.h"
+
+#include "prometheus_msgs/MultiUAVState.h"
+#include "prometheus_msgs/SwarmCommand.h"
+#include "prometheus_msgs/UAVState.h"
+#include "prometheus_msgs/OffsetPose.h"
+
+#include
+
+using namespace std;
+
+//订阅: /prometheus/formation_assign/result
+//发布: /Prometheus/formation_assign/info
+
+struct MultiUAVState
+{
+ int uav_num;
+ std::vector uav_state_all;
+};
+
+class SwarmControl//: public UAVBasic
+{
+public:
+ //真机构造
+ SwarmControl(ros::NodeHandle &nh, int id, int swarm_num,Communication *communication);
+
+ //仿真构造
+ SwarmControl(ros::NodeHandle &nh, int swarm_num,Communication *communication);
+
+ ~SwarmControl();
+
+ void init(ros::NodeHandle &nh, int swarm_num,int id = 1);
+
+ //更新全部飞机数据
+ void updateAllUAVState(struct UAVState uav_state);
+
+ //【发布】集群控制指令
+ void swarmCommandPub(struct SwarmCommand swarm_command);
+
+ //【发布】连接是否失效
+ void communicationStatePub(bool communication);
+
+ void communicationStatePub(bool communication,int id);
+
+ //【发布】所有无人机状态
+ void allUAVStatePub(struct MultiUAVState m_multi_uav_state);
+
+
+ void closeTopic();
+
+ inline struct MultiUAVState getMultiUAVState(){return this->multi_uav_state_;};
+
+ inline prometheus_msgs::UAVState getUAVStateMsg(){return this->uav_state_msg_;};
+
+
+private:
+
+ struct MultiUAVState multi_uav_state_;
+
+ Communication *communication_ = NULL;
+
+ prometheus_msgs::UAVState uav_state_msg_;
+
+
+ //集群全部uav 状态
+ ros::Publisher all_uav_state_pub_;
+ //控制指令
+ ros::Publisher swarm_command_pub_;
+ //连接是否失效
+ ros::Publisher communication_state_pub_;
+
+
+ //仿真
+ std::vector simulation_communication_state_pub;
+
+ bool is_simulation_;
+
+ std::string udp_ip, multicast_udp_ip;
+
+ std::string user_type_ = "";
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/communication/include/uav_basic_topic.hpp b/src/Prometheus/Modules/communication/include/uav_basic_topic.hpp
new file mode 100644
index 00000000..203c4568
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/uav_basic_topic.hpp
@@ -0,0 +1,75 @@
+#ifndef UAV_BASIC_TOPIC_HPP
+#define UAV_BASIC_TOPIC_HPP
+
+#include
+#include "communication.hpp"
+#include "prometheus_msgs/UAVState.h"
+#include "prometheus_msgs/TextInfo.h"
+#include "prometheus_msgs/OffsetPose.h"
+#include "prometheus_msgs/UAVCommand.h"
+#include "prometheus_msgs/UAVSetup.h"
+#include "prometheus_msgs/UAVControlState.h"
+
+class UAVBasic
+{
+public:
+ UAVBasic();
+
+ UAVBasic(ros::NodeHandle &nh,int id,Communication *communication);
+
+ ~UAVBasic();
+
+ inline int getRobotId(){return robot_id;};
+
+ void stateCb(const prometheus_msgs::UAVState::ConstPtr &msg);
+
+ //【回调】uav反馈信息
+ void textInfoCb(const prometheus_msgs::TextInfo::ConstPtr &msg);
+
+ //【订阅】偏移量
+ void offsetPoseCb(const prometheus_msgs::OffsetPose::ConstPtr &msg);
+
+ void controlStateCb(const prometheus_msgs::UAVControlState::ConstPtr &msg);
+
+ struct UAVState getUAVState();
+
+ void uavCmdPub(struct UAVCommand uav_cmd);
+
+ void uavSetupPub(struct UAVSetup uav_setup);
+
+ void setTimeStamp(uint time);
+
+ uint getTimeStamp();
+
+private:
+ ros::Subscriber uav_state_sub_;
+
+ //反馈信息
+ ros::Subscriber text_info_sub_;
+ //控制状态
+ ros::Subscriber uav_control_state_sub_;
+ //偏移量订阅
+ ros::Subscriber offset_pose_sub_;
+
+ ros::Publisher uav_cmd_pub_;
+
+ ros::Publisher uav_setup_pub_;
+
+ int current_mode_;
+
+ int robot_id;
+
+ struct UAVState uav_state_;
+ struct TextInfo text_info_;
+ struct UAVControlState uav_control_state_;
+
+ prometheus_msgs::OffsetPose offset_pose_;
+
+ Communication *communication_ = NULL;
+
+ std::string multicast_udp_ip;
+
+ uint time_stamp_ = 0;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/communication/include/ugv_basic_topic.hpp b/src/Prometheus/Modules/communication/include/ugv_basic_topic.hpp
new file mode 100644
index 00000000..2a2fdf32
--- /dev/null
+++ b/src/Prometheus/Modules/communication/include/ugv_basic_topic.hpp
@@ -0,0 +1,63 @@
+#ifndef UGV_BASIC_TOPIC_HPP
+#define UGV_BASIC_TOPIC_HPP
+
+#include
+#include "communication.hpp"
+#include "prometheus_msgs/RheaCommunication.h"
+#include "prometheus_msgs/RheaState.h"
+#include "prometheus_msgs/RheaGPS.h"
+using namespace std;
+
+class UGVBasic
+{
+public:
+ UGVBasic(ros::NodeHandle &nh,Communication *communication);
+
+ ~UGVBasic();
+
+ // void scanCb(const sensor_msgs::LaserScan::ConstPtr &msg);
+
+ // void scanMatchedPoints2Cb(const sensor_msgs::PointCloud2::ConstPtr &msg);
+
+ // void tfCb(const tf2_msgs::TFMessage::ConstPtr &msg);
+
+ // void tfStaticCb(const tf2_msgs::TFMessage::ConstPtr &msg);
+
+ // void constraintListCb(const visualization_msgs::MarkerArray::ConstPtr &msg);
+
+ // void landmarkPosesListCb(const visualization_msgs::MarkerArray::ConstPtr &msg);
+
+ // void trajectoryNodeListCb(const visualization_msgs::MarkerArray::ConstPtr &msg);
+
+ void rheaControlPub(struct RheaControl rhea_control);
+
+ void rheaStateCb(const prometheus_msgs::RheaState::ConstPtr &msg);
+
+ void setTimeStamp(uint time);
+
+ uint getTimeStamp();
+
+private:
+ //rviz
+ ros::Subscriber scan_matched_points2_sub_;
+ ros::Subscriber scan_sub_;
+ ros::Subscriber tf_static_sub_;
+ ros::Subscriber tf_sub_;
+ ros::Subscriber constraint_list_sub_;
+ ros::Subscriber landmark_poses_list_sub_;
+ ros::Subscriber trajectory_node_list_sub_;
+ //
+ ros::Publisher rhea_control_pub_;
+ ros::Subscriber rhea_state_sub_;
+
+ ros::Subscriber cmd_vel_sub_;
+
+ Communication* communication_ = NULL;
+
+ std::string udp_ip;
+ std::string multicast_udp_ip;
+
+ uint time_stamp_ = 0;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/Prometheus/Modules/communication/launch/bridge.launch b/src/Prometheus/Modules/communication/launch/bridge.launch
new file mode 100644
index 00000000..574ef1ca
--- /dev/null
+++ b/src/Prometheus/Modules/communication/launch/bridge.launch
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Prometheus/Modules/communication/package.xml b/src/Prometheus/Modules/communication/package.xml
new file mode 100644
index 00000000..624633b5
--- /dev/null
+++ b/src/Prometheus/Modules/communication/package.xml
@@ -0,0 +1,34 @@
+
+
+ prometheus_communication_bridge
+ 0.0.0
+ The ground_station_bridge module
+
+ Amov
+ Aomv
+
+ catkin
+ roscpp
+ std_msgs
+ std_srvs
+ geometry_msgs
+ roscpp
+ std_msgs
+ std_srvs
+ geometry_msgs
+ roscpp
+ std_msgs
+ std_srvs
+ geometry_msgs
+ sensor_msgs
+ sensor_msgs
+ sensor_msgs
+ mavros_msgs
+ mavros_msgs
+ mavros_msgs
+ message_runtime
+
+
+
+
+
diff --git a/src/Prometheus/Modules/communication/shard/include/CRC.h b/src/Prometheus/Modules/communication/shard/include/CRC.h
new file mode 100644
index 00000000..e20db354
--- /dev/null
+++ b/src/Prometheus/Modules/communication/shard/include/CRC.h
@@ -0,0 +1,2066 @@
+/**
+ @file CRC.h
+ @author Daniel Bahr
+ @version 1.1.0.0
+ @copyright
+ @parblock
+ CRC++
+ Copyright (c) 2021, Daniel Bahr
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of CRC++ nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ @endparblock
+*/
+
+/*
+ CRC++ can be configured by setting various #defines before #including this header file:
+
+ #define crcpp_uint8 - Specifies the type used to store CRCs that have a width of 8 bits or less.
+ This type is not used in CRC calculations. Defaults to ::std::uint8_t.
+ #define crcpp_uint16 - Specifies the type used to store CRCs that have a width between 9 and 16 bits (inclusive).
+ This type is not used in CRC calculations. Defaults to ::std::uint16_t.
+ #define crcpp_uint32 - Specifies the type used to store CRCs that have a width between 17 and 32 bits (inclusive).
+ This type is not used in CRC calculations. Defaults to ::std::uint32_t.
+ #define crcpp_uint64 - Specifies the type used to store CRCs that have a width between 33 and 64 bits (inclusive).
+ This type is not used in CRC calculations. Defaults to ::std::uint64_t.
+ #define crcpp_size - This type is used for loop iteration and function signatures only. Defaults to ::std::size_t.
+ #define CRCPP_USE_NAMESPACE - Define to place all CRC++ code within the ::CRCPP namespace.
+ #define CRCPP_BRANCHLESS - Define to enable a branchless CRC implementation. The branchless implementation uses a single integer
+ multiplication in the bit-by-bit calculation instead of a small conditional. The branchless implementation
+ may be faster on processor architectures which support single-instruction integer multiplication.
+ #define CRCPP_USE_CPP11 - Define to enables C++11 features (move semantics, constexpr, static_assert, etc.).
+ #define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS - Define to include definitions for little-used CRCs.
+*/
+
+#ifndef CRCPP_CRC_H_
+#define CRCPP_CRC_H_
+
+#include // Includes CHAR_BIT
+#ifdef CRCPP_USE_CPP11
+#include // Includes ::std::size_t
+#include // Includes ::std::uint8_t, ::std::uint16_t, ::std::uint32_t, ::std::uint64_t
+#else
+#include // Includes size_t
+#include // Includes uint8_t, uint16_t, uint32_t, uint64_t
+#endif
+#include // Includes ::std::numeric_limits
+#include // Includes ::std::move
+
+#ifndef crcpp_uint8
+# ifdef CRCPP_USE_CPP11
+ /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint8 ::std::uint8_t
+# else
+ /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint8 uint8_t
+# endif
+#endif
+
+#ifndef crcpp_uint16
+# ifdef CRCPP_USE_CPP11
+ /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint16 ::std::uint16_t
+# else
+ /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint16 uint16_t
+# endif
+#endif
+
+#ifndef crcpp_uint32
+# ifdef CRCPP_USE_CPP11
+ /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint32 ::std::uint32_t
+# else
+ /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint32 uint32_t
+# endif
+#endif
+
+#ifndef crcpp_uint64
+# ifdef CRCPP_USE_CPP11
+ /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint64 ::std::uint64_t
+# else
+ /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions.
+# define crcpp_uint64 uint64_t
+# endif
+#endif
+
+#ifndef crcpp_size
+# ifdef CRCPP_USE_CPP11
+ /// @brief Unsigned size definition, used for specifying data sizes.
+# define crcpp_size ::std::size_t
+# else
+ /// @brief Unsigned size definition, used for specifying data sizes.
+# define crcpp_size size_t
+# endif
+#endif
+
+#ifdef CRCPP_USE_CPP11
+ /// @brief Compile-time expression definition.
+# define crcpp_constexpr constexpr
+#else
+ /// @brief Compile-time expression definition.
+# define crcpp_constexpr const
+#endif
+
+#ifdef CRCPP_USE_NAMESPACE
+namespace CRCPP
+{
+#endif
+
+/**
+ @brief Static class for computing CRCs.
+ @note This class supports computation of full and multi-part CRCs, using a bit-by-bit algorithm or a
+ byte-by-byte lookup table. The CRCs are calculated using as many optimizations as is reasonable.
+ If compiling with C++11, the constexpr keyword is used liberally so that many calculations are
+ performed at compile-time instead of at runtime.
+*/
+class CRC
+{
+public:
+ // Forward declaration
+ template
+ struct Table;
+
+ /**
+ @brief CRC parameters.
+ */
+ template
+ struct Parameters
+ {
+ CRCType polynomial; ///< CRC polynomial
+ CRCType initialValue; ///< Initial CRC value
+ CRCType finalXOR; ///< Value to XOR with the final CRC
+ bool reflectInput; ///< true to reflect all input bytes
+ bool reflectOutput; ///< true to reflect the output CRC (reflection occurs before the final XOR)
+
+ Table MakeTable() const;
+ };
+
+ /**
+ @brief CRC lookup table. After construction, the CRC parameters are fixed.
+ @note A CRC table can be used for multiple CRC calculations.
+ */
+ template
+ struct Table
+ {
+ // Constructors are intentionally NOT marked explicit.
+ Table(const Parameters & parameters);
+
+#ifdef CRCPP_USE_CPP11
+ Table(Parameters && parameters);
+#endif
+
+ const Parameters & GetParameters() const;
+
+ const CRCType * GetTable() const;
+
+ CRCType operator[](unsigned char index) const;
+
+ private:
+ void InitTable();
+
+ Parameters parameters; ///< CRC parameters used to construct the table
+ CRCType table[1 << CHAR_BIT]; ///< CRC lookup table
+ };
+
+ // The number of bits in CRCType must be at least as large as CRCWidth.
+ // CRCType must be an unsigned integer type or a custom type with operator overloads.
+ template
+ static CRCType Calculate(const void * data, crcpp_size size, const Parameters & parameters);
+
+ template
+ static CRCType Calculate(const void * data, crcpp_size size, const Parameters & parameters, CRCType crc);
+
+ template
+ static CRCType Calculate(const void * data, crcpp_size size, const Table & lookupTable);
+
+ template
+ static CRCType Calculate(const void * data, crcpp_size size, const Table & lookupTable, CRCType crc);
+
+ template
+ static CRCType CalculateBits(const void * data, crcpp_size size, const Parameters & parameters);
+
+ template
+ static CRCType CalculateBits(const void * data, crcpp_size size, const Parameters & parameters, CRCType crc);
+
+ template
+ static CRCType CalculateBits(const void * data, crcpp_size size, const Table & lookupTable);
+
+ template
+ static CRCType CalculateBits(const void * data, crcpp_size size, const Table & lookupTable, CRCType crc);
+
+ // Common CRCs up to 64 bits.
+ // Note: Check values are the computed CRCs when given an ASCII input of "123456789" (without null terminator)
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters< crcpp_uint8, 4> & CRC_4_ITU();
+ static const Parameters< crcpp_uint8, 5> & CRC_5_EPC();
+ static const Parameters< crcpp_uint8, 5> & CRC_5_ITU();
+ static const Parameters< crcpp_uint8, 5> & CRC_5_USB();
+ static const Parameters< crcpp_uint8, 6> & CRC_6_CDMA2000A();
+ static const Parameters< crcpp_uint8, 6> & CRC_6_CDMA2000B();
+ static const Parameters< crcpp_uint8, 6> & CRC_6_ITU();
+ static const Parameters< crcpp_uint8, 6> & CRC_6_NR();
+ static const Parameters< crcpp_uint8, 7> & CRC_7();
+#endif
+ static const Parameters< crcpp_uint8, 8> & CRC_8();
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters< crcpp_uint8, 8> & CRC_8_EBU();
+ static const Parameters< crcpp_uint8, 8> & CRC_8_MAXIM();
+ static const Parameters< crcpp_uint8, 8> & CRC_8_WCDMA();
+ static const Parameters< crcpp_uint8, 8> & CRC_8_LTE();
+ static const Parameters & CRC_10();
+ static const Parameters & CRC_10_CDMA2000();
+ static const Parameters & CRC_11();
+ static const Parameters & CRC_11_NR();
+ static const Parameters & CRC_12_CDMA2000();
+ static const Parameters & CRC_12_DECT();
+ static const Parameters & CRC_12_UMTS();
+ static const Parameters & CRC_13_BBC();
+ static const Parameters & CRC_15();
+ static const Parameters & CRC_15_MPT1327();
+#endif
+ static const Parameters & CRC_16_ARC();
+ static const Parameters & CRC_16_BUYPASS();
+ static const Parameters & CRC_16_CCITTFALSE();
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters & CRC_16_CDMA2000();
+ static const Parameters & CRC_16_CMS();
+ static const Parameters & CRC_16_DECTR();
+ static const Parameters & CRC_16_DECTX();
+ static const Parameters & CRC_16_DNP();
+#endif
+ static const Parameters & CRC_16_GENIBUS();
+ static const Parameters & CRC_16_KERMIT();
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters & CRC_16_MAXIM();
+ static const Parameters & CRC_16_MODBUS();
+ static const Parameters & CRC_16_T10DIF();
+ static const Parameters & CRC_16_USB();
+#endif
+ static const Parameters & CRC_16_X25();
+ static const Parameters & CRC_16_XMODEM();
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters & CRC_17_CAN();
+ static const Parameters & CRC_21_CAN();
+ static const Parameters & CRC_24();
+ static const Parameters & CRC_24_FLEXRAYA();
+ static const Parameters & CRC_24_FLEXRAYB();
+ static const Parameters & CRC_24_LTEA();
+ static const Parameters & CRC_24_LTEB();
+ static const Parameters & CRC_24_NRC();
+ static const Parameters & CRC_30();
+#endif
+ static const Parameters & CRC_32();
+ static const Parameters & CRC_32_BZIP2();
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters & CRC_32_C();
+#endif
+ static const Parameters & CRC_32_MPEG2();
+ static const Parameters & CRC_32_POSIX();
+#ifdef CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
+ static const Parameters & CRC_32_Q();
+ static const Parameters & CRC_40_GSM();
+ static const Parameters & CRC_64();
+#endif
+
+#ifdef CRCPP_USE_CPP11
+ CRC() = delete;
+ CRC(const CRC & other) = delete;
+ CRC & operator=(const CRC & other) = delete;
+ CRC(CRC && other) = delete;
+ CRC & operator=(CRC && other) = delete;
+#endif
+
+private:
+#ifndef CRCPP_USE_CPP11
+ CRC();
+ CRC(const CRC & other);
+ CRC & operator=(const CRC & other);
+#endif
+
+ template
+ static IntegerType Reflect(IntegerType value, crcpp_uint16 numBits);
+
+ template
+ static CRCType Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput);
+
+ template
+ static CRCType UndoFinalize(CRCType remainder, CRCType finalXOR, bool reflectOutput);
+
+ template
+ static CRCType CalculateRemainder(const void * data, crcpp_size size, const Parameters & parameters, CRCType remainder);
+
+ template
+ static CRCType CalculateRemainder(const void * data, crcpp_size size, const Table & lookupTable, CRCType remainder);
+
+ template
+ static CRCType CalculateRemainderBits(unsigned char byte, crcpp_size numBits, const Parameters & parameters, CRCType remainder);
+};
+
+/**
+ @brief Returns a CRC lookup table construct using these CRC parameters.
+ @note This function primarily exists to allow use of the auto keyword instead of instantiating
+ a table directly, since template parameters are not inferred in constructors.
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC lookup table
+*/
+template
+inline CRC::Table CRC::Parameters::MakeTable() const
+{
+ // This should take advantage of RVO and optimize out the copy.
+ return CRC::Table(*this);
+}
+
+/**
+ @brief Constructs a CRC table from a set of CRC parameters
+ @param[in] params CRC parameters
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+*/
+template
+inline CRC::Table::Table(const Parameters & params) :
+ parameters(params)
+{
+ InitTable();
+}
+
+#ifdef CRCPP_USE_CPP11
+/**
+ @brief Constructs a CRC table from a set of CRC parameters
+ @param[in] params CRC parameters
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+*/
+template
+inline CRC::Table::Table(Parameters && params) :
+ parameters(::std::move(params))
+{
+ InitTable();
+}
+#endif
+
+/**
+ @brief Gets the CRC parameters used to construct the CRC table
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC parameters
+*/
+template
+inline const CRC::Parameters & CRC::Table::GetParameters() const
+{
+ return parameters;
+}
+
+/**
+ @brief Gets the CRC table
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC table
+*/
+template
+inline const CRCType * CRC::Table::GetTable() const
+{
+ return table;
+}
+
+/**
+ @brief Gets an entry in the CRC table
+ @param[in] index Index into the CRC table
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC table entry
+*/
+template
+inline CRCType CRC::Table::operator[](unsigned char index) const
+{
+ return table[index];
+}
+
+/**
+ @brief Initializes a CRC table.
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+*/
+template
+inline void CRC::Table::InitTable()
+{
+ // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth)
+ static crcpp_constexpr CRCType BIT_MASK((CRCType(1) << (CRCWidth - CRCType(1))) |
+ ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)));
+
+ // The conditional expression is used to avoid a -Wshift-count-overflow warning.
+ static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ? static_cast(CHAR_BIT - CRCWidth) : 0);
+
+ CRCType crc;
+ unsigned char byte = 0;
+
+ // Loop over each dividend (each possible number storable in an unsigned char)
+ do
+ {
+ crc = CRC::CalculateRemainder(&byte, sizeof(byte), parameters, CRCType(0));
+
+ // This mask might not be necessary; all unit tests pass with this line commented out,
+ // but that might just be a coincidence based on the CRC parameters used for testing.
+ // In any case, this is harmless to leave in and only adds a single machine instruction per loop iteration.
+ crc &= BIT_MASK;
+
+ if (!parameters.reflectInput && CRCWidth < CHAR_BIT)
+ {
+ // Undo the special operation at the end of the CalculateRemainder()
+ // function for non-reflected CRCs < CHAR_BIT.
+ crc = static_cast(crc << SHIFT);
+ }
+
+ table[byte] = crc;
+ }
+ while (++byte);
+}
+
+/**
+ @brief Computes a CRC.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bytes
+ @param[in] parameters CRC parameters
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Parameters & parameters)
+{
+ CRCType remainder = CalculateRemainder(data, size, parameters, parameters.initialValue);
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+/**
+ @brief Appends additional data to a previous CRC calculation.
+ @note This function can be used to compute multi-part CRCs.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bytes
+ @param[in] parameters CRC parameters
+ @param[in] crc CRC from a previous calculation
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Parameters & parameters, CRCType crc)
+{
+ CRCType remainder = UndoFinalize(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+
+ remainder = CalculateRemainder(data, size, parameters, remainder);
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+
+/**
+ @brief Computes a CRC via a lookup table.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bytes
+ @param[in] lookupTable CRC lookup table
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Table & lookupTable)
+{
+ const Parameters & parameters = lookupTable.GetParameters();
+
+ CRCType remainder = CalculateRemainder(data, size, lookupTable, parameters.initialValue);
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+
+/**
+ @brief Appends additional data to a previous CRC calculation using a lookup table.
+ @note This function can be used to compute multi-part CRCs.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bytes
+ @param[in] lookupTable CRC lookup table
+ @param[in] crc CRC from a previous calculation
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::Calculate(const void * data, crcpp_size size, const Table & lookupTable, CRCType crc)
+{
+ const Parameters & parameters = lookupTable.GetParameters();
+
+ CRCType remainder = UndoFinalize(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+
+ remainder = CalculateRemainder(data, size, lookupTable, remainder);
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+
+/**
+ @brief Computes a CRC.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bits
+ @param[in] parameters CRC parameters
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::CalculateBits(const void * data, crcpp_size size, const Parameters & parameters)
+{
+ CRCType remainder = parameters.initialValue;
+
+ // Calculate the remainder on a whole number of bytes first, then call
+ // a special-case function for the remaining bits.
+ crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
+ if (wholeNumberOfBytes > 0)
+ {
+ remainder = CalculateRemainder(data, wholeNumberOfBytes, parameters, remainder);
+ }
+
+ crcpp_size remainingNumberOfBits = size % CHAR_BIT;
+ if (remainingNumberOfBits != 0)
+ {
+ unsigned char lastByte = *(reinterpret_cast(data) + wholeNumberOfBytes);
+ remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
+ }
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+/**
+ @brief Appends additional data to a previous CRC calculation.
+ @note This function can be used to compute multi-part CRCs.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bits
+ @param[in] parameters CRC parameters
+ @param[in] crc CRC from a previous calculation
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::CalculateBits(const void * data, crcpp_size size, const Parameters & parameters, CRCType crc)
+{
+ CRCType remainder = UndoFinalize(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+
+ // Calculate the remainder on a whole number of bytes first, then call
+ // a special-case function for the remaining bits.
+ crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
+ if (wholeNumberOfBytes > 0)
+ {
+ remainder = CalculateRemainder(data, wholeNumberOfBytes, parameters, parameters.initialValue);
+ }
+
+ crcpp_size remainingNumberOfBits = size % CHAR_BIT;
+ if (remainingNumberOfBits != 0)
+ {
+ unsigned char lastByte = *(reinterpret_cast(data) + wholeNumberOfBytes);
+ remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
+ }
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+
+/**
+ @brief Computes a CRC via a lookup table.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bits
+ @param[in] lookupTable CRC lookup table
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::CalculateBits(const void * data, crcpp_size size, const Table & lookupTable)
+{
+ const Parameters & parameters = lookupTable.GetParameters();
+
+ CRCType remainder = parameters.initialValue;
+
+ // Calculate the remainder on a whole number of bytes first, then call
+ // a special-case function for the remaining bits.
+ crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
+ if (wholeNumberOfBytes > 0)
+ {
+ remainder = CalculateRemainder(data, wholeNumberOfBytes, lookupTable, remainder);
+ }
+
+ crcpp_size remainingNumberOfBits = size % CHAR_BIT;
+ if (remainingNumberOfBits != 0)
+ {
+ unsigned char lastByte = *(reinterpret_cast(data) + wholeNumberOfBytes);
+ remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
+ }
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+
+/**
+ @brief Appends additional data to a previous CRC calculation using a lookup table.
+ @note This function can be used to compute multi-part CRCs.
+ @param[in] data Data over which CRC will be computed
+ @param[in] size Size of the data, in bits
+ @param[in] lookupTable CRC lookup table
+ @param[in] crc CRC from a previous calculation
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC
+*/
+template
+inline CRCType CRC::CalculateBits(const void * data, crcpp_size size, const Table & lookupTable, CRCType crc)
+{
+ const Parameters & parameters = lookupTable.GetParameters();
+
+ CRCType remainder = UndoFinalize(crc, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+
+ // Calculate the remainder on a whole number of bytes first, then call
+ // a special-case function for the remaining bits.
+ crcpp_size wholeNumberOfBytes = size / CHAR_BIT;
+ if (wholeNumberOfBytes > 0)
+ {
+ remainder = CalculateRemainder(data, wholeNumberOfBytes, lookupTable, parameters.initialValue);
+ }
+
+ crcpp_size remainingNumberOfBits = size % CHAR_BIT;
+ if (remainingNumberOfBits > 0)
+ {
+ unsigned char lastByte = *(reinterpret_cast(data) + wholeNumberOfBytes);
+ remainder = CalculateRemainderBits(lastByte, remainingNumberOfBits, parameters, remainder);
+ }
+
+ // No need to mask the remainder here; the mask will be applied in the Finalize() function.
+
+ return Finalize(remainder, parameters.finalXOR, parameters.reflectInput != parameters.reflectOutput);
+}
+
+/**
+ @brief Reflects (i.e. reverses the bits within) an integer value.
+ @param[in] value Value to reflect
+ @param[in] numBits Number of bits in the integer which will be reflected
+ @tparam IntegerType Integer type of the value being reflected
+ @return Reflected value
+*/
+template
+inline IntegerType CRC::Reflect(IntegerType value, crcpp_uint16 numBits)
+{
+ IntegerType reversedValue(0);
+
+ for (crcpp_uint16 i = 0; i < numBits; ++i)
+ {
+ reversedValue = static_cast((reversedValue << 1) | (value & 1));
+ value = static_cast(value >> 1);
+ }
+
+ return reversedValue;
+}
+
+/**
+ @brief Computes the final reflection and XOR of a CRC remainder.
+ @param[in] remainder CRC remainder to reflect and XOR
+ @param[in] finalXOR Final value to XOR with the remainder
+ @param[in] reflectOutput true to reflect each byte of the remainder before the XOR
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return Final CRC
+*/
+template
+inline CRCType CRC::Finalize(CRCType remainder, CRCType finalXOR, bool reflectOutput)
+{
+ // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth)
+ static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
+ ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
+
+ if (reflectOutput)
+ {
+ remainder = Reflect(remainder, CRCWidth);
+ }
+
+ return (remainder ^ finalXOR) & BIT_MASK;
+}
+
+/**
+ @brief Undoes the process of computing the final reflection and XOR of a CRC remainder.
+ @note This function allows for computation of multi-part CRCs
+ @note Calling UndoFinalize() followed by Finalize() (or vice versa) will always return the original remainder value:
+
+ CRCType x = ...;
+ CRCType y = Finalize(x, finalXOR, reflectOutput);
+ CRCType z = UndoFinalize(y, finalXOR, reflectOutput);
+ assert(x == z);
+
+ @param[in] crc Reflected and XORed CRC
+ @param[in] finalXOR Final value XORed with the remainder
+ @param[in] reflectOutput true if the remainder is to be reflected
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return Un-finalized CRC remainder
+*/
+template
+inline CRCType CRC::UndoFinalize(CRCType crc, CRCType finalXOR, bool reflectOutput)
+{
+ // For masking off the bits for the CRC (in the event that the number of bits in CRCType is larger than CRCWidth)
+ static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) |
+ ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1));
+
+ crc = (crc & BIT_MASK) ^ finalXOR;
+
+ if (reflectOutput)
+ {
+ crc = Reflect(crc, CRCWidth);
+ }
+
+ return crc;
+}
+
+/**
+ @brief Computes a CRC remainder.
+ @param[in] data Data over which the remainder will be computed
+ @param[in] size Size of the data, in bytes
+ @param[in] parameters CRC parameters
+ @param[in] remainder Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation.
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC remainder
+*/
+template
+inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const Parameters & parameters, CRCType remainder)
+{
+#ifdef CRCPP_USE_CPP11
+ // This static_assert is put here because this function will always be compiled in no matter what
+ // the template parameters are and whether or not a table lookup or bit-by-bit algorithm is used.
+ static_assert(::std::numeric_limits::digits >= CRCWidth, "CRCType is too small to contain a CRC of width CRCWidth.");
+#else
+ // Catching this compile-time error is very important. Sadly, the compiler error will be very cryptic, but it's
+ // better than nothing.
+ enum { static_assert_failed_CRCType_is_too_small_to_contain_a_CRC_of_width_CRCWidth = 1 / (::std::numeric_limits::digits >= CRCWidth ? 1 : 0) };
+#endif
+
+ const unsigned char * current = reinterpret_cast(data);
+
+ // Slightly different implementations based on the parameters. The current implementations try to eliminate as much
+ // computation from the inner loop (looping over each bit) as possible.
+ if (parameters.reflectInput)
+ {
+ CRCType polynomial = CRC::Reflect(parameters.polynomial, CRCWidth);
+ while (size--)
+ {
+ remainder = static_cast(remainder ^ *current++);
+
+ // An optimizing compiler might choose to unroll this loop.
+ for (crcpp_size i = 0; i < CHAR_BIT; ++i)
+ {
+#ifdef CRCPP_BRANCHLESS
+ // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following:
+ // if (remainder & 1)
+ // remainder = (remainder >> 1) ^ polynomial;
+ // else
+ // remainder >>= 1;
+ remainder = static_cast((remainder >> 1) ^ ((remainder & 1) * polynomial));
+#else
+ remainder = static_cast((remainder & 1) ? ((remainder >> 1) ^ polynomial) : (remainder >> 1));
+#endif
+ }
+ }
+ }
+ else if (CRCWidth >= CHAR_BIT)
+ {
+ static crcpp_constexpr CRCType CRC_WIDTH_MINUS_ONE(CRCWidth - CRCType(1));
+#ifndef CRCPP_BRANCHLESS
+ static crcpp_constexpr CRCType CRC_HIGHEST_BIT_MASK(CRCType(1) << CRC_WIDTH_MINUS_ONE);
+#endif
+ // The conditional expression is used to avoid a -Wshift-count-overflow warning.
+ static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ? static_cast(CRCWidth - CHAR_BIT) : 0);
+
+ while (size--)
+ {
+ remainder = static_cast(remainder ^ (static_cast(*current++) << SHIFT));
+
+ // An optimizing compiler might choose to unroll this loop.
+ for (crcpp_size i = 0; i < CHAR_BIT; ++i)
+ {
+#ifdef CRCPP_BRANCHLESS
+ // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following:
+ // if (remainder & CRC_HIGHEST_BIT_MASK)
+ // remainder = (remainder << 1) ^ parameters.polynomial;
+ // else
+ // remainder <<= 1;
+ remainder = static_cast((remainder << 1) ^ (((remainder >> CRC_WIDTH_MINUS_ONE) & 1) * parameters.polynomial));
+#else
+ remainder = static_cast((remainder & CRC_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ parameters.polynomial) : (remainder << 1));
+#endif
+ }
+ }
+ }
+ else
+ {
+ static crcpp_constexpr CRCType CHAR_BIT_MINUS_ONE(CHAR_BIT - 1);
+#ifndef CRCPP_BRANCHLESS
+ static crcpp_constexpr CRCType CHAR_BIT_HIGHEST_BIT_MASK(CRCType(1) << CHAR_BIT_MINUS_ONE);
+#endif
+ // The conditional expression is used to avoid a -Wshift-count-overflow warning.
+ static crcpp_constexpr CRCType SHIFT((CHAR_BIT >= CRCWidth) ? static_cast(CHAR_BIT - CRCWidth) : 0);
+
+ CRCType polynomial = static_cast(parameters.polynomial << SHIFT);
+ remainder = static_cast(remainder << SHIFT);
+
+ while (size--)
+ {
+ remainder = static_cast(remainder ^ *current++);
+
+ // An optimizing compiler might choose to unroll this loop.
+ for (crcpp_size i = 0; i < CHAR_BIT; ++i)
+ {
+#ifdef CRCPP_BRANCHLESS
+ // Clever way to avoid a branch at the expense of a multiplication. This code is equivalent to the following:
+ // if (remainder & CHAR_BIT_HIGHEST_BIT_MASK)
+ // remainder = (remainder << 1) ^ polynomial;
+ // else
+ // remainder <<= 1;
+ remainder = static_cast((remainder << 1) ^ (((remainder >> CHAR_BIT_MINUS_ONE) & 1) * polynomial));
+#else
+ remainder = static_cast((remainder & CHAR_BIT_HIGHEST_BIT_MASK) ? ((remainder << 1) ^ polynomial) : (remainder << 1));
+#endif
+ }
+ }
+
+ remainder = static_cast(remainder >> SHIFT);
+ }
+
+ return remainder;
+}
+
+/**
+ @brief Computes a CRC remainder using lookup table.
+ @param[in] data Data over which the remainder will be computed
+ @param[in] size Size of the data, in bytes
+ @param[in] lookupTable CRC lookup table
+ @param[in] remainder Running CRC remainder. Can be an initial value or the result of a previous CRC remainder calculation.
+ @tparam CRCType Integer type for storing the CRC result
+ @tparam CRCWidth Number of bits in the CRC
+ @return CRC remainder
+*/
+template
+inline CRCType CRC::CalculateRemainder(const void * data, crcpp_size size, const Table & lookupTable, CRCType remainder)
+{
+ const unsigned char * current = reinterpret_cast(data);
+
+ if (lookupTable.GetParameters().reflectInput)
+ {
+ while (size--)
+ {
+#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
+ // Disable warning about data loss when doing (remainder >> CHAR_BIT) when
+ // remainder is one byte long. The algorithm is still correct in this case,
+ // though it's possible that one additional machine instruction will be executed.
+# pragma warning (push)
+# pragma warning (disable : 4333)
+#endif
+ remainder = static_cast((remainder >> CHAR_BIT) ^ lookupTable[static_cast(remainder ^ *current++)]);
+#if defined(WIN32) || defined(_WIN32) || defined(WINCE)
+# pragma warning (pop)
+#endif
+ }
+ }
+ else if (CRCWidth >= CHAR_BIT)
+ {
+ // The conditional expression is used to avoid a -Wshift-count-overflow warning.
+ static crcpp_constexpr CRCType SHIFT((CRCWidth >= CHAR_BIT) ? static_cast(CRCWidth - CHAR_BIT) : 0);
+
+ while (size--)
+ {
+ remainder = static_cast