Skip to content

Commit

Permalink
adding contact information to getRobotCB
Browse files Browse the repository at this point in the history
  • Loading branch information
jvarley committed Aug 23, 2017
1 parent c0f99f1 commit aec81ab
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ find_package(graspit)
SearchSpace.msg
SearchContact.msg
Energy.msg
Contact.msg
)

## Generate services in the 'srv' folder
Expand Down
8 changes: 8 additions & 0 deletions msg/Contact.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
string body1
string body2

geometry_msgs/Point position # in body1 frame.

float64 cof # coefficient of friction.


1 change: 1 addition & 0 deletions msg/Robot.msg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ std_msgs/Header header
geometry_msgs/Pose pose
sensor_msgs/JointState[] joints
float64[] dofs
Contact[] contacts
22 changes: 19 additions & 3 deletions src/graspit_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,25 @@ bool GraspitInterface::getRobotCB(graspit_interface::GetRobot::Request &request,
pose.orientation.w = t.rotation().w();
pose.orientation.x = t.rotation().x();
pose.orientation.y = t.rotation().y();
pose.orientation.z = t.rotation().z();

response.robot.pose = pose;
pose.orientation.z = t.rotation().z();

response.robot.pose = pose;

// Info for all contacts with this robot:
std::list<Contact*> contacts = r->getContacts();
for (std::list<Contact*>::iterator it = contacts.begin();
it != contacts.end(); it++) {
graspit_interface::Contact c;
c.body1 = (*it)->getBody1()->getName().toStdString();
c.body2 = (*it)->getBody2()->getName().toStdString();

position p = (*it)->getPosition();
c.position.x = p.x() * 0.001;
c.position.y = p.y() * 0.001;
c.position.z = p.z() * 0.001;
c.cof = (*it)->getCof();
response.robot.contacts.push_back(c);
}

for (int i=0; i < r->getNumJoints(); i++) {
sensor_msgs::JointState robot_joint_state = sensor_msgs::JointState();
Expand Down

0 comments on commit aec81ab

Please sign in to comment.