I am trying to compile a project with ROS on a JetsonTX1 that was flashed with Jetpack 3.2.1,
When I run catkin_make on my work space(catkin_ws) this output:
I really do not know what to do
I read that is problem with flags and the cmake file. I really will appreciate your help.
/usr/bin/ld: CMakeFiles/drive_train.dir/src/drive_train.cpp.o: undefined reference to symbol '_ZN2cv11VideoWriterC1Ev'
//usr/lib/libopencv_highgui.so.2.4: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
JetLabs/lab4_autonomous_driving/CMakeFiles/drive_train.dir/build.make:154: recipe for target '/home/ubuntu/FOLDER_FOR_ROS/catkin_ws/devel/lib/lab4_autonomous_driving/drive_train' failed
make[2]: *** [/home/ubuntu/FOLDER_FOR_ROS/catkin_ws/devel/lib/lab4_autonomous_driving/drive_train] Error 1
CMakeFiles/Makefile2:4644: recipe for target 'JetLabs/lab4_autonomous_driving/CMakeFiles/drive_train.dir/all' failed
make[1]: *** [JetLabs/lab4_autonomous_driving/CMakeFiles/drive_train.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 25%] Built target rosserial_arduino_generate_messages_py
[ 27%] Built target rosserial_arduino_generate_messages_nodejs
[ 31%] Built target rosserial_arduino_generate_messages_eus
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
My cmake file
cmake_minimum_required(VERSION 2.8.3) project(lab4_autonomous_driving)
set(CMAKE_CXX_FLAGS "-DCPU_ONLY -std=c++0x ${CMAKE_CXX_FLAGS}")
set(CAFFE_LINK_LIBRARAY ~/caffe/build/lib)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs cv_bridge image_transport )
find_package(OpenCV REQUIRED)
catkin_package( INCLUDE_DIRS include LIBRARIES ${PROJECT_NAME} CATKIN_DEPENDS roscpp rospy std_msgs cv_bridge image_transport )
add_library(${PROJECT_NAME} src/classifier.cpp src/drive_inference.cpp)
include_directories( "~/caffe/include" "~/caffe/build/src" ${catkin_INCLUDE_DIRS} include ${catkin_INCLUDE_DIRS} )
link_directories(${CAFFE_LINK_LIBRARAY})
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )
install(PROGRAMS scripts/preprocess.py DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} )
add_executable(drive_train src/drive_train.cpp src/classifier.cpp) target_link_libraries(drive_train ${catkin_LIBRARIES} caffe glog)
add_executable(drive_inference src/drive_inference.cpp src/classifier.cpp) target_link_libraries(drive_inference ${catkin_LIBRARIES} caffe glog)
my drive train file
#include <math.h>
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <cv_bridge/cv_bridge.h>
#include "geometry_msgs/Twist.h"
#include <ros/package.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <lab4_autonomous_driving/classifier.h>
using namespace cv;
using namespace std;
using namespace geometry_msgs;
string base_path, vid_path, data_path;
Mat src;
VideoWriter* vidFile;
image_transport::Subscriber raw_image_sub;
ros::Subscriber twist_sub;
ofstream dataFile;
double lin_x, ang_z;
void imageCallback(const sensor_msgs::ImageConstPtr& msg) {
try
{
ROS_INFO("%f\n", lin_x);
src = cv_bridge::toCvShare(msg, "bgr8")->image;
if(lin_x > 0.0) {
dataFile << FORWARD_DIR << endl;
*vidFile << src;
}
else if (ang_z > 0.0) {
dataFile << RIGHT_DIR << endl;
*vidFile << src;
}
else if (ang_z < 0.0) {
dataFile << LEFT_DIR << endl;
*vidFile << src;
}
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str());
}
}
void twistCallback(const Twist::ConstPtr& msg) {
lin_x = msg->linear.x;
ang_z = msg->angular.z;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "drive_train");
ros::NodeHandle nh;
image_transport::ImageTransport it(nh);
//subscribe to the raw usb camera image
raw_image_sub = it.subscribe("/usb_cam/image_raw", 10, imageCallback);
//subscribe to the velocity vector
twist_sub = nh.subscribe("/cmd_vel", 10, twistCallback);
base_path = ros::package::getPath("lab4_autonomous_driving") + "/resources/raw/" + to_string((int)ros::Time::now().toSec());
vid_path = base_path + ".avi";
data_path = base_path + ".csv";
vidFile = new VideoWriter();
vidFile->open(vid_path, CV_FOURCC('M','J','P','G'), 30, cv::Size(320,240));
dataFile.open(data_path.c_str());
ros::spin();
}