36 #include "nav_msgs/MapMetaData.h" 37 #include "nav_msgs/OccupancyGrid.h" 39 #include <boost/thread.hpp> 43 #include "nav_msgs/GetMap.h" 48 #include "hector_nav_msgs/GetDistanceToObstacle.h" 49 #include "hector_nav_msgs/GetSearchPosition.h" 60 std::string service_name =
"map";
64 std::string lookup_service_name =
"get_distance_to_obstacle";
67 std::string get_search_pos_service_name =
"get_search_position";
77 nav_msgs::GetMap::Response &res )
79 ROS_INFO(
"hector_map_server map service called");
82 ROS_INFO(
"map_server has no map yet, no map service available");
92 hector_nav_msgs::GetDistanceToObstacle::Response &res )
98 ROS_INFO(
"map_server has no map yet, no lookup service available");
114 tf::Vector3 v2 = stamped_pose * v2_tf;
115 tf::Vector3 diff = v2 - v1;
116 v2 = v1 + diff / tf::Vector3(diff.
x(), diff.
y(), 0.0).
length() * 5.0f;
118 Eigen::Vector2f start(v1.x(),v1.y());
119 Eigen::Vector2f end(v2.
x(),v2.
y());
121 Eigen::Vector2f hit_world;
126 tf::Vector3 diff (v2-v1);
128 float angle = diff.
angle(tf::Vector3(diff.
x(),diff.
y(),0.0f));
130 res.distance = dist/cos(angle);
133 res.distance = -1.0f;
139 float cube_scale =
map_ptr_->info.resolution;
161 ROS_ERROR(
"Transform failed in lookup distance service call: %s",e.what());
168 hector_nav_msgs::GetSearchPosition::Response &res )
171 ROS_INFO(
"map_server has no map yet, no get best search pos service available");
184 search_position = transformed_pose;
185 search_position.setOrigin(transformed_pose.getOrigin() + transformed_pose.getBasis() * direction);
257 ROS_ERROR(
"Transform failed in getSearchPosition service call: %s",e.what());
295 std::string frame_id;
298 hector_drawings_->setNamespace(
"map_server");
308 delete hector_drawings_;
320 int main(
int argc,
char **argv)
322 ros::init(argc, argv,
"hector_map_server");
HectorDrawings * drawing_provider_
tf::TransformListener tf_
ros::ServiceServer dist_lookup_service_
static void pointMsgToTF(const geometry_msgs::Point &msg_v, Point &bt_v)
bool getSearchPosServiceCallback(hector_nav_msgs::GetSearchPosition::Request &req, hector_nav_msgs::GetSearchPosition::Response &res)
virtual void sendAndResetData()
HectorDrawings * hector_drawings_
ros::ServiceServer get_search_pos_service_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual void setScale(double scale)
HectorMapTools::DistanceMeasurementProvider dist_meas_
OccupancyGridContainer(std::string sub_topic, std::string prefix, ros::NodeHandle &nh, HectorDrawings *drawing_provider, tf::TransformListener *tf_)
static void poseStampedTFToMsg(const Stamped< Pose > &bt, geometry_msgs::PoseStamped &msg)
virtual void drawPoint(const Eigen::Vector2f &pointWorldFrame)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool lookupServiceCallback(hector_nav_msgs::GetDistanceToObstacle::Request &req, hector_nav_msgs::GetDistanceToObstacle::Response &res)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
TFSIMD_FORCE_INLINE tfScalar angle(const Vector3 &v) const
nav_msgs::GetMap::Response map_resp_
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
ROSCPP_DECL void spin(Spinner &spinner)
~OccupancyGridContainer()
TFSIMD_FORCE_INLINE const tfScalar & x() const
int main(int argc, char **argv)
tf::TransformListener * tf_
HectorMapServer(ros::NodeHandle &private_nh)
ros::ServiceServer map_service_
TFSIMD_FORCE_INLINE const tfScalar & y() const
bool mapServiceCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
void mapCallback(const nav_msgs::OccupancyGridConstPtr &map)
nav_msgs::OccupancyGridConstPtr map_ptr_
virtual void setColor(double r, double g, double b, double a=1.0)
OccupancyGridContainer * mapContainer
static void poseStampedMsgToTF(const geometry_msgs::PoseStamped &msg, Stamped< Pose > &bt)
TFSIMD_FORCE_INLINE tfScalar length() const