fix core dumped err when loadplugin
This commit is contained in:
@@ -48,6 +48,8 @@
|
||||
#include <tf3/utils.h>
|
||||
#include <exception>
|
||||
|
||||
#include <boost/dll/import.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace costmap_2d
|
||||
@@ -97,19 +99,19 @@ void Costmap2DROBOT::getParams(const std::string& config_file_name)
|
||||
robot::Time last_error = robot::Time::now();
|
||||
std::string tf_error;
|
||||
|
||||
// we need to make sure that the transform between the robot base frame and the global frame is available
|
||||
while (!tf_.canTransform(global_frame_, robot_base_frame_, tf3::Time::now(), &tf_error))
|
||||
{
|
||||
if (last_error + robot::Duration(5.0) < robot::Time::now())
|
||||
{
|
||||
printf("%f: Timed out waiting for transform from %s to %s to become available before running costmap, tf error: %s\n",
|
||||
robot::Time::now().toSec(), robot_base_frame_.c_str(), global_frame_.c_str(), tf_error.c_str());
|
||||
last_error = robot::Time::now();
|
||||
}
|
||||
// The error string will accumulate and errors will typically be the same, so the last
|
||||
// will do for the warning above. Reset the string here to avoid accumulation.
|
||||
tf_error.clear();
|
||||
}
|
||||
// // we need to make sure that the transform between the robot base frame and the global frame is available
|
||||
// while (!tf_.canTransform(global_frame_, robot_base_frame_, tf3::Time::now(), &tf_error))
|
||||
// {
|
||||
// if (last_error + robot::Duration(5.0) < robot::Time::now())
|
||||
// {
|
||||
// printf("%f: Timed out waiting for transform from %s to %s to become available before running costmap, tf error: %s\n",
|
||||
// robot::Time::now().toSec(), robot_base_frame_.c_str(), global_frame_.c_str(), tf_error.c_str());
|
||||
// last_error = robot::Time::now();
|
||||
// }
|
||||
// // The error string will accumulate and errors will typically be the same, so the last
|
||||
// // will do for the warning above. Reset the string here to avoid accumulation.
|
||||
// tf_error.clear();
|
||||
// }
|
||||
|
||||
// check if we want a rolling window version of the costmap
|
||||
bool rolling_window, track_unknown_space, always_send_full_costmap;
|
||||
@@ -121,10 +123,10 @@ void Costmap2DROBOT::getParams(const std::string& config_file_name)
|
||||
|
||||
struct PluginInfo { std::string path; std::string name; };
|
||||
std::vector<PluginInfo> plugins_to_load = {
|
||||
{"./costmap_2d/libstatic_layer.so", "static_layer"},
|
||||
{"./costmap_2d/libinflation_layer.so", "inflation_layer"},
|
||||
{"./costmap_2d/libobstacle_layer.so", "obstacle_layer"},
|
||||
{"./costmap_2d/libpreferred_layer.so", "preferred_layer"}
|
||||
{"./costmap_2d/libstatic_layer.so", "create_static_layer"},
|
||||
{"./costmap_2d/libinflation_layer.so", "create_inflation_layer"},
|
||||
{"./costmap_2d/libobstacle_layer.so", "create_obstacle_layer"},
|
||||
{"./costmap_2d/libpreferred_layer.so", "create_preferred_layer"}
|
||||
};
|
||||
|
||||
// if (private_nh.hasParam("plugins"))
|
||||
@@ -140,10 +142,11 @@ void Costmap2DROBOT::getParams(const std::string& config_file_name)
|
||||
try
|
||||
{
|
||||
// copyParentParameters(pname, type, private_nh);
|
||||
auto creator = boost::dll::import_alias<PluginLayerPtr()>(
|
||||
info.path, "create_plugin", boost::dll::load_mode::append_decorations
|
||||
creators_.push_back(
|
||||
boost::dll::import_alias<PluginLayerPtr()>(
|
||||
info.path, info.name, boost::dll::load_mode::append_decorations)
|
||||
);
|
||||
PluginLayerPtr plugin = creator();
|
||||
PluginLayerPtr plugin = creators_.back()();
|
||||
std::cout << "Plugin created: " << info.name << std::endl;
|
||||
plugin->initialize(layered_costmap_, info.name, &tf_);
|
||||
layered_costmap_->addPlugin(plugin);
|
||||
|
||||
Reference in New Issue
Block a user