30 pnh.
param(
"samples", samples, 360);
34 pnh.
param(
"range_max",
range_max_, std::numeric_limits<double>::quiet_NaN());
35 pnh.
param(
"frequency",
frequency_, std::numeric_limits<double>::quiet_NaN());
40 double costmap_update_frequency, costmap_width, costmap_height;
42 nh.
getParam(
"move_base/local_costmap/update_frequency", costmap_update_frequency);
43 nh.
getParam(
"move_base/local_costmap/width", costmap_width);
44 nh.
getParam(
"move_base/local_costmap/height", costmap_height);
48 range_max_ = std::max(costmap_width, costmap_height)/2.0;
65 scan_.ranges.resize(samples);
110 std::vector< boost::shared_ptr<Obstacle> > obstacles;
113 for (
unsigned int i = 0; i <
columns_.size(); i++)
121 add(new_obs, obstacles);
125 for (
unsigned int i = 0; i <
walls_.size(); i++)
132 add(new_obs, obstacles);
140 for (
double ray_theta =
scan_.angle_min; ray_theta <=
scan_.angle_max; ray_theta +=
scan_.angle_increment)
142 double rx =
scan_.range_max*std::cos(ray_theta);
143 double ry =
scan_.range_max*std::sin(ray_theta);
148 for (
unsigned int i = 0; i < obstacles.size(); i++)
151 if (obstacles[i]->intersects(rx, ry,
scan_.range_max, distance) ==
true)
154 scan_.ranges[ray] = std::min(
scan_.ranges[ray], (
float)distance);
180 if ((new_obs->minHeight() > 0.0) || (new_obs->maxHeight() < 0.0))
185 if (new_obs->distance() <= 0.0)
187 ROS_WARN_THROTTLE(2,
"The robot is inside an obstacle??? Ignore it (distance: %f)", new_obs->distance());
191 if (new_obs->distance() <=
scan_.range_max)
193 std::vector< boost::shared_ptr<Obstacle> >::iterator it;
194 for (it = obstacles.begin(); it != obstacles.end(); ++it)
196 if (new_obs->distance() <= (*it)->distance())
198 obstacles.insert(it, new_obs);
203 if ((obstacles.size() == 0) || it == obstacles.end())
206 obstacles.push_back(new_obs);
217 int main(
int argc,
char **argv)
222 if (node.
init() ==
false)
static void poseMsgToTF(const geometry_msgs::Pose &msg, Pose &bt)
#define ROS_WARN_THROTTLE(rate,...)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Subscriber wall_poses_sub_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
ros::Subscriber column_poses_sub_
std::vector< yocs_msgs::Wall > walls_
void columnPosesCB(const yocs_msgs::ColumnList::ConstPtr &msg)
static const Quaternion & getIdentity()
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
std::string sensor_frame_id_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
tf::TransformListener tf_listener_
uint32_t getNumSubscribers() const
bool getParam(const std::string &key, std::string &s) const
sensor_msgs::LaserScan scan_
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
ros::Publisher virtual_obs_pub_
ROSCPP_DECL void spinOnce()
bool add(boost::shared_ptr< Obstacle > &new_obs, std::vector< boost::shared_ptr< Obstacle > > &obstacles)
void wallPosesCB(const yocs_msgs::WallList::ConstPtr &msg)
std::vector< yocs_msgs::Column > columns_
std::string global_frame_id_