34 #ifndef BIN_POSE_EMULATOR_CPP 35 #define BIN_POSE_EMULATOR_CPP 45 nh->
advertise<visualization_msgs::Marker>(
"bin_pose_visualization", 1);
47 ROS_INFO(
"Bin Pose Emulator Ready!");
53 bin_pose_msgs::bin_pose::Response& res)
58 geometry_msgs::Pose grasp_pose;
74 grasp_orientation.
setRPY(grasp_roll, grasp_pitch, grasp_yaw);
75 grasp_pose.orientation.x = grasp_orientation.getX();
76 grasp_pose.orientation.y = grasp_orientation.getY();
77 grasp_pose.orientation.z = grasp_orientation.getZ();
78 grasp_pose.orientation.w = grasp_orientation.
getW();
80 res.grasp_pose = grasp_pose;
84 geometry_msgs::Pose approach_pose;
89 approach_pose.position.x =
91 approach_pose.position.y =
93 approach_pose.position.z =
96 approach_pose.orientation = grasp_pose.orientation;
97 res.approach_pose = approach_pose;
101 geometry_msgs::Pose deapproach_pose;
103 deapproach_pose = grasp_pose;
104 deapproach_pose.position.z =
111 res.deapproach_pose = deapproach_pose;
118 double f = (double)rand() / RAND_MAX;
119 return fMin + f * (fMax - fMin);
126 YAML::Node config_file = YAML::LoadFile(filepath);
146 catch (YAML::ParserException& e)
148 ROS_ERROR(
"Error reading yaml config file");
154 uint32_t shape = visualization_msgs::Marker::CUBE;
155 visualization_msgs::Marker marker;
157 marker.header.frame_id =
"/base_link";
163 marker.action = visualization_msgs::Marker::ADD;
173 marker.color.r = 0.8f;
174 marker.color.g = 0.0f;
175 marker.color.b = 0.8f;
176 marker.color.a = 0.5;
183 geometry_msgs::Pose approach_pose)
185 uint32_t shape = visualization_msgs::Marker::ARROW;
186 visualization_msgs::Marker marker;
188 marker.header.frame_id =
"/base_link";
194 marker.action = visualization_msgs::Marker::ADD;
196 geometry_msgs::Point approach_point;
197 approach_point.x = approach_pose.position.x;
198 approach_point.y = approach_pose.position.y;
199 approach_point.z = approach_pose.position.z;
201 geometry_msgs::Point grasp_point;
202 grasp_point.x = grasp_pose.position.x;
203 grasp_point.y = grasp_pose.position.y;
204 grasp_point.z = grasp_pose.position.z;
206 marker.points.push_back(approach_point);
207 marker.points.push_back(grasp_point);
209 marker.scale.x = 0.01;
210 marker.scale.y = 0.02;
211 marker.scale.z = 0.05;
213 marker.color.r = 0.9f;
214 marker.color.g = 0.9f;
215 marker.color.b = 0.0f;
216 marker.color.a = 1.0;
228 grasp_pose.position.z));
230 tf::Quaternion(grasp_pose.orientation.x, grasp_pose.orientation.y,
231 grasp_pose.orientation.z, grasp_pose.orientation.w));
233 "base_link",
"current_goal"));
236 #endif // BIN_POSE_EMULATOR_CPP
void broadcast_pose_tf(geometry_msgs::Pose grasp_pose)
ros::Publisher marker_pub
void publish(const boost::shared_ptr< M > &message) const
TFSIMD_FORCE_INLINE const tfScalar & getY() const
Emulator(ros::NodeHandle *nh, std::string filepath)
TFSIMD_FORCE_INLINE const tfScalar & getW() const
bool callback(bin_pose_msgs::bin_pose::Request &req, bin_pose_msgs::bin_pose::Response &res)
TFSIMD_FORCE_INLINE const tfScalar & getZ() const
bool parseConfig(std::string filepath)
double randGen(double fMin, double fMax)
void setRPY(const tfScalar &roll, const tfScalar &pitch, const tfScalar &yaw)
TFSIMD_FORCE_INLINE Vector3 quatRotate(const Quaternion &rotation, const Vector3 &v)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
TFSIMD_FORCE_INLINE const tfScalar & getX() const
void visualize_pose(geometry_msgs::Pose grasp_pose, geometry_msgs::Pose approach_pose)