When I run "roslaunch" there is the error:
[Err] [Plugin.hh:178] Failed to load plugin libmodel_push.so: /Robosub_Simulation/devel/lib/libmodel_push.so: undefined symbol: _ZN9ModelPush14SetJointStatesERKN5boost10shared_ptrIKN11sensor_msgs11JointState_ISaIvEEEEE
Can you guys please assist us with how to solve this error?
This probably has to do with including the library
#include <sensor_msgs/JointState.h>
and using it in the functions for the plugin called model_push.cpp:
void ModelPush::addSubscribeForce()
{
// ros::init("talker");
ros::NodeHandle* rosnode = new ros::NodeHandle();
ros::SubscribeOptions jointStatesSo = ros::SubscribeOptions::create<sensor_msgs::JointState>("/test", 1, SetJointStates,ros::VoidPtr(), rosnode->getCallbackQueue());
ros::Subscriber subJointState = rosnode->subscribe(jointStatesSo);
ros::spin();
}
static void SetJointStates(const sensor_msgs::JointState::ConstPtr &_js)
{
static ros::Time startTime = ros::Time::now();
{
std::cout<<"AYo"<<std::endl;
}
}
Lastly because this is a linker error here is the CMakeLists.txt that is in the plugin folder:
add_library(model_push SHARED model_push_plugin.cpp model_push.cpp)
add_dependencies(model_push ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(model_push ${catkin_LIBRARIES} ${GAZEBO_LIBRARIES} ${Boost_LIBRARIES})
I have already tried using QT5_WRAP_CPP instead for adding the dependencies (from https://answers.gazebosim.org/question/25672/gui-plugin-linker-error-undefined-symbol/) however that leads to the same error. Also, for some context, this code (please see the repository https://github.com/GU-RoboSub-Machine-Learning/Robosub_Simulation/tree/ros_listener) is meant to subscribe to a node called "test" and is based off this tutorial for subscribing to joint commands: http://gazebosim.org/tutorials?tut=drcsim_ros_cmds&cat=drcsim. Can guys you please provide suggestions on how to implement sensor_msgs/JointState correctly to not have the error, as shown in the beginning of this post?