Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
triccyx committed May 27, 2019
1 parent 74745fe commit d6af557
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
1 change: 1 addition & 0 deletions genericactiondepotlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/../src)

target_link_libraries(${PROJECT_NAME} BlockTestCore ${Boost_LIBRARIES} Pugixml::Pugixml)

# Add install target
set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME})
Expand Down
4 changes: 2 additions & 2 deletions genericactiondepotlib/src/genericActionDepotStart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ void Start(char* data,char* name)
{
if(data)
{
TXLOG(Severity::info)<<"Library start called:"<<data<<std::endl;
//TXLOG(Severity::info)<<"Library start called:"<<data<<std::endl;
start.configure(data,name);
}
}

void Stop(char* data,char* name)
{
TXLOG(Severity::info)<<"Library stop called:"<<std::endl;
//TXLOG(Severity::info)<<"Library stop called:"<<std::endl;
}


4 changes: 2 additions & 2 deletions src/clockFacility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool ClockFacility::wait(double value) const

CommandAttributes commandAttributes{{"command","wait"},{"seconds",std::to_string(value)},{"reporterror","false"}};

auto action=(call)(commandAttributes,nullptr);
auto action=(call)(commandAttributes,"");
action->execute(0);
}
else
Expand All @@ -58,7 +58,7 @@ std::string ClockFacility::now() const

CommandAttributes commandAttributes{{"command","wait"},{"reporterror","false"}};

auto action=(call)(commandAttributes,nullptr);
auto action=(call)(commandAttributes,"");
std::stringstream ss;
ss<<std::setfill('0')<<std::setw(8)<<std::setprecision(4)<<action->getDouble();
return ss.str();
Expand Down
27 changes: 13 additions & 14 deletions src/libraryLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LibraryLoader::LibraryLoader()

bool LibraryLoader::load(const std::string& path)
{
TXLOG(Severity::debug)<<"LibraryLoader constructor"<<std::endl;
std::string completePath;
if(!path.empty())
completePath=path+"/"+testName_;
Expand All @@ -47,26 +48,24 @@ bool LibraryLoader::load(const std::string& path)
pugi::xpath_node nodeLibrary = *it;
std::string currentPath=nodeLibrary.node().attribute("path").as_string();
std::string libraryName=nodeLibrary.node().attribute("name").as_string();
TXLOG(Severity::info)<<"Try load lib:"<<currentPath<<std::endl;
std::string extension;
#ifdef _WIN32
extension=".dll";
#else
extension=".so";
#endif
TXLOG(Severity::info)<<"Try load lib:"<<currentPath<<extension<<std::endl;

try
{
void* handle = dlopen(currentPath.c_str(), RTLD_LAZY);
if (!handle) {
/* fail to load the library */
fprintf(stderr, "Error: %s\n", dlerror());
return EXIT_FAILURE;
}


boost::function<funcptr> startFunction = boost::dll::import<funcptr>(
currentPath,
currentPath+extension,
"Start",
boost::dll::load_mode::rtld_lazy
);

boost::function<funcptr> stopFunction = boost::dll::import<funcptr>(
currentPath,
currentPath+extension,
"Stop",
boost::dll::load_mode::rtld_lazy
);
Expand All @@ -77,17 +76,17 @@ bool LibraryLoader::load(const std::string& path)
startFunction((char*)completePath.c_str(),(char*)libraryName.c_str());
}
catch(boost::exception const& e) {
std::cout<<"xxxxxxxxxxxxxxxxxxx"<<boost::diagnostic_information(e, true)<<std::endl;
TXLOG(Severity::critical)<<"Custom lib:"<<currentPath<<" error missing Start/Stop function in lib----"<<boost::diagnostic_information(e, true)<<std::endl;
TXLOG(Severity::critical)<<"Custom lib:"<<currentPath<<extension<<" error missing Start/Stop function in lib----"<<boost::diagnostic_information(e, true)<<std::endl;
return false;
}
TXLOG(Severity::info)<<"Custom ok:"<<currentPath<<std::endl;
TXLOG(Severity::info)<<"Load lib ok:"<<currentPath<<extension<<std::endl;
}
return true;
}

