Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <srs_interaction_primitives/update_publisher.h>
00029
00030 using namespace std;
00031 using namespace interactive_markers;
00032 using namespace visualization_msgs;
00033 using namespace geometry_msgs;
00034 using namespace std_msgs;
00035
00036
00037 namespace srs_interaction_primitives
00038 {
00039
00040 UpdatePublisher::UpdatePublisher(std::string name, int type)
00041 {
00042 im_name_ = name;
00043 im_type_ = type;
00044
00045 poseChangedPublisher_ = nh_.advertise<srs_interaction_primitives::PoseChanged> (BUT_PoseChanged_TOPIC(im_name_),
00046 BUFFER_SIZE);
00047 scaleChangedPublisher_ = nh_.advertise<srs_interaction_primitives::ScaleChanged> (BUT_ScaleChanged_TOPIC(im_name_),
00048 BUFFER_SIZE);
00049 menuClickedPublisher_ = nh_.advertise<srs_interaction_primitives::MenuClicked> (BUT_MenuClicked_TOPIC(im_name_),
00050 BUFFER_SIZE);
00051
00052 switch (im_type_)
00053 {
00054 case srs_interaction_primitives::PrimitiveType::BILLBOARD:
00055 movementChangedPublisher_
00056 = nh_.advertise<srs_interaction_primitives::MovementChanged> (BUT_MovementChanged_TOPIC(im_name_),
00057 BUFFER_SIZE);
00058 break;
00059 case srs_interaction_primitives::PrimitiveType::PLANE:
00060 tagChangedPublisher_ = nh_.advertise<srs_interaction_primitives::TagChanged> (BUT_TagChanged_TOPIC(im_name_),
00061 BUFFER_SIZE);
00062 break;
00063 case srs_interaction_primitives::PrimitiveType::OBJECT:
00064 moveArmToPreGraspPublisher_
00065 = nh_.advertise<srs_interaction_primitives::MoveArmToPreGrasp> (BUT_MoveArmToPreGrasp_TOPIC(im_name_),
00066 BUFFER_SIZE);
00067 break;
00068 }
00069 }
00070
00071 std::string UpdatePublisher::getUpdateTopic(int update_type)
00072 {
00073 std::string topic;
00074 switch (update_type)
00075 {
00076 case UPDATE_SCALE:
00077 topic = scaleChangedPublisher_.getTopic();
00078 break;
00079 case UPDATE_POSE:
00080 topic = poseChangedPublisher_.getTopic();
00081 break;
00082 case MENU_CLICKED:
00083 topic = menuClickedPublisher_.getTopic();
00084 break;
00085 case MOVEMENT_CHANGED:
00086 topic = movementChangedPublisher_.getTopic();
00087 break;
00088 case TAG_CHANGED:
00089 topic = tagChangedPublisher_.getTopic();
00090 break;
00091 case MOVE_ARM_TO_PREGRASP:
00092 topic = moveArmToPreGraspPublisher_.getTopic();
00093 default:
00094 topic = "";
00095 break;
00096 }
00097
00098 if (topic == "")
00099 ROS_WARN("No update topic of type %d for marker of type %d!", update_type, im_type_);
00100 return topic;
00101 }
00102
00103 void UpdatePublisher::publishScaleChanged(geometry_msgs::Vector3 new_scale, geometry_msgs::Vector3 scale_change)
00104 {
00105 srs_interaction_primitives::ScaleChanged scaleChangedMsg;
00106 scaleChangedMsg.marker_name = im_name_;
00107 scaleChangedMsg.new_scale = new_scale;
00108 scaleChangedMsg.scale_change = scale_change;
00109 scaleChangedPublisher_.publish(scaleChangedMsg);
00110 }
00111
00112 void UpdatePublisher::publishPoseChanged(geometry_msgs::Pose new_pose, geometry_msgs::Pose pose_change)
00113 {
00114 srs_interaction_primitives::PoseChanged poseChangedMsg;
00115 poseChangedMsg.marker_name = im_name_;
00116 poseChangedMsg.new_pose = new_pose;
00117 poseChangedMsg.pose_change = pose_change;
00118 poseChangedPublisher_.publish(poseChangedMsg);
00119 }
00120
00121 void UpdatePublisher::publishMenuClicked(std::string title, interactive_markers::MenuHandler::CheckState state)
00122 {
00123 srs_interaction_primitives::MenuClicked menuClickedMsg;
00124 menuClickedMsg.marker_name = im_name_;
00125 menuClickedMsg.menu_title = title;
00126 menuClickedMsg.state = state;
00127 menuClickedPublisher_.publish(menuClickedMsg);
00128 }
00129
00130 void UpdatePublisher::publishMovementChanged(geometry_msgs::Quaternion new_direction,
00131 geometry_msgs::Quaternion direction_change, float new_velocity,
00132 float velocity_change)
00133 {
00134 srs_interaction_primitives::MovementChanged movementChangedMsg;
00135 movementChangedMsg.marker_name = im_name_;
00136 movementChangedMsg.new_direction = new_direction;
00137 movementChangedMsg.direction_change = direction_change;
00138 movementChangedMsg.new_velocity = new_velocity;
00139 movementChangedMsg.velocity_change = velocity_change;
00140 movementChangedPublisher_.publish(movementChangedMsg);
00141 }
00142
00143 void UpdatePublisher::publishTagChanged(std::string new_tag)
00144 {
00145 srs_interaction_primitives::TagChanged tagChangedMsg;
00146 tagChangedMsg.marker_name = im_name_;
00147 tagChangedMsg.new_tag = new_tag;
00148 tagChangedPublisher_.publish(tagChangedMsg);
00149 }
00150
00151 void UpdatePublisher::publishMoveArmToPreGrasp(int pos_id)
00152 {
00153 srs_interaction_primitives::MoveArmToPreGrasp msg;
00154 msg.marker_name = im_name_;
00155 msg.pos_id = pos_id;
00156 moveArmToPreGraspPublisher_.publish(msg);
00157 }
00158
00159 }