Skip to content
Snippets Groups Projects
Commit 34eb6d48 authored by Niklas Yann Wettengel's avatar Niklas Yann Wettengel
Browse files

Merge branch 'feature/stop_navigation_on_collision' into 'master'

Feature/stop navigation on collision

See merge request !1
parents 9ff5c30f 671488dd
No related branches found
No related tags found
1 merge request!1Feature/stop navigation on collision
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
Changelog for package homer_map_manager Changelog for package homer_map_manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.7 (2016-11-17)
------------------
0.1.6 (2016-11-04) 0.1.6 (2016-11-04)
------------------ ------------------
......
<package> <package>
<name>homer_map_manager</name> <name>homer_map_manager</name>
<version>0.1.6</version> <version>0.1.7</version>
<description> <description>
map_manager map_manager
</description> </description>
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
Changelog for package homer_mapnav_msgs Changelog for package homer_mapnav_msgs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.7 (2016-11-17)
------------------
* Add a parameter to NavigateToPOI msgs to controll new behaviour (remove config parameter)
* Contributors: Malte Roosen
0.1.6 (2016-11-04) 0.1.6 (2016-11-04)
------------------ ------------------
......
string poi_name string poi_name
float32 distance_to_target float32 distance_to_target
bool skip_final_turn bool skip_final_turn
bool stop_before_obstacle
<package> <package>
<name>homer_mapnav_msgs</name> <name>homer_mapnav_msgs</name>
<version>0.1.6</version> <version>0.1.7</version>
<description> homer_mapnav_msgs contains the messages used for mapping and navigation <description> homer_mapnav_msgs contains the messages used for mapping and navigation
</description> </description>
<maintainer email="vseib@uni-koblenz.de">Viktor Seib</maintainer> <maintainer email="vseib@uni-koblenz.de">Viktor Seib</maintainer>
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
Changelog for package homer_mapping Changelog for package homer_mapping
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.7 (2016-11-17)
------------------
0.1.6 (2016-11-04) 0.1.6 (2016-11-04)
------------------ ------------------
......
<package> <package>
<name>homer_mapping</name> <name>homer_mapping</name>
<version>0.1.6</version> <version>0.1.7</version>
<description> <description>
homer_mapping homer_mapping
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
Changelog for package homer_nav_libs Changelog for package homer_nav_libs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.7 (2016-11-17)
------------------
0.1.6 (2016-11-04) 0.1.6 (2016-11-04)
------------------ ------------------
......
<?xml version="1.0"?> <?xml version="1.0"?>
<package> <package>
<name>homer_nav_libs</name> <name>homer_nav_libs</name>
<version>0.1.6</version> <version>0.1.7</version>
<description>The nav_libs package</description> <description>The nav_libs package</description>
<maintainer email="vseib@uni-koblenz.de">Viktor Seib</maintainer> <maintainer email="vseib@uni-koblenz.de">Viktor Seib</maintainer>
......
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
Changelog for package homer_navigation Changelog for package homer_navigation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.7 (2016-11-17)
------------------
* Add a parameter to NavigateToPOI msgs to controll new behaviour (remove config parameter)
* Introduce parameter to change behaviour after collision avoidance
* Autoformat homer_navigation_node
* Contributors: Malte Roosen
* Introduce parameter to change behaviour after collision avoidance
* Autoformat homer_navigation_node
* Contributors: Malte Roosen
0.1.6 (2016-11-04) 0.1.6 (2016-11-04)
------------------ ------------------
......
#ifndef FastNavigationModule_H #ifndef FastNavigationModule_H
#define FastNavigationModule_H #define FastNavigationModule_H
#include <vector>
#include <string>
#include <sstream>
#include <cmath> #include <cmath>
#include <sstream>
#include <string>
#include <vector>
#include <ros/ros.h>
#include <ros/package.h> #include <ros/package.h>
#include <ros/ros.h>
#include <tf/transform_listener.h> #include <tf/transform_listener.h>
#include <homer_robbie_architecture/Architecture/StateMachine/StateMachine.h> #include <homer_robbie_architecture/Architecture/StateMachine/StateMachine.h>
#include <nav_msgs/OccupancyGrid.h>
#include <nav_msgs/Path.h>
#include <geometry_msgs/PoseStamped.h> #include <geometry_msgs/PoseStamped.h>
#include <geometry_msgs/Twist.h> #include <geometry_msgs/Twist.h>
#include <sensor_msgs/LaserScan.h> #include <homer_mapnav_msgs/GetPointsOfInterest.h>
#include <homer_mapnav_msgs/StartNavigation.h>
#include <homer_mapnav_msgs/NavigateToPOI.h> #include <homer_mapnav_msgs/NavigateToPOI.h>
#include <homer_mapnav_msgs/StartNavigation.h>
#include <homer_mapnav_msgs/TargetUnreachable.h> #include <homer_mapnav_msgs/TargetUnreachable.h>
#include <homer_mapnav_msgs/GetPointsOfInterest.h>
#include <std_msgs/Int8.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Empty.h>
#include <std_msgs/String.h>
#include <std_msgs/Float32.h>
#include <homer_ptu_msgs/CenterWorldPoint.h> #include <homer_ptu_msgs/CenterWorldPoint.h>
#include <homer_ptu_msgs/SetPanTilt.h> #include <homer_ptu_msgs/SetPanTilt.h>
#include <nav_msgs/OccupancyGrid.h>
#include <nav_msgs/Path.h>
#include <sensor_msgs/LaserScan.h>
#include <std_msgs/Empty.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Int8.h>
#include <std_msgs/String.h>
#include <homer_nav_libs/tools.h>
#include <homer_nav_libs/Explorer/Explorer.h> #include <homer_nav_libs/Explorer/Explorer.h>
#include <homer_nav_libs/tools.h>
class Explorer; class Explorer;
/** /**
...@@ -40,290 +40,304 @@ class Explorer; ...@@ -40,290 +40,304 @@ class Explorer;
* @brief Performs autonomous navigation * @brief Performs autonomous navigation
*/ */
class HomerNavigationNode { class HomerNavigationNode {
public:
/**
* @brief States of the state machines
*/
enum ProcessState {
IDLE,
AWAITING_PATHPLANNING_MAP,
FOLLOWING_PATH,
AVOIDING_COLLISION,
FINAL_TURN
};
/**
* The constructor
*/
HomerNavigationNode();
/**
* The destructor
*/
virtual ~HomerNavigationNode();
/** @brief Is called in constant intervals. */
void idleProcess();
protected:
/** @brief Handles incoming messages. */
void mapCallback(const nav_msgs::OccupancyGrid::ConstPtr& msg);
void poseCallback(const geometry_msgs::PoseStamped::ConstPtr& msg);
void laserDataCallback(const sensor_msgs::LaserScan::ConstPtr& msg);
void downlaserDataCallback(const sensor_msgs::LaserScan::ConstPtr& msg);
void startNavigationCallback(
const homer_mapnav_msgs::StartNavigation::ConstPtr& msg);
void moveBaseSimpleGoalCallback(
const geometry_msgs::PoseStamped::ConstPtr& msg);
void stopNavigationCallback(const std_msgs::Empty::ConstPtr& msg);
void navigateToPOICallback(
const homer_mapnav_msgs::NavigateToPOI::ConstPtr& msg);
void unknownThresholdCallback(const std_msgs::Int8::ConstPtr& msg);
void maxDepthMoveDistanceCallback(const std_msgs::Float32::ConstPtr& msg);
/** @brief initializes and refreshs parameters */
void loadParameters();
/** @brief Is called when all modules are loaded and thread has started. */
virtual void init();
/** @brief Detect & handle possible collision */
void handleCollision();
private:
/** @brief Start navigation to m_Target on last_map_data_ */
void startNavigation();
/** @brief Check if obstacles are blocking the way in last_map_data_ */
bool checkPath();
/** @brief calculate path from current robot position to target approximation
*/
void calculatePath();
/** @brief Send message containing current navigation path */
void sendPathData();
/** @brief Sends target reached and stops the robot. */
void sendTargetReachedMsg();
/**
* @brief Sends a target unreachable with given reason and stops the robot.
* @param reason reason for unreachable target (see
* homer_mapnav_msgs::TargetUnreachable for possible reasons)
*/
void sendTargetUnreachableMsg(int8_t reason);
/** @brief reloads all params from the parameterserver */
void refreshParamsCallback(const std_msgs::Empty::ConstPtr& msg);
/** @brief Navigate robot to next waypoint */
void performNextMove();
/** @brief Finishes navigation or starts turning to target direction if the
* target position has been reached */
void targetPositionReached();
/** @return Angle from robot_pose_ to point in degrees */
int angleToPointDeg(geometry_msgs::Point point);
/** @brief Calculates current maximal backwards distance on map Data */
bool backwardObstacle();
/** @brief stops the Robot */
void stopRobot();
/**
* @brief Sets each cell of the map to -1 outside the bounding box
* containing the robot pose and the current target
*/
void maskMap();
/**
* @brief Current path was finished (either successful or not),
* sets state machine to path planning to check if the robot is already
* at the goal
*/
void currentPathFinished();
// convenience math functions
/**
* Computes minimum turn angle from angle 1 to angle 2
* @param angle1 from angle
* @param angle2 to angle
* @return minimal angle needed to turn from angle 1 to angle 2 [-Pi..Pi]
*/
static float minTurnAngle(float angle1, float angle2);
/**
* converts value from degree to radiant
* @param deg Value in degree
* @return value in radiants
*/
static float deg2Rad(float deg) { return deg / 180.0 * M_PI; }
/**
* converts value from radiants to degrees
* @param rad Value in radiants
* @return value in degrees
*/
static float rad2Deg(float rad) { return rad / M_PI * 180.0; }
bool drawPolygon(std::vector<geometry_msgs::Point> vertices);
void drawLine(std::vector<int>& data, int startX, int startY, int endX,
int endY, int value);
bool fillPolygon(std::vector<int>& data, int x, int y, int value);
public: /** @brief calcs the maximal move distance from Laser and DepthData */
void calcMaxMoveDist();
/**
* @brief States of the state machines
*/
enum ProcessState
{
IDLE,
AWAITING_PATHPLANNING_MAP,
FOLLOWING_PATH,
AVOIDING_COLLISION,
FINAL_TURN
};
/**
* The constructor
*/
HomerNavigationNode();
/**
* The destructor
*/
virtual ~HomerNavigationNode();
/** @brief Is called in constant intervals. */
void idleProcess();
protected:
/** @brief Handles incoming messages. */
void mapCallback(const nav_msgs::OccupancyGrid::ConstPtr& msg);
void poseCallback(const geometry_msgs::PoseStamped::ConstPtr& msg);
void laserDataCallback(const sensor_msgs::LaserScan::ConstPtr& msg);
void downlaserDataCallback(const sensor_msgs::LaserScan::ConstPtr& msg);
void startNavigationCallback(const homer_mapnav_msgs::StartNavigation::ConstPtr& msg);
void moveBaseSimpleGoalCallback(const geometry_msgs::PoseStamped::ConstPtr& msg);
void stopNavigationCallback(const std_msgs::Empty::ConstPtr& msg);
void navigateToPOICallback(const homer_mapnav_msgs::NavigateToPOI::ConstPtr& msg);
void unknownThresholdCallback(const std_msgs::Int8::ConstPtr& msg);
void maxDepthMoveDistanceCallback(const std_msgs::Float32::ConstPtr& msg);
/** @brief initializes and refreshs parameters */
void loadParameters();
/** @brief Is called when all modules are loaded and thread has started. */
virtual void init();
/** @brief Detect & handle possible collision */
void handleCollision();
private:
/** @brief Start navigation to m_Target on last_map_data_ */
void startNavigation();
/** @brief Check if obstacles are blocking the way in last_map_data_ */
bool checkPath();
/** @brief calculate path from current robot position to target approximation */
void calculatePath();
/** @brief Send message containing current navigation path */
void sendPathData();
/** @brief Sends target reached and stops the robot. */
void sendTargetReachedMsg();
/**
* @brief Sends a target unreachable with given reason and stops the robot.
* @param reason reason for unreachable target (see homer_mapnav_msgs::TargetUnreachable for possible reasons)
*/
void sendTargetUnreachableMsg( int8_t reason );
/** @brief reloads all params from the parameterserver */
void refreshParamsCallback(const std_msgs::Empty::ConstPtr& msg);
/** @brief Navigate robot to next waypoint */
void performNextMove();
/** @brief Finishes navigation or starts turning to target direction if the target position has been reached */
void targetPositionReached();
/** @return Angle from robot_pose_ to point in degrees */
int angleToPointDeg(geometry_msgs::Point point);
/** @brief Calculates current maximal backwards distance on map Data */
bool backwardObstacle();
/** @brief stops the Robot */
void stopRobot();
/**
* @brief Sets each cell of the map to -1 outside the bounding box
* containing the robot pose and the current target
*/
void maskMap();
/**
* @brief Current path was finished (either successful or not),
* sets state machine to path planning to check if the robot is already at the goal
*/
void currentPathFinished();
//convenience math functions
/**
* Computes minimum turn angle from angle 1 to angle 2
* @param angle1 from angle
* @param angle2 to angle
* @return minimal angle needed to turn from angle 1 to angle 2 [-Pi..Pi]
*/
static float minTurnAngle ( float angle1, float angle2 );
/**
* converts value from degree to radiant
* @param deg Value in degree
* @return value in radiants
*/
static float deg2Rad ( float deg ) { return deg / 180.0*M_PI; }
/**
* converts value from radiants to degrees
* @param rad Value in radiants
* @return value in degrees
*/
static float rad2Deg ( float rad ) { return rad / M_PI*180.0; }
bool drawPolygon ( std::vector< geometry_msgs::Point > vertices); /// @brief Worker instances
void drawLine ( std::vector<int> &data, int startX, int startY, int endX, int endY, int value ); Explorer* m_explorer;
bool fillPolygon ( std::vector<int> &data, int x, int y, int value );
/** @brief calcs the maximal move distance from Laser and DepthData */ /// @brief State machine
void calcMaxMoveDist(); StateMachine<ProcessState> m_MainMachine;
/// @brief Worker instances /// @brief Navigation options & data
Explorer* m_explorer;
/// @brief State machine /** list of waypoints subsampled from m_PixelPath */
StateMachine<ProcessState> m_MainMachine; std::vector<geometry_msgs::PoseStamped> m_waypoints;
/// @brief Navigation options & data /** Path planned by Explorer, pixel accuracy */
std::vector<Eigen::Vector2i> m_pixel_path;
/** target point */
geometry_msgs::Point m_target_point;
/** list of waypoints subsampled from m_PixelPath */ /** target name if called via Navigate_to_POI */
std::vector<geometry_msgs::PoseStamped> m_waypoints; std::string m_target_name;
/** Path planned by Explorer, pixel accuracy */ /** orientation the robot should have at the target point */
std::vector<Eigen::Vector2i> m_pixel_path; double m_target_orientation;
/** target point */ /** allowed distance to target */
geometry_msgs::Point m_target_point; float m_desired_distance;
/** target name if called via Navigate_to_POI */
std::string m_target_name;
/** orientation the robot should have at the target point */ /** check if the final turn should be skipped */
double m_target_orientation; bool m_skip_final_turn;
/** allowed distance to target */ /**
float m_desired_distance; * check if navigation should perform fast planning. In this mode a path is
* only planned within
* a bounding box containing the robot pose and the target point
*/
bool m_fast_path_planning;
/** check if the final turn should be skipped */ /** current pose of the robot */
bool m_skip_final_turn; geometry_msgs::Pose m_robot_pose;
/** /** last pose of the robot */
* check if navigation should perform fast planning. In this mode a path is only planned within geometry_msgs::Pose m_robot_last_pose;
* a bounding box containing the robot pose and the target point
*/ /** time stamp of the last incoming laser scan */
bool m_fast_path_planning; ros::Time m_last_laser_time;
/** time stamp of the last incoming pose */
/** current pose of the robot */ ros::Time m_last_pose_time;
geometry_msgs::Pose m_robot_pose;
/** Distance factor of a frontier cell considered save for exploration */
/** last pose of the robot */ float m_FrontierSafenessFactor;
geometry_msgs::Pose m_robot_last_pose;
double m_SafePathWeight;
/** time stamp of the last incoming laser scan */
ros::Time m_last_laser_time; /// map parameters
/** time stamp of the last incoming pose */ double m_resolution;
ros::Time m_last_pose_time; double m_width;
double m_height;
/** Distance factor of a frontier cell considered save for exploration */ geometry_msgs::Pose m_origin;
float m_FrontierSafenessFactor;
/// @brief Configuration parameters
double m_SafePathWeight;
/** Allowed distances of obstacles to robot. Robot must move within these
///map parameters * bounds */
double m_resolution; std::pair<float, float> m_AllowedObstacleDistance;
double m_width;
double m_height; /** Safe distances of obstacles to robot. If possible, robot should move
geometry_msgs::Pose m_origin; * within these bounds */
std::pair<float, float> m_SafeObstacleDistance;
/// @brief Configuration parameters
/** threshold to sample down waypoints */
/** Allowed distances of obstacles to robot. Robot must move within these bounds */ float m_waypoint_sampling_threshold;
std::pair<float,float> m_AllowedObstacleDistance;
float m_max_move_distance;
/** Safe distances of obstacles to robot. If possible, robot should move within these bounds */ float m_max_move_sick;
std::pair<float,float> m_SafeObstacleDistance; float m_max_move_down;
float m_max_move_depth;
/** threshold to sample down waypoints */
float m_waypoint_sampling_threshold; /** if distance to nearest obstacle is below collision distance trigger
* collision avoidance */
float m_max_move_distance; float m_collision_distance;
float m_max_move_sick;
float m_max_move_down; /** if distance to nearest obstacle is below collision distance don't drive
float m_max_move_depth; * backwards */
float m_backward_collision_distance;
/** if distance to nearest obstacle is below collision distance trigger collision avoidance */ /** do not drive back in collision avoidance when this near target */
float m_collision_distance; float m_collision_distance_near_target;
/** if distance to nearest obstacle is below collision distance don't drive backwards */ /** if true, obstacles in path will be detected and path will be replanned */
float m_backward_collision_distance; bool m_check_path;
/** do not drive back in collision avoidance when this near target */
float m_collision_distance_near_target; /** waypoints will only be checked for obstacles if they are closer than
* check_path_max_distance to robot */
/** if true, obstacles in path will be detected and path will be replanned */ float m_check_path_max_distance;
bool m_check_path;
/** do not replan if lisa avoids an obstacle, instead send target
/** waypoints will only be checked for obstacles if they are closer than check_path_max_distance to robot */ * unreachable*/
float m_check_path_max_distance; bool m_stop_before_obstacle;
bool m_avoided_collision;
float m_min_turn_angle;
float m_max_turn_speed;
float m_min_turn_speed;
float m_max_move_speed;
float m_max_drive_angle;
float m_waypoint_radius_factor;
float m_distance_to_target; bool m_avoided_collision;
float m_act_speed;
float m_angular_avoidance;
float m_map_speed_factor; float m_min_turn_angle;
float m_waypoint_speed_factor; float m_max_turn_speed;
float m_obstacle_speed_factor; float m_min_turn_speed;
float m_target_distance_speed_factor; float m_max_move_speed;
float m_max_drive_angle;
float m_min_y; float m_waypoint_radius_factor;
float m_min_x;
float m_distance_to_target;
float m_callback_error_duration; float m_act_speed;
float m_angular_avoidance;
bool m_last_check_path_res;
bool m_use_ptu; float m_map_speed_factor;
bool m_new_target; float m_waypoint_speed_factor;
float m_obstacle_speed_factor;
bool m_path_reaches_target; float m_target_distance_speed_factor;
int m_last_calculations_failed;
int m_unknown_threshold; float m_min_y;
float m_min_x;
/** last map data */
std::vector<int8_t> * m_last_map_data; float m_callback_error_duration;
//ros specific members bool m_last_check_path_res;
tf::TransformListener m_transform_listener; bool m_use_ptu;
bool m_new_target;
//subscribers
ros::Subscriber m_map_sub; bool m_path_reaches_target;
ros::Subscriber m_pose_sub; bool m_initial_path_reaches_target;
ros::Subscriber m_laser_data_sub; int m_last_calculations_failed;
ros::Subscriber m_down_laser_data_sub; int m_unknown_threshold;
ros::Subscriber m_laser_back_data_sub;
ros::Subscriber m_start_navigation_sub; /** last map data */
ros::Subscriber m_stop_navigation_sub; std::vector<int8_t>* m_last_map_data;
ros::Subscriber m_navigate_to_poi_sub;
ros::Subscriber m_unknown_threshold_sub; // ros specific members
ros::Subscriber m_refresh_param_sub; tf::TransformListener m_transform_listener;
ros::Subscriber m_max_move_depth_sub;
ros::Subscriber m_move_base_simple_goal_sub; // subscribers
ros::Subscriber m_map_sub;
//publishers ros::Subscriber m_pose_sub;
ros::Publisher m_cmd_vel_pub; ros::Subscriber m_laser_data_sub;
ros::Publisher m_target_reached_string_pub; ros::Subscriber m_down_laser_data_sub;
//ros::Publisher m_target_reached_empty_pub; ros::Subscriber m_laser_back_data_sub;
ros::Publisher m_target_unreachable_pub; ros::Subscriber m_start_navigation_sub;
ros::Publisher m_path_pub; ros::Subscriber m_stop_navigation_sub;
ros::Publisher m_ptu_center_world_point_pub; ros::Subscriber m_navigate_to_poi_sub;
ros::Publisher m_set_pan_tilt_pub; ros::Subscriber m_unknown_threshold_sub;
ros::Publisher m_debug_pub; ros::Subscriber m_refresh_param_sub;
ros::Subscriber m_max_move_depth_sub;
//service clients ros::Subscriber m_move_base_simple_goal_sub;
ros::ServiceClient m_get_POIs_client;
// publishers
ros::Publisher m_cmd_vel_pub;
ros::Publisher m_target_reached_string_pub;
// ros::Publisher m_target_reached_empty_pub;
ros::Publisher m_target_unreachable_pub;
ros::Publisher m_path_pub;
ros::Publisher m_ptu_center_world_point_pub;
ros::Publisher m_set_pan_tilt_pub;
ros::Publisher m_debug_pub;
// service clients
ros::ServiceClient m_get_POIs_client;
}; };
#endif #endif
<?xml version="1.0"?> <?xml version="1.0"?>
<package> <package>
<name>homer_navigation</name> <name>homer_navigation</name>
<version>0.1.6</version> <version>0.1.7</version>
<description>The homer_navigation package</description> <description>The homer_navigation package</description>
<maintainer email="vseib@uni-koblenz.de">Viktor Seib</maintainer> <maintainer email="vseib@uni-koblenz.de">Viktor Seib</maintainer>
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment