Каким-то образом мой catkin_make
успешно выполнен, но run_test не выполнен.Я подтвердил, что добавил свой тестовый скрипт и мой код как исполняемый файл в CMakeList.txt и связал их, используя target_link_libraries
.Тем не менее, я получаю сообщение об ошибке при запуске Catkin_make run_tests
:
undefined reference to `VisualRobot::VisualRobot(std::shared_ptr<moveit::core::RobotModel>)'
Вот мой тестовый код:
#include <iostream>
#include <moveit_visual_tools/moveit_visual_tools.h>
#include <visualization_msgs/Marker.h>
#include <eigen_conversions/eigen_msg.h>
#include <tf/transform_datatypes.h>
#include <cmath>
#include "gtest/gtest.h"
#include "visual_robot.h"
class Checksweep : public testing::Test{
public:
virtual void SetUp() {
// ...
robot_model_loader::RobotModelLoader robot_model_loader("robot_description");
robot_model::RobotModelPtr kinematic_model = robot_model_loader.getModel();
visual = new VisualRobot(kinematic_model);
}
virtual void TearDown() { delete visual; }
VisualRobot * visual;
ros::NodeHandle nh;
};
TEST_F(Checksweep, TestnJoint)
{
EXPECT_GT(visual->nJoints, 0); //nJoints is a public variable in VisualRobot class.
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
ros::init(argc, argv, "my_testnode");
return RUN_ALL_TESTS();
}
И мой visual_robot.h:
#ifndef _VISUAL_ROBOT
#define _VISUAL_ROBOT
class VisualRobot{
public:
VisualRobot( robot_model::RobotModelPtr kinematic_model);
void make_function();
robot_model::RobotModelPtr kinematic_model;
int nJoints;
private:
ros::NodeHandle nh;
ros::Publisher marker_pub;
};
#endif
В моем понимании, я думал, что уже определил момент визуального робота в строке моего тестового кода VisualRobot * visual
Редактировать 1: Кроме того, похоже, что ошибка возникает в строке моего тестового кода:
visual = new VisualRobot(kinematic_model);
Редактировать 2: Добавлена часть моего CMakeList.txt:
add_executable(visual_robot src/visual_robot.cpp)
target_link_libraries(visual_robot ${catkin_LIBRARIES} ${Boost_LIBRARIES})
if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED)
add_rostest_gtest(visual_testnode launch/visual.launch src/visual_test.cpp )
target_link_libraries(visual_testnode ${catkin_LIBRARIES} )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
endif()