LibraryLoader::~LibraryLoader()
{
TXLOG(Severity::debug)<<"LibraryLoader destructor"<<std::endl;
for(auto current:stopFunction_)
{
if(current)
Expand Down
2 changes: 0 additions & 2 deletions src/testsDepot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ TestsDepot::~TestsDepot()

bool TestsDepot::load(const std::string& path)
{
TXLOG(Severity::info)<<"Try load library"<<std::endl;

std::string completePath;
if(!path.empty())
completePath=path+"/"+testName_;
Expand Down
6 changes: 3 additions & 3 deletions test/test.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<testlist repetitions="1">
<settings robotname="icubSim" realrobot="false" onlysimcommands="yarpcheckrobotisvertical checkRobot yarpreset applyForce" netclock="true" neverexecutecommands="" logseverity="debug" loggingtime="0.01" tablename="test/tables/main.tab" waitcommand="yarpwait" nowcommand="yarpnow" loggingcommand="infologgeryarp" />
<library enabled="true" path="genericactiondepot/genericactiondepot.so" name="genericactiondepot" note="System generic action library" />
<library enabled="true" path="yarpactiondepot/yarpactiondepot.so" name="yarpactiondepot" note="Yarp action library" />
<library enabled="true" path="genericactiondepot/genericactiondepot" name="genericactiondepot" note="System generic action library" />
<library enabled="true" path="yarpactiondepot/yarpactiondepot" name="yarpactiondepot" note="Yarp action library" />
<librarysettings enabled="true" name="genericactiondepot" />
<librarysettings enabled="true" name="yarpactiondepot" wrappername="/right_leg /left_leg /torso /head /right_arm /left_arm" />
<test file="test/0001.xml" repetitions="0" code="0001" />
Expand All @@ -14,7 +14,7 @@
<prerequisite enabled="true" command="yarpserver" waitafter="5000" param="--silent" prefix="" kill="true" />
<prerequisite enabled="false" command="gzserver" waitafter="5000" param="--verbose -e ode --profile ode_default -slibgazebo_yarp_clock.so icub.world" prefix="" kill="true" />
<prerequisite enabled="true" command="gzserver" waitafter="5000" param="--verbose -e ode --profile ode_default -slibgazebo_yarp_clock.so icub_fixed.world" prefix="" kill="true" />
<prerequisite enabled="true" command="gzclient" waitafter="5000" param="" prefix="" kill="true" />
<prerequisite enabled="false" command="gzclient" waitafter="5000" param="" prefix="" kill="true" />
<prerequisite enabled="false" command="yarpdev" waitafter="5000" param="--device transformServer --ROS::enable_ros_publisher 1 --ROS::enable_ros_subscriber 1 --transforms_lifetime 0.5" prefix="YARP_CLOCK=/clock" kill="true" />
<prerequisite enabled="false" command="yarprobotinterface" waitafter="5000" param="--config main-fbe.xml" prefix="" kill="true" />
<prerequisite enabled="false" command="roslaunch" waitafter="5000" param="icub robotStatePublisher.launch" prefix="" kill="true" />
Expand Down
2 changes: 1 addition & 1 deletion yarpactiondepotlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ add_library(${PROJECT_NAME} MODULE ${allSrc})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")

target_include_directories(${PROJECT_NAME} PRIVATE ${YARP_HELPERS_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/../src)
target_link_libraries(${PROJECT_NAME} PRIVATE BlockTestCore YARP::YARP_OS YARP::YARP_init YARP::YARP_dev YARP::YARP_conf YARP::YARP_sig YARP::YARP_math YARP::YARP_rosmsg ClockRpc Pugixml::Pugixml)
target_link_libraries(${PROJECT_NAME} PRIVATE BlockTestCore ${Boost_LIBRARIES} YARP::YARP_OS YARP::YARP_init YARP::YARP_dev YARP::YARP_conf YARP::YARP_sig YARP::YARP_math YARP::YARP_rosmsg ClockRpc Pugixml::Pugixml)

# Add install target
set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}")
Expand Down
1 change: 1 addition & 0 deletions yarpactiondepotlib/src/yarpActionDepotStart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "pugixml.hpp"

static YarpActionDepotStart start;
std::string YarpActionDepotStart::robotName_{""};
std::map<std::string,PolyDriver_sptr> YarpActionDepotStart::polyDriverDepot_;

YarpActionDepotStart::YarpActionDepotStart()
Expand Down

0 comments on commit d6af557

Please sign in to comment.