spirecv-ros code framework
spirecv ros mainly provides gimbal related functions such as rotation control and status reading. All of these functions expose external interfaces through ROS topics and servic…
1 min read · English documentation
spirecv-ros mainly provides gimbal-related functions such as rotation control and status reading. All of these functions expose external interfaces through ROS topics and services. The source code is located in the gimbal_server.cpp file.
Topics
[Publish] Gimbal status information
Topic: /uav*/gimbal/state (prometheus_msgs/GimbalState)
Corresponding code:
const std::string ns = "/uav" + std::to_string(uav_id_);
gimbal_state_topic_ = ns + "/gimbal/state";
state_pub_ = create_publisher<prometheus_msgs::msg::GimbalState>(
gimbal_state_topic_, rclcpp::QoS(10));
[Subscribe] Gimbal control command
Topic: /uav*/gimbal/control (prometheus_msgs/GimbalControl)
Corresponding code:
const std::string ns = "/uav" + std::to_string(uav_id_);
gimbal_control_topic_ = ns + "/gimbal/control";
control_sub_ = create_subscription<prometheus_msgs::msg::GimbalControl>(
gimbal_control_topic_, rclcpp::QoS(10),
std::bind(&GimbalServerNode::onGimbalControl, this, std::placeholders::_1));
Services
[Service] Gimbal photo capture service
Service: /uav*/gimbal_take_server (std_srvs/SetBool)
Corresponding code:
using std::placeholders::_1;
using std::placeholders::_2;
const std::string ns = "/uav" + std::to_string(uav_id_);
gimbal_take_photo_server_name_ = ns + "/gimbal_take_server";
gimbal_take_photo_service_ = create_service<std_srvs::srv::SetBool>(
gimbal_take_photo_server_name_,
std::bind(&GimbalServerNode::onGimbalTakePhoto, this, _1, _2));
Each time true is sent, the gimbal takes one photo. This service requires supported gimbal hardware. The captured photos are saved to the gimbal's SD card. Currently supported gimbal: GX40.
[Service] Gimbal video recording service
Service: /uav*/gimbal_record_server (std_srvs/SetBool)
Corresponding code:
const std::string ns = "/uav" + std::to_string(uav_id_);
gimbal_record_server_name_ = ns + "/gimbal_record_server";
gimbal_record_service_ = create_service<std_srvs::srv::SetBool>(
gimbal_record_server_name_,
std::bind(&GimbalServerNode::onGimbalRecord, this, _1, _2));
Sending true for the first time starts recording, and sending true for the second time stops recording. This service requires supported gimbal hardware. The recorded videos are saved to the gimbal's SD card. Currently supported gimbal: GX40.
Messages
The message files are located at:
/home/amov/机型_experiment/src/Prometheus/Modules/common/prometheus_msgs/msg
GimbalState.msg (gimbal status message)
std_msgs/Header header
# gimbal type; value = {SV::GimbalType};0:G1;1:Q10F;2:AT10;3:GX40;4:SU17
uint8 type
# gimbal movement mode; 0:None; 1:lock head; 2:unlock head; 3:tracking
uint8 move_mode
# gimbal image type; 0:normal; 1:infrared; 2:merge
uint8 image_mode
# gimbal zoom
bool is_zoom
# gimbal rec; 0:none; 1:gimbal rec; 2:local rec; 3:gimbal & local rec
uint8 is_rec
# gimbal fov, XY
float32[2] fov
# gimbal real time angle, RPY <deg>
float32[3] angle_rt
# gimbal real time angle rate, RPY <deg/s> <if gimbal supported>
float32[3] angle_rt_rate
# gimbal setted max angle rate <deg/s> <if gimbal supported>
float32[3] angle_rate_set
# gimbal follow the track result; 0:false; 1:three angle; 3:only pitch
uint8 gimbal_follow_track_res_mode
GimbalControl.msg (gimbal control message)
std_msgs/Header header
# gimbal control mode; 0:None; 1:speed; 2:angle; 3:mixed
uint8 mode
# RPY <deg>
float32[3] angle
# RPY <deg/s>
float32[3] speed
