Skip to content

Commit

Permalink
making the picture taking stop when the goal is cancelled; increasing…
Browse files Browse the repository at this point in the history
… the inspection too timeout (#150)
  • Loading branch information
marinagmoreira authored Feb 27, 2024
1 parent 3cc0cd9 commit 7c1f38e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
29 changes: 24 additions & 5 deletions astrobee/behaviors/inspection/src/inspection_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ class InspectionNode : public ff_util::FreeFlyerNodelet {
goal.type = isaac_msgs::ImageInspectionGoal::VENT;
client_i_.SendGoal(goal);
}
finished_anomaly_ = false;

// Allow image to stabilize
ros::Duration(cfg_.Get<double>("station_time")).sleep();
Expand All @@ -531,7 +532,7 @@ class InspectionNode : public ff_util::FreeFlyerNodelet {
flashlight_intensity_current_ = 0.0;

// Signal an imminent sci cam image
sci_cam_req_ = sci_cam_req_ + 1;
sci_cam_req_ += 1;

// Send the command
SendPicture(focus_distance_calculated_);
Expand All @@ -546,12 +547,16 @@ class InspectionNode : public ff_util::FreeFlyerNodelet {
// Clear local variables
sci_cam_timeout_.stop();
sci_cam_req_ = 0;

// If the action was cancelled stop taking more pictures
if (fsm_.GetState() == STATE::WAITING) return;

result_.inspection_result.push_back(isaac_msgs::InspectionResult::PIC_ACQUIRED);
result_.picture_time.push_back(msg->header.stamp);
ros::Duration(cfg_.Get<double>("station_time")).sleep();

if (goal_.command == isaac_msgs::InspectionGoal::ANOMALY) {
ROS_DEBUG_STREAM("Scicam picture acquired - Timestamp: " << msg->header.stamp
ROS_INFO_STREAM("Scicam picture acquired - Timestamp: " << msg->header.stamp
<< ", Focus distance (m): " << focus_distance_current_
<< ", Focal distance : " << 1.6 * std::pow(focus_distance_current_, -1.41)
<< ", Flashlight: " << flashlight_intensity_current_);
Expand All @@ -568,9 +573,13 @@ class InspectionNode : public ff_util::FreeFlyerNodelet {
} else if (focus_distance_current_ <
cfg_.Get<double>("target_distance") + cfg_.Get<double>("focus_distance_range") - EPS) {
focus_distance_current_ += cfg_.Get<double>("focus_distance_step");
} else {
// Finish inspection
} else if (!ground_active_ || finished_anomaly_) {
// If no anomaly detectiuon active or if anomaly detection finished, go to next inspection
finished_anomaly_ = false;
return fsm_.Update(NEXT_INSPECT);
} else {
// When the anomaly detection returns a result it will go to the next inspection
finished_anomaly_ = true;
}
}
sci_cam_req_ = 1;
Expand Down Expand Up @@ -608,7 +617,16 @@ class InspectionNode : public ff_util::FreeFlyerNodelet {
result_.anomaly_result.push_back(result->anomaly_result);
else
ROS_INFO_STREAM("Invalid result received Image Analysis");
return fsm_.Update(NEXT_INSPECT);

// If we finished taking pictures, go to next inspection
// If not, return and when the pictures are all taken, it go to the next inspection
if (finished_anomaly_) {
finished_anomaly_ = false;
return fsm_.Update(NEXT_INSPECT);
} else {
finished_anomaly_ = true;
return;
}
}

// INSPECTION ACTION SERVER
Expand Down Expand Up @@ -886,6 +904,7 @@ class InspectionNode : public ff_util::FreeFlyerNodelet {
int sci_cam_req_ = 0;
bool ground_active_ = false;
bool sim_mode_ = false;
bool finished_anomaly_ = false;

// Inspection library
Inspection* inspection_;
Expand Down
2 changes: 1 addition & 1 deletion astrobee/behaviors/inspection/tools/inspection_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ DEFINE_string(volumetric_poses, "/resources/volumetric_iss.txt", "Wifi poses lis
// Timeout values for action
DEFINE_double(connect, 10.0, "Action connect timeout");
DEFINE_double(active, 10.0, "Action active timeout");
DEFINE_double(response, 200.0, "Action response timeout");
DEFINE_double(response, 500.0, "Action response timeout");
DEFINE_double(deadline, -1.0, "Action deadline timeout");

// Match the internal states and responses with the message definition
Expand Down

0 comments on commit 7c1f38e

Please sign in to comment.