Commit fb17a2c4 authored by Niklas Yann Wettengel's avatar Niklas Yann Wettengel
Browse files

Merge branch 'master' of gitlab.uni-koblenz.de:robbie/homer_navigation

parents 0da4a492 921e40cf
......@@ -2,6 +2,36 @@
Changelog for package homer_navigation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.1.101 (2020-11-12)
--------------------
* Merge branch 'cpp_lib_refactor' into 'master'
refactor init() check
See merge request robbie/homer_navigation!9
* refactor init() check
* Contributors: Robin Bartsch
0.1.100 (2020-11-02)
--------------------
* Merge branch 'cpp_lib_refactor' into 'master'
Bugfix and added library init()
See merge request robbie/homer_navigation!8
* Contributors: Robin Bartsch
0.1.99 (2020-10-26)
-------------------
* Merge branch 'cpp_lib' into 'master'
Cpp Library
See merge request robbie/homer_navigation!7
* fixed callback; logging and error handling
* init cpp library; atm non-functioning done callback
* 0.1.98
* Merge branch 'pyc_fix' into 'master'
removed old .pyc and added .gitignore
See merge request robbie/homer_navigation!6
* removed old .pyc and added .gitignore
* bug fix: removed deleted member variable
* Contributors: Daniel Müller, Niklas Yann Wettengel, Robin Bartsch
0.1.97 (2020-07-21)
-------------------
* Further adding dependancies
......
......@@ -35,7 +35,10 @@ endif()
set(CMAKE_BUILD_TYPE Release)
catkin_package(
INCLUDE_DIRS include
INCLUDE_DIRS
include
LIBRARIES
HomerNavigationLib
CATKIN_DEPENDS
roscpp
roslib
......@@ -84,11 +87,24 @@ add_dependencies(narrow_passage_detection_node ${catkin_EXPORTED_TARGETS})
target_link_libraries(narrow_passage_detection_node ${catkin_LIBRARIES} ${OpenCV_LIBS})
#--------------------------------------------------------------------------------------
add_library(HomerNavigationLib
src/HomerNavigationLib.cpp
)
add_dependencies(HomerNavigationLib
${catkin_EXPORTED_TARGETS}
${${PROJECT_NAME}_EXPORTED_TARGETS}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
install(TARGETS homer_navigation drive_to depth_occupancy_map
install(
TARGETS
homer_navigation drive_to depth_occupancy_map HomerNavigationLib
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
......@@ -100,9 +116,9 @@ install(PROGRAMS
)
install(DIRECTORY launch/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)
install(DIRECTORY config/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/config
)
#pragma once
#include <string>
#include <actionlib/client/simple_action_client.h>
#include <homer_mapnav_msgs/DriveToAction.h>
#include <ros/ros.h>
namespace homer_navigation
{
void init(const ros::NodeHandle& nh);
void drive_to_POI(const std::string& poi_name, float distance_to_target = 0.03,
bool suppress_speaking = false, bool skip_final_turn = false, bool stop_before_obstacle = false,
bool check_obstacle_type = false,
const boost::function<void(const actionlib::SimpleClientGoalState& state,
const homer_mapnav_msgs::DriveToResultConstPtr&)>& callback
= 0,
bool keep_torso_position = false);
homer_mapnav_msgs::DriveToResultConstPtr drive_to_POI_blocked(const std::string& poi_name,
float distance_to_target = 0.03, bool suppress_speaking = false, bool skip_final_turn = false,
bool stop_before_obstacle = false, bool check_obstacle_type = false,
ros::Duration timeout = ros::Duration(0), bool keep_torso_position = false);
} // namespace homer_navigation
<?xml version="1.0"?>
<package>
<name>homer_navigation</name>
<version>0.1.98</version>
<version>0.1.101</version>
<description>The homer_navigation package</description>
<maintainer email="fpolster@uni-koblenz.de">Florian Polster</maintainer>
......
#include <homer_navigation/HomerNavigationLib.h>
#include <homer_mapnav_msgs/DriveToGoal.h>
#include <stdexcept>
#include <utility>
namespace homer_navigation
{
typedef actionlib::SimpleActionClient<homer_mapnav_msgs::DriveToAction> ActionClient;
namespace
{
std::unique_ptr<ros::NodeHandle> nh_ptr;
std::unique_ptr<ActionClient> ac_ptr;
void checkIfInit()
{
if (!nh_ptr)
{
ROS_ERROR_STREAM(
"HomerNavigationLib not initialized. Call init() once before library usage.");
throw std::runtime_error("HomerNavigationLib not initialized");
}
}
homer_mapnav_msgs::DriveToGoal create_goal(const std::string& poi_name,
float distance_to_target = 0.03, bool suppress_speaking = false,
bool skip_final_turn = false, bool stop_before_obstacle = false,
bool check_obstacle_type = false, bool keep_torso_position = false)
{
ROS_INFO_STREAM("[DriveTo]:\n goal_location: \t"
<< poi_name << "\n distance_to_target: \t" << distance_to_target << "\n speaking: \t\t"
<< (!suppress_speaking ? "true" : "false"));
homer_mapnav_msgs::DriveToGoal goal;
goal.goal_location = poi_name;
goal.distance_to_target = distance_to_target;
goal.suppress_speaking = suppress_speaking;
goal.skip_final_turn = skip_final_turn;
goal.stop_before_obstacle = stop_before_obstacle;
goal.check_obstacle = check_obstacle_type;
goal.keep_torso_position = keep_torso_position;
return goal;
}
} // namespace
void init(const ros::NodeHandle& nh)
{
nh_ptr = std::make_unique<ros::NodeHandle>(nh);
ac_ptr = std::make_unique<ActionClient>("drive_to", true);
}
void drive_to_POI(const std::string& poi_name, float distance_to_target, bool suppress_speaking,
bool skip_final_turn, bool stop_before_obstacle, bool check_obstacle_type,
const boost::function<void(const actionlib::SimpleClientGoalState& state,
const homer_mapnav_msgs::DriveToResultConstPtr&)>& callback,
bool keep_torso_position)
{
checkIfInit();
auto goal = create_goal(poi_name, distance_to_target, suppress_speaking, skip_final_turn,
stop_before_obstacle, check_obstacle_type, keep_torso_position);
if (!(ac_ptr->waitForServer(ros::Duration(5))))
{
ROS_ERROR_STREAM("Drive_to action server not reachable");
return;
}
ac_ptr->sendGoal(goal, callback);
ros::Duration(0.1).sleep(); // required for the callback; otherwise its not called
}
homer_mapnav_msgs::DriveToResultConstPtr drive_to_POI_blocked(const std::string& poi_name,
float distance_to_target, bool suppress_speaking, bool skip_final_turn,
bool stop_before_obstacle, bool check_obstacle_type, ros::Duration timeout,
bool keep_torso_position)
{
homer_navigation::drive_to_POI(poi_name, distance_to_target, suppress_speaking, skip_final_turn,
stop_before_obstacle, check_obstacle_type, 0, keep_torso_position);
if (!(ac_ptr->waitForResult(timeout)))
{
ROS_ERROR_STREAM("Timeout of drive_to_POI_blocked result.");
return nullptr;
}
return ac_ptr->getResult();
}
} // namespace homer_navigation
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment