Drawing the PR2 gripper in Rviz
I'm trying to draw an interactive marker that shows the PR2 gripper. I've found this C++ code in the interactive_marker_helpers package (object_manipulation stack), file interactive_marker_helpers.cpp.
visualization_msgs::InteractiveMarker makeGripperMarker( const char *name, const geometry_msgs::PoseStamped &stamped,
float scale, float angle, bool view_facing, std_msgs::ColorRGBA color, bool use_color )
{
visualization_msgs::InteractiveMarker int_marker;
int_marker.header = stamped.header;
int_marker.name = name;
int_marker.scale = 1.0; //scale;
int_marker.pose = stamped.pose;
// add6DofControl(int_marker, false);
visualization_msgs::InteractiveMarkerControl control;
visualization_msgs::Marker mesh;
mesh.mesh_use_embedded_materials = !use_color;
mesh.type = visualization_msgs::Marker::MESH_RESOURCE;
mesh.scale.x = scale;
mesh.scale.y = scale;
mesh.scale.z = scale;
mesh.color = color;
tf::Transform T1, T2;
tf::Transform T_proximal, T_distal;
T1.setOrigin(tf::Vector3(0.07691, 0.01, 0));
T1.setRotation(tf::Quaternion(tf::Vector3(0,0,1), angle));
T2.setOrigin(tf::Vector3(0.09137, 0.00495, 0));
T2.setRotation(tf::Quaternion(tf::Vector3(0,0,1), -angle));
T_proximal = T1;
T_distal = T1 * T2;
mesh.mesh_resource = "package://pr2_description/meshes/gripper_v0/gripper_palm.dae";
mesh.pose.orientation.w = 1;
control.markers.push_back( mesh );
mesh.mesh_resource = "package://pr2_description/meshes/gripper_v0/l_finger.dae";
mesh.pose = object_manipulator::msg::createPoseMsg(T_proximal);
control.markers.push_back( mesh );
mesh.mesh_resource = "package://pr2_description/meshes/gripper_v0/l_finger_tip.dae";
mesh.pose = object_manipulator::msg::createPoseMsg(T_distal);
control.markers.push_back( mesh );
T1.setOrigin(tf::Vector3(0.07691, -0.01, 0));
T1.setRotation(tf::Quaternion(tf::Vector3(1,0,0), M_PI)*tf::Quaternion(tf::Vector3(0,0,1), angle));
T2.setOrigin(tf::Vector3(0.09137, 0.00495, 0));
T2.setRotation(tf::Quaternion(tf::Vector3(0,0,1), -angle));
T_proximal = T1;
T_distal = T1 * T2;
mesh.mesh_resource = "package://pr2_description/meshes/gripper_v0/l_finger.dae";
mesh.pose = object_manipulator::msg::createPoseMsg(T_proximal);
control.markers.push_back( mesh );
mesh.mesh_resource = "package://pr2_description/meshes/gripper_v0/l_finger_tip.dae";
mesh.pose = object_manipulator::msg::createPoseMsg(T_distal);
control.markers.push_back( mesh );
control.interaction_mode = visualization_msgs::InteractiveMarkerControl::BUTTON;
int_marker.controls.push_back( control );
return int_marker;
}
I am translating this code to Python, but tf lacks the Transform class. Is there any replacement for Transform class in Python? Does anybody have a piece of Python code that draws a gripper in Rviz?