Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
bostoncleek committed Jan 10, 2022
1 parent 708ae00 commit 86466cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion moveit_task_constructor_dexnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ find_package(catkin REQUIRED COMPONENTS

# System dependencies are found with CMake's conventions
find_package(Eigen3 REQUIRED)
find_package(OpenCV 3.2 REQUIRED)
find_package(OpenCV REQUIRED)

# Service files
add_service_files(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <Eigen/Geometry>

// Action Server
#include <moveit_task_constructor_msgs/SampleGraspPosesAction.h>
#include <grasping_msgs/GraspPlanningAction.h>
#include <actionlib/server/simple_action_server.h>

namespace moveit_task_constructor_dexnet
Expand Down Expand Up @@ -107,10 +107,9 @@ class GraspDetection
ros::ServiceClient gqcnn_client_; // gqcnn service client
ros::ServiceClient image_client_; // image saving service client

std::unique_ptr<actionlib::SimpleActionServer<moveit_task_constructor_msgs::SampleGraspPosesAction>>
server_; // action server
moveit_task_constructor_msgs::SampleGraspPosesFeedback feedback_; // action feedback message
moveit_task_constructor_msgs::SampleGraspPosesResult result_; // action result message
std::unique_ptr<actionlib::SimpleActionServer<grasping_msgs::GraspPlanningAction>> server_; // action server
grasping_msgs::GraspPlanningFeedback feedback_; // action feedback message
grasping_msgs::GraspPlanningResult result_; // action result message

std::string goal_name_; // action name
std::string action_name_; // action namespace
Expand Down
18 changes: 7 additions & 11 deletions moveit_task_constructor_dexnet/src/grasp_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ void GraspDetection::loadParameters()
void GraspDetection::init()
{
// action server
server_.reset(new actionlib::SimpleActionServer<moveit_task_constructor_msgs::SampleGraspPosesAction>(
nh_, action_name_, false));
server_.reset(new actionlib::SimpleActionServer<grasping_msgs::GraspPlanningAction>(nh_, action_name_, false));
server_->registerGoalCallback(std::bind(&GraspDetection::goalCallback, this));
server_->registerPreemptCallback(std::bind(&GraspDetection::preemptCallback, this));
server_->start();
Expand All @@ -101,7 +100,7 @@ void GraspDetection::init()

void GraspDetection::goalCallback()
{
goal_name_ = server_->acceptNewGoal()->action_name;
goal_name_ = server_->acceptNewGoal()->object.name;
ROS_INFO_NAMED(LOGNAME, "New goal accepted: %s", goal_name_.c_str());

// save images
Expand Down Expand Up @@ -159,7 +158,6 @@ void GraspDetection::sampleGrasps()
if (grasp_candidates.empty())
{
ROS_ERROR_NAMED(LOGNAME, "No grasp candidates found");
result_.grasp_state = "failed";
server_->setAborted(result_);
return;
}
Expand Down Expand Up @@ -193,24 +191,22 @@ void GraspDetection::sampleGrasps()
grasp_pose.pose.orientation.z = rot.z();

// send feedback to action client
feedback_.grasp_candidates.emplace_back(grasp_pose);
moveit_msgs::Grasp current_grasp;
current_grasp.grasp_pose = grasp_pose;

// Q_value (probability of success)
// cost = 1.0 - Q_value, to represent cost
const double cost = 1.0 - q_values.at(i);
// ROS_INFO_NAMED(LOGNAME, "ID: %u Cost: %f", i, cost);
feedback_.costs.emplace_back(cost);
current_grasp.grasp_quality = 1.0 - q_values.at(i);

feedback_.grasps.emplace_back(current_grasp);
}

server_->publishFeedback(feedback_);
result_.grasp_state = "success";
server_->setSucceeded(result_);
}

else
{
ROS_ERROR_NAMED(LOGNAME, "Failed to call gqcnn_grasp service");
result_.grasp_state = "failed";
server_->setAborted(result_);
}
}
Expand Down

0 comments on commit 86466cf

Please sign in to comment.