|
From: <ei...@us...> - 2009-08-07 01:47:30
|
Revision: 20982
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=20982&view=rev
Author: eitanme
Date: 2009-08-07 01:47:21 +0000 (Fri, 07 Aug 2009)
Log Message:
-----------
Merging the plugin branch back into trunk with move_base and its associated plugins (navfn, carrot_planner, navfn_constrained, base_local_planner) as examples. The plugin tools are available in the pluginlib package.
r30318@att (orig r20810): eitanme | 2009-08-05 13:19:38 -0700
Creating a branch for ROS plugins
r30362@att (orig r20848): eitanme | 2009-08-05 15:25:41 -0700
Moving navfn to the new plugin model
r30370@att (orig r20854): eitanme | 2009-08-05 15:51:48 -0700
Base local planner now works with plugin model
r30393@att (orig r20868): eitanme | 2009-08-05 19:23:50 -0700
Now works with the new plugin model and move_base
r30394@att (orig r20869): eitanme | 2009-08-05 19:24:35 -0700
Now works with the new plugin model and move_base
r30395@att (orig r20870): eitanme | 2009-08-05 19:25:18 -0700
Changed to differentiate between the name of a plugin and the name of the class that it refers to
r30396@att (orig r20871): eitanme | 2009-08-05 19:33:09 -0700
Working version of move_base with the new plugin model
r30398@att (orig r20872): eitanme | 2009-08-05 19:34:12 -0700
Working version of move_base with the new plugin model
r30400@att (orig r20874): eitanme | 2009-08-05 19:36:42 -0700
Checking in nav_core which holds the interfaces used by the plugins for the navigation stack
r30403@att (orig r20877): eitanme | 2009-08-05 19:48:36 -0700
Carrot planner now works with the new plugin model
r30460@att (orig r20930): eitanme | 2009-08-06 14:26:12 -0700
Working towards a cleaner imp. Also, no linking necessary on the user's part
r30461@att (orig r20931): eitanme | 2009-08-06 14:28:39 -0700
Creating include dir
r30462@att (orig r20932): eitanme | 2009-08-06 14:31:07 -0700
Moving plugin_user package to pluginlib package
r30487@att (orig r20952): eitanme | 2009-08-06 17:00:47 -0700
Separated macros and implementation from PluginLoader class spec
r30491@att (orig r20956): eitanme | 2009-08-06 17:03:10 -0700
Removing old example
r30492@att (orig r20957): eitanme | 2009-08-06 17:13:30 -0700
Moving .hpp to .h for polygon
r30493@att (orig r20958): eitanme | 2009-08-06 17:14:28 -0700
Working version of a plugin provider with new plugin model
r30496@att (orig r20960): eitanme | 2009-08-06 17:29:16 -0700
Working semi-complicated example of plugin use
r30497@att (orig r20961): eitanme | 2009-08-06 17:29:36 -0700
Working example of plugin use.... huzzah\!
r30501@att (orig r20964): eitanme | 2009-08-06 17:38:30 -0700
Now throws an exception
r30504@att (orig r20967): eitanme | 2009-08-06 17:52:41 -0700
Carrot Planner works with new plugin model
r30505@att (orig r20968): eitanme | 2009-08-06 17:55:17 -0700
Working navfn plugin
r30506@att (orig r20969): eitanme | 2009-08-06 17:55:44 -0700
Working version of base_local_planner plugin for move_base
r30509@att (orig r20971): eitanme | 2009-08-06 18:20:25 -0700
Moving navfn_constrained over to the new plugin model
r30511@att (orig r20973): eitanme | 2009-08-06 18:21:36 -0700
Making initialized_ protected
r30512@att (orig r20974): eitanme | 2009-08-06 18:23:35 -0700
Working version of move_base_old with new plugin model
r30513@att (orig r20975): eitanme | 2009-08-06 18:30:07 -0700
Adding checks for proper initialization
r30515@att (orig r20977): eitanme | 2009-08-06 18:30:48 -0700
Adding checks for proper initialization
r30520@att (orig r20980): eitanme | 2009-08-06 18:38:42 -0700
Removing blacklist on the pluginlib package now that it is tested and should be expected to compile
Modified Paths:
--------------
pkg/trunk/nav/people_aware_nav/include/people_aware_nav/navfn_constrained.h
pkg/trunk/nav/people_aware_nav/manifest.xml
pkg/trunk/nav/people_aware_nav/src/move_base_constrained.cpp
pkg/trunk/nav/people_aware_nav/src/navfn_constrained.cpp
pkg/trunk/sandbox/plugin_provider/CMakeLists.txt
pkg/trunk/sandbox/plugin_provider/line.cpp
pkg/trunk/sandbox/plugin_provider/manifest.xml
pkg/trunk/sandbox/plugin_provider/polygon_plugins.xml
pkg/trunk/sandbox/plugin_provider/shape_plugins.xml
pkg/trunk/sandbox/plugin_provider/square.cpp
pkg/trunk/sandbox/pluginlib/CMakeLists.txt
pkg/trunk/sandbox/pluginlib/example.cpp
pkg/trunk/sandbox/pluginlib/manifest.xml
pkg/trunk/stacks/navigation/base_local_planner/include/base_local_planner/trajectory_planner_ros.h
pkg/trunk/stacks/navigation/base_local_planner/manifest.xml
pkg/trunk/stacks/navigation/base_local_planner/src/trajectory_planner_ros.cpp
pkg/trunk/stacks/navigation/carrot_planner/include/carrot_planner/carrot_planner.h
pkg/trunk/stacks/navigation/carrot_planner/manifest.xml
pkg/trunk/stacks/navigation/carrot_planner/src/carrot_planner.cpp
pkg/trunk/stacks/navigation/move_base/CMakeLists.txt
pkg/trunk/stacks/navigation/move_base/include/move_base/move_base.h
pkg/trunk/stacks/navigation/move_base/include/move_base/move_base_old.h
pkg/trunk/stacks/navigation/move_base/manifest.xml
pkg/trunk/stacks/navigation/move_base/src/move_base.cpp
pkg/trunk/stacks/navigation/move_base/src/move_base_old.cpp
pkg/trunk/stacks/navigation/navfn/include/navfn/navfn_ros.h
pkg/trunk/stacks/navigation/navfn/manifest.xml
pkg/trunk/stacks/navigation/navfn/src/navfn_node.cpp
pkg/trunk/stacks/navigation/navfn/src/navfn_ros.cpp
Added Paths:
-----------
pkg/trunk/nav/people_aware_nav/bgp_plugin.xml
pkg/trunk/sandbox/plugin_provider/manifest.cpp
pkg/trunk/sandbox/plugin_provider/square.h
pkg/trunk/sandbox/plugin_provider/triangle.cpp
pkg/trunk/sandbox/plugin_provider/triangle.h
pkg/trunk/sandbox/pluginlib/
pkg/trunk/sandbox/pluginlib/include/
pkg/trunk/sandbox/pluginlib/include/pluginlib/
pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader.h
pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader_imp.h
pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_macros.h
pkg/trunk/sandbox/pluginlib/polygon.h
pkg/trunk/sandbox/pluginlib/shape.h
pkg/trunk/stacks/navigation/base_local_planner/blp_plugin.xml
pkg/trunk/stacks/navigation/nav_core/
pkg/trunk/stacks/navigation/nav_core/CMakeLists.txt
pkg/trunk/stacks/navigation/nav_core/Makefile
pkg/trunk/stacks/navigation/nav_core/include/
pkg/trunk/stacks/navigation/nav_core/include/nav_core/
pkg/trunk/stacks/navigation/nav_core/include/nav_core/base_global_planner.h
pkg/trunk/stacks/navigation/nav_core/include/nav_core/base_local_planner.h
pkg/trunk/stacks/navigation/nav_core/mainpage.dox
pkg/trunk/stacks/navigation/nav_core/manifest.xml
pkg/trunk/stacks/navigation/navfn/bgp_plugin.xml
Removed Paths:
-------------
pkg/trunk/sandbox/plugin_user/
Property Changed:
----------------
pkg/trunk/
Property changes on: pkg/trunk
___________________________________________________________________
Modified: svk:merge
- 637b03a7-42c1-4bbd-8d43-e365e379942c:/prfilters:13971
637b03a7-42c1-4bbd-8d43-e365e379942c:/rosTF_to_tf:9746
920d6130-5740-4ec1-bb1a-45963d5fd813:/costmap_rework_branch:20583
920d6130-5740-4ec1-bb1a-45963d5fd813:/frameidpr:7015
920d6130-5740-4ec1-bb1a-45963d5fd813:/nav_rework:21482
920d6130-5740-4ec1-bb1a-45963d5fd813:/users/josh-pr:11755
920d6130-5740-4ec1-bb1a-45963d5fd813:/wgpkgtrunk:5865
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/action_branch:20116
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/common_msgs-0.1-v2:20514
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/common_msgs-0.1-v3:20628
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/common_msgs_0.1:20375
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/josh:10136
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/milestone2:16602
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/nav_rework:17337
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/rosbus:261
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/tags/milestone2_tags/milestone2_final:16577
+ 637b03a7-42c1-4bbd-8d43-e365e379942c:/prfilters:13971
637b03a7-42c1-4bbd-8d43-e365e379942c:/rosTF_to_tf:9746
920d6130-5740-4ec1-bb1a-45963d5fd813:/costmap_rework_branch:20583
920d6130-5740-4ec1-bb1a-45963d5fd813:/frameidpr:7015
920d6130-5740-4ec1-bb1a-45963d5fd813:/nav_rework:21482
920d6130-5740-4ec1-bb1a-45963d5fd813:/users/josh-pr:11755
920d6130-5740-4ec1-bb1a-45963d5fd813:/wgpkgtrunk:5865
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/action_branch:20116
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/common_msgs-0.1-v2:20514
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/common_msgs-0.1-v3:20628
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/common_msgs_0.1:20375
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/josh:10136
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/milestone2:16602
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/nav_rework:17337
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/plugin_branch:20980
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/branches/rosbus:261
f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/tags/milestone2_tags/milestone2_final:16577
Added: pkg/trunk/nav/people_aware_nav/bgp_plugin.xml
===================================================================
--- pkg/trunk/nav/people_aware_nav/bgp_plugin.xml (rev 0)
+++ pkg/trunk/nav/people_aware_nav/bgp_plugin.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,7 @@
+<library path="lib/libnavfn_constrained">
+ <plugin name="NavfnROSConstrained" class="people_aware_nav::NavfnROSConstrained" type="nav_core::BaseGlobalPlanner">
+ <description>
+ A constrained version of the navfn planner
+ </description>
+ </plugin>
+</library>
Modified: pkg/trunk/nav/people_aware_nav/include/people_aware_nav/navfn_constrained.h
===================================================================
--- pkg/trunk/nav/people_aware_nav/include/people_aware_nav/navfn_constrained.h 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/nav/people_aware_nav/include/people_aware_nav/navfn_constrained.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -46,7 +46,9 @@
public:
- NavfnROSConstrained (std::string name, costmap_2d::Costmap2DROS& cmap);
+ NavfnROSConstrained ();
+ NavfnROSConstrained (std::string name, costmap_2d::Costmap2DROS* cmap);
+ void initialize (std::string name, costmap_2d::Costmap2DROS* cmap);
bool setConstraint (SetNavConstraint::Request& req, SetNavConstraint::Response& resp);
protected:
Modified: pkg/trunk/nav/people_aware_nav/manifest.xml
===================================================================
--- pkg/trunk/nav/people_aware_nav/manifest.xml 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/nav/people_aware_nav/manifest.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -6,6 +6,7 @@
<depend package="roslisp" />
<depend package="roslib" />
<depend package="people" />
+<depend package="pluginlib" />
<depend package="hallway_tracker" />
<depend package="topic_synchronizer" />
<depend package="tf" />
@@ -13,6 +14,7 @@
<depend package="base_local_planner"/>
<depend package="costmap_2d"/>
<depend package="angles"/>
+<depend package="nav_core"/>
<depend package="navfn"/>
<depend package="nav_msgs"/>
<depend package="robot_msgs" />
@@ -24,6 +26,7 @@
<depend package="visualization_msgs"/>
<export>
<cpp cflags="-I${prefix}/include -I${prefix}/srv/cpp -I${prefix}/msg/cpp" lflags="-Wl,-rpath,${prefix}/lib -L${prefix}/lib -lnavfn_constrained"/>
+ <nav_core BaseGlobalPlanner="${prefix}/bgp_plugin.xml" />
</export>
</package>
Modified: pkg/trunk/nav/people_aware_nav/src/move_base_constrained.cpp
===================================================================
--- pkg/trunk/nav/people_aware_nav/src/move_base_constrained.cpp 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/nav/people_aware_nav/src/move_base_constrained.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -73,14 +73,14 @@
planner_costmap_ros_->getCostmapCopy(planner_costmap_);
//initialize the NavFn planner
- planner_ = new NavfnROS("NavfnROS", *planner_costmap_ros_);
+ planner_ = new NavfnROS("NavfnROS", planner_costmap_ros_);
ROS_INFO("MAP SIZE: %d, %d", planner_costmap_.getSizeInCellsX(), planner_costmap_.getSizeInCellsY());
//create the ros wrapper for the controller's costmap... and initializer a pointer we'll use with the underlying map
controller_costmap_ros_ = new Costmap2DROS("local_costmap", tf_);
//create a trajectory controller
- tc_ = new TrajectoryPlannerROS("TrajectoryPlannerROS", tf_, *controller_costmap_ros_);
+ tc_ = new TrajectoryPlannerROS("TrajectoryPlannerROS", &tf_, controller_costmap_ros_);
//initially clear any unknown space around the robot
planner_costmap_ros_->clearNonLethalWindow(circumscribed_radius_ * 2, circumscribed_radius_ * 2);
Modified: pkg/trunk/nav/people_aware_nav/src/navfn_constrained.cpp
===================================================================
--- pkg/trunk/nav/people_aware_nav/src/navfn_constrained.cpp 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/nav/people_aware_nav/src/navfn_constrained.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -37,7 +37,12 @@
#include <people_aware_nav/navfn_constrained.h>
#include <visualization_msgs/Marker.h>
#include <ros/ros.h>
+#include <pluginlib/plugin_macros.h>
+BEGIN_PLUGIN_LIST(nav_core::BaseGlobalPlanner);
+REGISTER_PLUGIN(people_aware_nav::NavfnROSConstrained);
+END_PLUGIN_LIST
+
namespace people_aware_nav {
using geometry_msgs::PoseStamped;
@@ -48,17 +53,31 @@
namespace vm=visualization_msgs;
-ROS_REGISTER_BGP(NavfnROSConstrained);
+NavfnROSConstrained::NavfnROSConstrained (){}
-NavfnROSConstrained::NavfnROSConstrained (std::string name, costmap_2d::Costmap2DROS& cmap) :
- navfn::NavfnROS(name, cmap)
+NavfnROSConstrained::NavfnROSConstrained (std::string name, costmap_2d::Costmap2DROS* cmap)
{
+ initialize(name, cmap);
+}
+
+void NavfnROSConstrained::initialize (std::string name, costmap_2d::Costmap2DROS* cmap)
+{
+ if(!initialized_){
+ navfn::NavfnROS::initialize(name, cmap);
service_ = node_.advertiseService("~set_nav_constraint", &NavfnROSConstrained::setConstraint, this);
vis_pub_add_ = node_.advertise<visualization_msgs::Marker>("visualization_marker", 0);
+ }
+ else
+ ROS_WARN("You are attempting to initialize a planner that has already been initialized, doing nothing");
}
bool NavfnROSConstrained::setConstraint (SetNavConstraint::Request& req, SetNavConstraint::Response& resp)
{
+ if(!initialized_){
+ ROS_ERROR("This planner has not been initialized, please call initialize() before attempting to use it.");
+ return false;
+ }
+
forbidden_ = req.forbidden;
ROS_DEBUG_STREAM_NAMED("navfn", "Setting constraint polygon with " << forbidden_.points.size() << " points");
return true;
@@ -67,9 +86,14 @@
void NavfnROSConstrained::getCostmap (costmap_2d::Costmap2D& cmap)
{
- costmap_ros_.clearRobotFootprint();
- costmap_ros_.getCostmapCopy(cmap);
+ if(!initialized_){
+ ROS_ERROR("This planner has not been initialized, please call initialize() before attempting to use it.");
+ return;
+ }
+ costmap_ros_->clearRobotFootprint();
+ costmap_ros_->getCostmapCopy(cmap);
+
// Set cost of forbidden region
vector<Point> polygon;
for (vector<Point32>::const_iterator iter = forbidden_.points.begin(); iter!=forbidden_.points.end(); ++iter) {
Modified: pkg/trunk/sandbox/plugin_provider/CMakeLists.txt
===================================================================
--- pkg/trunk/sandbox/plugin_provider/CMakeLists.txt 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/sandbox/plugin_provider/CMakeLists.txt 2009-08-07 01:47:21 UTC (rev 20982)
@@ -29,8 +29,6 @@
#rospack_add_executable(example examples/example.cpp)
#target_link_libraries(example ${PROJECT_NAME})
-rospack_add_library(square square.cpp)
-target_link_libraries(square PocoUtil)
+rospack_add_library(square square.cpp triangle.cpp manifest.cpp)
-rospack_add_library(line line.cpp)
-target_link_libraries(line PocoUtil)
\ No newline at end of file
+rospack_add_library(line line.cpp shape_manifest.cpp)
Modified: pkg/trunk/sandbox/plugin_provider/line.cpp
===================================================================
--- pkg/trunk/sandbox/plugin_provider/line.cpp 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/sandbox/plugin_provider/line.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -27,21 +27,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "shape.hpp"
-#include "Poco/ClassLibrary.h"
+#include "line.h"
#include <cmath>
-class line : public shape {
-public:
- virtual double area() const {
- return 0;
- }
-};
+double line::area() const {
+ return 0;
+}
-
-POCO_BEGIN_MANIFEST(shape)
-
-POCO_EXPORT_CLASS(line)
-
-POCO_END_MANIFEST
Added: pkg/trunk/sandbox/plugin_provider/manifest.cpp
===================================================================
--- pkg/trunk/sandbox/plugin_provider/manifest.cpp (rev 0)
+++ pkg/trunk/sandbox/plugin_provider/manifest.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,48 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Willow Garage, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Author: Eitan Marder-Eppstein
+*********************************************************************/
+#include "pluginlib/plugin_macros.h"
+#include "polygon.h"
+#include "square.h"
+#include "triangle.h"
+
+//polygon plugin list
+BEGIN_PLUGIN_LIST(polygon)
+
+REGISTER_PLUGIN(triangle)
+REGISTER_PLUGIN(square)
+
+END_PLUGIN_LIST
Modified: pkg/trunk/sandbox/plugin_provider/manifest.xml
===================================================================
--- pkg/trunk/sandbox/plugin_provider/manifest.xml 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/sandbox/plugin_provider/manifest.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -8,10 +8,10 @@
<license>BSD</license>
<review status="experimental" notes=""/>
<url>http://pr.willowgarage.com/wiki/pluging_provider</url>
- <depend package="plugin_user"/>
+ <depend package="pluginlib"/>
<export>
- <plugin_user polygon="${prefix}/polygon_plugins.xml" shape="${prefix}/shape_plugins.xml"/>
+ <pluginlib polygon="${prefix}/polygon_plugins.xml" shape="${prefix}/shape_plugins.xml"/>
</export>
</package>
Modified: pkg/trunk/sandbox/plugin_provider/polygon_plugins.xml
===================================================================
--- pkg/trunk/sandbox/plugin_provider/polygon_plugins.xml 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/sandbox/plugin_provider/polygon_plugins.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -1,11 +1,11 @@
<library path="lib/libsquare">
- <plugin name="square" type="polygon">
+ <plugin name="square" class="square" type="polygon">
<description>
this is a square plugin
</description>
</plugin>
- <plugin name="triangle" type="polygon">
+ <plugin name="triangle" class="triangle" type="polygon">
<description>
this is a triangle plugin
</description>
Modified: pkg/trunk/sandbox/plugin_provider/shape_plugins.xml
===================================================================
--- pkg/trunk/sandbox/plugin_provider/shape_plugins.xml 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/sandbox/plugin_provider/shape_plugins.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -1,5 +1,5 @@
<library path="lib/libline">
- <plugin name="line" type="shape">
+ <plugin name="line" class="line" type="shape">
<description>
this is a line plugin
</description>
Modified: pkg/trunk/sandbox/plugin_provider/square.cpp
===================================================================
--- pkg/trunk/sandbox/plugin_provider/square.cpp 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/sandbox/plugin_provider/square.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -27,30 +27,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "polygon.hpp"
-#include "Poco/ClassLibrary.h"
+#include "square.h"
#include <cmath>
-class square : public polygon {
-public:
- virtual double area() const {
- return side_length_ * side_length_;
- }
-};
+square::square() : name_("my_square") {}
-class triangle : public polygon {
-public:
- virtual double area() const {
- return side_length_ * side_length_ * sqrt(3) / 2;
- }
-};
+double square::area() const {
+ return side_length_ * side_length_;
+}
-
-
-POCO_BEGIN_MANIFEST(polygon)
-
-POCO_EXPORT_CLASS(square)
-POCO_EXPORT_CLASS(triangle)
-
-POCO_END_MANIFEST
Added: pkg/trunk/sandbox/plugin_provider/square.h
===================================================================
--- pkg/trunk/sandbox/plugin_provider/square.h (rev 0)
+++ pkg/trunk/sandbox/plugin_provider/square.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,49 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Willow Garage, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Author: Eitan Marder-Eppstein
+*********************************************************************/
+#ifndef SQUARE_H_
+#define SQUARE_H_
+
+#include "polygon.h"
+
+class square : public polygon {
+public:
+ square();
+ virtual double area() const;
+private:
+ std::string name_;
+};
+#endif
Added: pkg/trunk/sandbox/plugin_provider/triangle.cpp
===================================================================
--- pkg/trunk/sandbox/plugin_provider/triangle.cpp (rev 0)
+++ pkg/trunk/sandbox/plugin_provider/triangle.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,44 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Willow Garage, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Author: Eitan Marder-Eppstein
+*********************************************************************/
+#include "triangle.h"
+#include <cmath>
+
+triangle::triangle(){}
+
+double triangle::area() const {
+ return side_length_ * side_length_ * sqrt(3) / 2;
+}
Added: pkg/trunk/sandbox/plugin_provider/triangle.h
===================================================================
--- pkg/trunk/sandbox/plugin_provider/triangle.h (rev 0)
+++ pkg/trunk/sandbox/plugin_provider/triangle.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,47 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Willow Garage, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Author: Eitan Marder-Eppstein
+*********************************************************************/
+#ifndef TRIANGLE_H_
+#define TRIANGLE_H_
+
+#include "polygon.h"
+
+class triangle : public polygon {
+public:
+ triangle();
+ virtual double area() const;
+};
+#endif
Modified: pkg/trunk/sandbox/pluginlib/CMakeLists.txt
===================================================================
--- pkg/trunk/sandbox/plugin_user/CMakeLists.txt 2009-08-07 01:30:35 UTC (rev 20976)
+++ pkg/trunk/sandbox/pluginlib/CMakeLists.txt 2009-08-07 01:47:21 UTC (rev 20982)
@@ -9,30 +9,15 @@
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)
-rospack(plugin_user)
+rospack(pluginlib)
#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
-#uncomment if you have defined messages
-#genmsg()
-#uncomment if you have defined services
-#gensrv()
-
-#common commands for building c++ executables and libraries
-#rospack_add_library(${PROJECT_NAME} src/example.cpp)
-#target_link_libraries(${PROJECT_NAME} another_library)
rospack_add_boost_directories()
-#rospack_link_boost(example system)
-#rospack_add_executable(example examples/example.cpp)
-#target_link_libraries(example ${PROJECT_NAME})
-rospack_add_executable(simple_test main.cpp)
-rospack_add_library(foo lib.cpp)
-target_link_libraries(simple_test dl)
-
rospack_add_executable(example example.cpp)
rospack_link_boost(example filesystem)
target_link_libraries(example PocoUtil)
Modified: pkg/trunk/sandbox/pluginlib/example.cpp
===================================================================
--- pkg/trunk/sandbox/plugin_user/example.cpp 2009-08-07 01:30:35 UTC (rev 20976)
+++ pkg/trunk/sandbox/pluginlib/example.cpp 2009-08-07 01:47:21 UTC (rev 20982)
@@ -27,18 +27,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include "polygon.hpp"
-#include "shape.hpp"
+#include "polygon.h"
+#include "shape.h"
#include <iostream>
-#include "Poco/ClassLoader.h"
#include "ros/package.h"
-#include "class_loader.h"
+#include "pluginlib/plugin_loader.h"
int main() {
- ros::ClassLoader<polygon> cl("plugin_user", "polygon");
+ pluginlib::PluginLoader<polygon> cl("pluginlib", "polygon");
std::cout << "Created Class Loader of polygon" << std::endl;
std::cout << "Available plugins are:" << std::endl;
@@ -85,7 +84,7 @@
if (!cl.loadPlugin("line"))
std::cerr<< "Correctly failed to load line in polygon loader" << std::endl;
- ros::ClassLoader<shape> ph("plugin_user", "shape");
+ pluginlib::PluginLoader<shape> ph("pluginlib", "shape");
if (!ph.loadPlugin("line"))
std::cerr<<"Failed to load line" << std::endl;
Added: pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader.h
===================================================================
--- pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader.h (rev 0)
+++ pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2009, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef PLUGINLIB_PLUGIN_LOADER_H
+#define PLUGINLIB_PLUGIN_LOADER_H
+
+#include <iostream>
+
+#include "Poco/ClassLoader.h"
+#include "ros/package.h"
+#include "tinyxml/tinyxml.h"
+#include <vector>
+#include <map>
+
+#include "boost/filesystem.hpp"
+
+namespace fs = boost::filesystem;
+
+
+
+namespace pluginlib
+{
+
+ template <class T>
+ class PluginLoader
+ {
+ private:
+ typedef std::map<std::string, unsigned int> LibraryCountMap;
+
+
+ class Plugin
+ {
+ public:
+ Plugin(const std::string& name, const std::string& class_name, const std::string& type, const std::string& package,
+ const std::string& description, const std::string& library_path):
+ name_(name),
+ class_name_(class_name),
+ type_(type),
+ package_(package),
+ description_(description),
+ library_path_ (library_path){};
+ std::string name_;
+ std::string class_name_;
+ std::string type_;
+ std::string package_;
+ std::string description_;
+ std::string library_path_;
+
+ };
+
+ typedef typename std::map<std::string, Plugin>::iterator PluginMapIterator;
+
+ public:
+
+ PluginLoader(std::string package, std::string plugin_type);
+
+ bool loadPlugin(const std::string & plugin_name);
+
+ ~PluginLoader();
+
+
+ bool isPluginLoaded(const std::string& name);
+
+ std::vector<std::string> getDeclaredPlugins();
+
+ std::string getPluginClass(const std::string& plugin_name);
+
+ std::string getPluginDescription(const std::string& plugin_name);
+
+ std::string getPluginType(const std::string& plugin_name);
+
+ std::string getPluginLibraryPath(const std::string& plugin_name);
+
+ std::string getPluginPackage(const std::string& plugin_name);
+
+ T* createPluginInstance(const std::string& name, bool auto_load_plugin = true);
+
+ void unloadPluginLibrary(const std::string& library_path);
+
+ void loadPluginLibrary(const std::string& library_path);
+
+ std::vector<std::string> getPluginsInLibrary(const std::string & library_path);
+
+ std::vector<std::string> getLoadedLibraries();
+
+ private:
+
+ //used for proper unloading of automatically loaded libraries
+ LibraryCountMap loaded_libraries_;
+
+
+ // map from library to plugin's descriptions
+ // This is all available plugins found in xml
+ std::map<std::string, Plugin> plugins_available_;
+
+ Poco::ClassLoader<T> poco_class_loader_;
+ };
+
+};
+
+#include "plugin_loader_imp.h"
+
+#endif //PLUGINLIB_PLUGIN_LOADER_H
Added: pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader_imp.h
===================================================================
--- pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader_imp.h (rev 0)
+++ pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_loader_imp.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,321 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Willow Garage, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Author: Eitan Marder-Eppstein
+*********************************************************************/
+
+//NOTE: this should really never be included on its own, but just in case someone is bad we'll guard
+
+#ifndef PLUGINLIB_PLUGIN_LOADER_IMP_H_
+#define PLUGINLIB_PLUGIN_LOADER_IMP_H_
+
+#include <stdexcept>
+
+namespace pluginlib {
+ template <class T>
+ PluginLoader<T>::PluginLoader(std::string package, std::string plugin_type)
+ {
+ //Pull possible files from manifests of packages which depend on this package and export plugin
+ std::vector<std::string> paths;
+
+ ros::package::getPlugins(package, plugin_type, paths);
+
+ //The poco factory for base class T
+ for (std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); ++it)
+ {
+ TiXmlDocument document;
+ document.LoadFile(*it);
+
+ TiXmlElement* library = document.FirstChildElement( "library" );
+ if ( library )
+ {
+ std::string library_path = library->Attribute("path");
+ if (library_path.size() == 0)
+ {
+ std::cerr << "Failed to find Path Attirbute in library element in " << it->c_str() << std::endl;
+ continue;
+ }
+
+ std::string package_name;
+
+ fs::path p(*it);
+ fs::path parent = p.parent_path();
+ // figure out the package this plugin is part of
+ while (true)
+ {
+ if (fs::exists(parent / "manifest.xml"))
+ {
+ std::string package = parent.filename();
+ std::string package_path = ros::package::getPath(package);
+ if (it->find(package_path) == 0)
+ {
+ package_name = package;
+ break;
+ }
+ }
+
+ parent = parent.parent_path();
+
+ if (parent.string().empty())
+ {
+ std::cerr << "Could not find package name for plugin" << *it << std::endl;
+ break;
+ }
+ }
+ fs::path full_library_path(parent / library_path);
+
+ TiXmlElement* plugin = library->FirstChildElement( "plugin" );
+ while (plugin)
+ {
+ // register plugin here
+ TiXmlElement* description = plugin->FirstChildElement( "description" );
+ std::string description_str = description->GetText();
+
+ std::string plugin_name = plugin->Attribute("name");
+ std::string plugin_class_name = plugin->Attribute("class");
+
+ plugins_available_.insert(std::pair<std::string, Plugin>(plugin_name, Plugin(plugin_name, plugin_class_name, plugin_type, package_name, description_str, full_library_path.string())));
+
+
+ //step to next plugin
+ plugin = plugin->NextSiblingElement( "plugin" );
+ }
+
+
+ }
+ }
+
+ }
+
+ template <class T>
+ bool PluginLoader<T>::loadPlugin(const std::string & plugin_name)
+ {
+ std::string library_path;
+ PluginMapIterator it = plugins_available_.find(plugin_name);
+ if (it != plugins_available_.end())
+ library_path = it->second.library_path_;
+ else
+ {
+ std::cerr<< "Couldn't find plugin "<<plugin_name << std::endl;
+ return false;
+ }
+ library_path.append(Poco::SharedLibrary::suffix());
+ std::cout << "Loading library " << library_path << std::endl;
+ try
+ {
+ loadPluginLibrary(library_path);
+ //poco_assert (poco_class_loader_.isLibraryLoaded(library_path));
+ //zpoco_check_ptr (poco_class_loader_.findManifest(library_path));
+ }
+ catch (Poco::LibraryLoadException &ex)
+ {
+ std::cerr << "Failed to load library " << library_path << ex.what() << std::endl;
+ return false;
+ }
+ catch (Poco::NotFoundException &ex)
+ {
+ std::cerr << "Failed to find library " << library_path << ex.what() << std::endl;
+ return false;
+ }
+ return true;
+ }
+
+ template <class T>
+ PluginLoader<T>::~PluginLoader()
+ {
+ for (LibraryCountMap::iterator it = loaded_libraries_.begin(); it != loaded_libraries_.end(); ++it)
+ {
+ if ( it->second > 0)
+ unloadPluginLibrary(it->first);
+ }
+ }
+
+
+ template <class T>
+ bool PluginLoader<T>::isPluginLoaded(const std::string& name)
+ {
+ try
+ {
+ return poco_class_loader_.canCreate(getPluginClass(name));
+ }
+ catch (Poco::RuntimeException &ex)
+ {
+ return false;
+ }
+ }
+
+ template <class T>
+ std::vector<std::string> PluginLoader<T>::getDeclaredPlugins()
+ {
+ std::vector<std::string> plugin_names;
+ for (PluginMapIterator it = plugins_available_.begin(); it != plugins_available_.end(); ++it)
+ {
+ plugin_names.push_back(it->first);
+ }
+ return plugin_names;
+ }
+
+ template <class T>
+ std::string PluginLoader<T>::getPluginClass(const std::string& plugin_name)
+ {
+ PluginMapIterator it = plugins_available_.find(plugin_name);
+ if (it != plugins_available_.end())
+ return it->second.class_name_;
+ return "";
+ }
+
+ template <class T>
+ std::string PluginLoader<T>::getPluginDescription(const std::string& plugin_name)
+ {
+ PluginMapIterator it = plugins_available_.find(plugin_name);
+ if (it != plugins_available_.end())
+ return it->second.description_;
+ return "";
+ }
+
+ template <class T>
+ std::string PluginLoader<T>::getPluginType(const std::string& plugin_name)
+ {
+ PluginMapIterator it = plugins_available_.find(plugin_name);
+ if (it != plugins_available_.end())
+ return it->second.type_;
+ return "";
+ }
+
+ template <class T>
+ std::string PluginLoader<T>::getPluginLibraryPath(const std::string& plugin_name)
+ {
+ PluginMapIterator it = plugins_available_.find(plugin_name);
+ if (it != plugins_available_.end())
+ return it->second.library_path_;
+ return "";
+ }
+
+ template <class T>
+ std::string PluginLoader<T>::getPluginPackage(const std::string& plugin_name)
+ {
+ PluginMapIterator it = plugins_available_.find(plugin_name);
+ if (it != plugins_available_.end())
+ return it->second.package_;
+ return "";
+ }
+
+ template <class T>
+ T* PluginLoader<T>::createPluginInstance(const std::string& name, bool auto_load_plugin)
+ {
+ if ( auto_load_plugin && !isPluginLoaded(name))
+ if(!loadPlugin(name))
+ {
+ //\todo THROW HERE
+ std::cerr <<"Failed to auto load library" << std::endl;
+ return NULL;
+ throw std::runtime_error("Failed to auto load library for plugin " + name + ".");
+ }
+
+ //\todo rethrow with non poco Exceptions
+ try{
+ return poco_class_loader_.create(getPluginClass(name));
+ }
+ catch(const Poco::RuntimeException& ex){
+ throw std::runtime_error(ex.what());
+ }
+ }
+
+ template <class T>
+ void PluginLoader<T>::unloadPluginLibrary(const std::string& library_path)
+ {
+ LibraryCountMap::iterator it = loaded_libraries_.find(library_path);
+ if (it == loaded_libraries_.end())
+ {
+ std::cerr << "unable to unload library which is not loaded" << std::endl;
+ return;
+ }
+ else if (it-> second > 1)
+ (it->second)--;
+ else
+ poco_class_loader_.unloadLibrary(library_path);
+
+ }
+
+ template <class T>
+ void PluginLoader<T>::loadPluginLibrary(const std::string& library_path)
+ {
+ poco_class_loader_.loadLibrary(library_path);
+ LibraryCountMap::iterator it = loaded_libraries_.find(library_path);
+ if (it == loaded_libraries_.end())
+ loaded_libraries_[library_path] = 1; //for correct destruction and access
+ else
+ loaded_libraries_[library_path] = loaded_libraries_[library_path] + 1;
+ }
+
+ template <class T>
+ std::vector<std::string> PluginLoader<T>::getPluginsInLibrary(const std::string & library_path)
+ {
+ std::vector<std::string> plugin_names;
+
+
+ const Poco::Manifest<T> * manifest = poco_class_loader_.findManifest(library_path);
+ if (manifest == NULL)
+ return plugin_names;
+
+ for (typename Poco::Manifest<T>::Iterator it = manifest->begin(); it != manifest->end(); ++it)
+ {
+ plugin_names.push_back(it->name());
+ }
+ return plugin_names;
+ }
+
+ template <class T>
+ std::vector<std::string> PluginLoader<T>::getLoadedLibraries()
+ {
+ std::vector<std::string> library_names;
+
+ /*
+ \todo find a way to get ths out of poco
+ for (typename Poco::ClassLoader<T>::Iterator it = poco_class_loader_.begin(); it != poco_class_loader_.end(); ++it)
+ {
+ library_names.push_back(it->second->className());
+ }
+ return library_names;
+ */
+ LibraryCountMap::iterator it;
+ for (it = loaded_libraries_.begin(); it != loaded_libraries_.end(); it++)
+ {
+ if (it->second > 0)
+ library_names.push_back(it->first);
+ }
+ return library_names;
+ }
+};
+#endif
Added: pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_macros.h
===================================================================
--- pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_macros.h (rev 0)
+++ pkg/trunk/sandbox/pluginlib/include/pluginlib/plugin_macros.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,50 @@
+/*********************************************************************
+*
+* Software License Agreement (BSD License)
+*
+* Copyright (c) 2008, Willow Garage, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Willow Garage, Inc. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+* Author: Eitan Marder-Eppstein
+*********************************************************************/
+#ifndef PLUGINLIB_PLUGIN_MACROS_H_
+#define PLUGINLIB_PLUGIN_MACROS_H_
+#include "Poco/ClassLibrary.h"
+
+#define BEGIN_PLUGIN_LIST(base_class) \
+ POCO_BEGIN_MANIFEST(base_class)
+
+#define REGISTER_PLUGIN(plugin_class) \
+ POCO_EXPORT_CLASS(plugin_class)
+
+#define END_PLUGIN_LIST \
+ POCO_END_MANIFEST
+
+#endif
Modified: pkg/trunk/sandbox/pluginlib/manifest.xml
===================================================================
--- pkg/trunk/sandbox/plugin_user/manifest.xml 2009-08-07 01:30:35 UTC (rev 20976)
+++ pkg/trunk/sandbox/pluginlib/manifest.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -1,10 +1,10 @@
<package>
- <description brief="a package to experiment with plugin use">
+ <description brief="Tools for creating and using plugins with ROS">
- a package to experiment with plugin use
+ Tools for creating and using plugins with ROS, leveraging ROS manifests for automatic discovery of plugins.
</description>
- <author>Tully Foote</author>
+ <author>Tully Foote and Eitan Marder-Eppstein</author>
<license>BSD</license>
<review status="experimental" notes=""/>
<url>http://pr.willowgarage.com/wiki/plugin_user</url>
@@ -13,7 +13,7 @@
<depend package="tinyxml"/>
<export>
- <cpp cflags="-I${prefix}"/>
+ <cpp cflags="-I${prefix}/include -I${prefix} `rosboost-cfg --cflags`" lflags="-lPocoUtil `rosboost-cfg -l filesystem`"/>
</export>
<rosdep name="libpoco"/>
Added: pkg/trunk/sandbox/pluginlib/polygon.h
===================================================================
--- pkg/trunk/sandbox/pluginlib/polygon.h (rev 0)
+++ pkg/trunk/sandbox/pluginlib/polygon.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2009, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef POLYGON_HPP
+#define POLYGON_HPP
+
+#include <string>
+#include <set>
+#include <vector>
+#include <iostream>
+
+#include "boost/algorithm/string.hpp"
+
+template<class T>
+class base_polygon
+{
+public:
+ base_polygon(): side_length_(0) {};
+protected:
+ T side_length_;
+};
+
+class polygon : public base_polygon<double>{
+
+public:
+ polygon(){}
+
+ virtual ~polygon() {}
+
+ void set_side_length(double side_length) {
+ side_length_ = side_length;
+ }
+
+ virtual double area() const = 0;
+};
+
+
+
+
+
+#endif
Added: pkg/trunk/sandbox/pluginlib/shape.h
===================================================================
--- pkg/trunk/sandbox/pluginlib/shape.h (rev 0)
+++ pkg/trunk/sandbox/pluginlib/shape.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2009, Willow Garage, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Willow Garage, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SHAPE_HPP
+#define SHAPE_HPP
+
+#include <string>
+#include <set>
+#include <vector>
+#include <iostream>
+
+#include "boost/algorithm/string.hpp"
+
+template<class T>
+class base_shape
+{
+public:
+ base_shape(): side_length_(0) {};
+protected:
+ T side_length_;
+};
+
+class shape : public base_shape<double>{
+
+public:
+ shape(){}
+
+ virtual ~shape() {}
+
+ void set_side_length(double side_length) {
+ side_length_ = side_length;
+ }
+
+ virtual double area() const = 0;
+};
+
+
+
+#endif
Added: pkg/trunk/stacks/navigation/base_local_planner/blp_plugin.xml
===================================================================
--- pkg/trunk/stacks/navigation/base_local_planner/blp_plugin.xml (rev 0)
+++ pkg/trunk/stacks/navigation/base_local_planner/blp_plugin.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -0,0 +1,7 @@
+<library path="lib/libbase_local_planner">
+ <plugin name="TrajectoryPlannerROS" class="base_local_planner::TrajectoryPlannerROS" type="nav_core::BaseLocalPlanner">
+ <description>
+ A implementation of a local planner using either a DWA or Trajectory Rollout approach based on configuration parameters.
+ </description>
+ </plugin>
+</library>
Modified: pkg/trunk/stacks/navigation/base_local_planner/include/base_local_planner/trajectory_planner_ros.h
===================================================================
--- pkg/trunk/stacks/navigation/base_local_planner/include/base_local_planner/trajectory_planner_ros.h 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/stacks/navigation/base_local_planner/include/base_local_planner/trajectory_planner_ros.h 2009-08-07 01:47:21 UTC (rev 20982)
@@ -65,25 +65,39 @@
#include <angles/angles.h>
-#include <nav_robot_actions/base_local_planner.h>
+#include <nav_core/base_local_planner.h>
namespace base_local_planner {
/**
* @class TrajectoryPlannerROS
* @brief A ROS wrapper for the trajectory controller that queries the param server to construct a controller
*/
- class TrajectoryPlannerROS : public nav_robot_actions::BaseLocalPlanner {
+ class TrajectoryPlannerROS : public nav_core::BaseLocalPlanner {
public:
/**
+ * @brief Default constructor for the ros wrapper
+ */
+ TrajectoryPlannerROS();
+
+ /**
* @brief Constructs the ros wrapper
* @param name The name to give this instance of the trajectory planner
- * @param tf A reference to a transform listener
+ * @param tf A pointer to a transform listener
* @param costmap The cost map to use for assigning costs to trajectories
*/
- TrajectoryPlannerROS(std::string name, tf::TransformListener& tf,
- costmap_2d::Costmap2DROS& costmap_ros);
+ TrajectoryPlannerROS(std::string name, tf::TransformListener* tf,
+ costmap_2d::Costmap2DROS* costmap_ros);
/**
+ * @brief Constructs the ros wrapper
+ * @param name The name to give this instance of the trajectory planner
+ * @param tf A pointer to a transform listener
+ * @param costmap The cost map to use for assigning costs to trajectories
+ */
+ void initialize(std::string name, tf::TransformListener* tf,
+ costmap_2d::Costmap2DROS* costmap_ros);
+
+ /**
* @brief Destructor for the wrapper
*/
~TrajectoryPlannerROS();
@@ -197,10 +211,9 @@
WorldModel* world_model_; ///< @brief The world model that the controller will use
TrajectoryPlanner* tc_; ///< @brief The trajectory controller
- costmap_2d::Costmap2DROS& costmap_ros_; ///< @brief The ROS wrapper for the costmap the controller will use
+ costmap_2d::Costmap2DROS* costmap_ros_; ///< @brief The ROS wrapper for the costmap the controller will use
costmap_2d::Costmap2D costmap_; ///< @brief The costmap the controller will use
- tf::TransformListener& tf_; ///< @brief Used for transforming point clouds
- ros::NodeHandle ros_node_; ///< @brief The ros node we're running under
+ tf::TransformListener* tf_; ///< @brief Used for transforming point clouds
std::string global_frame_; ///< @brief The frame in which the controller will run
double max_sensor_range_; ///< @brief Keep track of the effective maximum range of our sensors
deprecated_msgs::RobotBase2DOdom base_odom_; ///< @brief Used to get the velocity of the robot
@@ -213,6 +226,7 @@
ros::Publisher footprint_pub_, g_plan_pub_, l_plan_pub_;
ros::Subscriber odom_sub_;
boost::recursive_mutex odom_lock_;
+ bool initialized_;
};
};
Modified: pkg/trunk/stacks/navigation/base_local_planner/manifest.xml
===================================================================
--- pkg/trunk/stacks/navigation/base_local_planner/manifest.xml 2009-08-07 01:44:50 UTC (rev 20981)
+++ pkg/trunk/stacks/navigation/base_local_planner/manifest.xml 2009-08-07 01:47:21 UTC (rev 20982)
@@ -15,13 +15,15 @@
<depend package="tf" />
<depend package="roslib" />
<depend package="rospy" />
+ <depend package="pluginlib" />
<depend pac...
[truncated message content] |