Skip to content

Commit d5edb32

Browse files
committed
Исправил ошибку с флагами
Исправил ошибки с вёдрами Добавил сценарий для только столбиков
1 parent 3bca940 commit d5edb32

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

src/sauvc_missions/configs/missions/flares.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ states:
2222
max_yaw: 360
2323
yaw_step: 30.0
2424
surge: 30.0
25-
avoid_sway: 0.0
25+
avoid_sway: -50
26+
sway: 0
2627
depth: 1.5
2728
roll: 0.0
2829
pitch: 0.0

src/sauvc_missions/configs/missions/hydroacoustic_bowl.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ states:
2828
bbox_name: red_bowl
2929
bbox_topic: /stingray/topics/front_camera/bbox_array
3030
hydroacoustic_topic: /stingray/topics/angle_hydroacoustic
31-
angle_threshold: 10.0
32-
distance_threshold: 2.0
31+
angle_threshold: 2.0
32+
distance_threshold: 1.2
3333
lost_threshold: 30
3434
surge: 50.0
3535
sway: 0.0
@@ -54,7 +54,7 @@ states:
5454
roll: 0.0
5555
pitch: 0.0
5656
yaw: 0.0
57-
duration: 4.0
57+
duration: 5.0
5858
DROPPER_OPEN:
5959
action:
6060
type: SetDeviceValue
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
initial: INIT
2+
ok_state_package_name: stingray_missions
3+
failed_state_package_name: stingray_missions
4+
abort_state_package_name: stingray_missions
5+
missions:
6+
INIT:
7+
config_name: init
8+
package_name: stingray_missions
9+
FLARES:
10+
config_name: flares
11+
package_name: sauvc_missions
12+
13+
transitions:
14+
- { source: INIT, outcome: OK, dest: FLARES }
15+
- { source: FLARES, outcome: OK, dest: OK }
16+
- { source: [INIT, FLARES], outcome: FAILED, dest: FAILED }

src/sauvc_movement/src/HydroacousticCenteringTwistActionServer.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ HydroacousticCenteringTwistActionServer::HydroacousticCenteringTwistActionServer
1111
void HydroacousticCenteringTwistActionServer::bboxArrayCallback(const stingray_interfaces::msg::BboxArray &msg) {
1212
bool found_target = false;
1313
for (auto bbox : msg.bboxes) {
14-
if (bbox.name == target_bbox_name && abs(bbox.horizontal_angle) < target_angle_threshold && abs(bbox.horizontal_angle) < abs(current_target_bbox.horizontal_angle)) {
14+
if (bbox.name == target_bbox_name) {//} && abs(bbox.horizontal_angle) < target_angle_threshold && abs(bbox.horizontal_angle) < abs(current_target_bbox.horizontal_angle)) {
1515
current_target_bbox = bbox;
1616
found_target = true;
1717
target_disappeared_counter = 0;
@@ -61,13 +61,6 @@ void HydroacousticCenteringTwistActionServer::execute(const std::shared_ptr<rclc
6161
auto goal_result = std::make_shared<sauvc_interfaces::action::HydroacousticCenteringTwistAction::Result>();
6262
goal_result->success = false;
6363

64-
bboxArraySub = _node->create_subscription<stingray_interfaces::msg::BboxArray>(
65-
goal->bbox_topic, 10,
66-
std::bind(&HydroacousticCenteringTwistActionServer::bboxArrayCallback, this, std::placeholders::_1));
67-
68-
angleHydroacousticSub = _node->create_subscription<std_msgs::msg::Float32>(goal->hydroacoustic_topic, 10,
69-
std::bind(&HydroacousticCenteringTwistActionServer::hydroacousticCallback, this, std::placeholders::_1));
70-
7164
// check duration
7265
if (goal->duration < 0.0) {
7366
goal_result->success = false;
@@ -76,6 +69,13 @@ void HydroacousticCenteringTwistActionServer::execute(const std::shared_ptr<rclc
7669
return;
7770
}
7871

72+
bboxArraySub = _node->create_subscription<stingray_interfaces::msg::BboxArray>(
73+
goal->bbox_topic, 10,
74+
std::bind(&HydroacousticCenteringTwistActionServer::bboxArrayCallback, this, std::placeholders::_1));
75+
76+
angleHydroacousticSub = _node->create_subscription<std_msgs::msg::Float32>(goal->hydroacoustic_topic, 10,
77+
std::bind(&HydroacousticCenteringTwistActionServer::hydroacousticCallback, this, std::placeholders::_1));
78+
7979
// send service request
8080
target_bbox_name = goal->bbox_name;
8181
target_distance_threshold = goal->distance_threshold;
@@ -102,18 +102,34 @@ void HydroacousticCenteringTwistActionServer::execute(const std::shared_ptr<rclc
102102

103103
if (isTwistDone(goal) && isCenteringTwistDone()) {
104104
RCLCPP_INFO(_node->get_logger(), "Twist done, target distance: %f, closer than: %f", current_target_bbox.pos_z, target_distance_threshold);
105+
twistSrvRequest->surge = 0;
106+
//break;
107+
}
108+
109+
if (isTwistDone(goal) && isCenteringTwistDone() && abs(current_uv_state.yaw - twistSrvRequest->yaw) < goal->angle_threshold) {
110+
RCLCPP_INFO(_node->get_logger(), "Centering done, current yaw: %f, pinger agnle: %f", current_uv_state.yaw, current_hydroacoustic_angle);
111+
twistSrvRequest->surge = 0;
105112
break;
106113
}
107-
twistSrvRequest->yaw = current_hydroacoustic_angle;
114+
115+
twistSrvRequest->yaw = current_uv_state.yaw + current_hydroacoustic_angle;
108116
RCLCPP_INFO(_node->get_logger(), "Twist action current yaw: %f, request diff: %f, surge: %f", current_uv_state.yaw, twistSrvRequest->yaw, twistSrvRequest->surge);
117+
RCLCPP_INFO(_node->get_logger(), "Pure current_hydroacoustic_angle: %f", current_hydroacoustic_angle);
109118
// check if service success
110119
twistSrvClient->async_send_request(twistSrvRequest).wait();
111-
twistSrvRequest->yaw = 0.0;
120+
// twistSrvRequest->yaw = 0.0;
112121

113122
if (goal_handle->is_canceling()) {
114123
goal_result->success = false;
115124
RCLCPP_INFO(_node->get_logger(), "Goal canceled");
116125
goal_handle->canceled(goal_result);
126+
127+
target_disappeared_counter = 0;
128+
target_bbox_name = "";
129+
angleHydroacousticSub.reset();
130+
bboxArraySub.reset();
131+
// stop maneuvr service request
132+
stopTwist(twistSrvRequest);
117133
return;
118134
}
119135
// rclcpp::spin_some(_node);

0 commit comments

Comments
 (0)