my main code cannot find my header file
I have a package called "motor_driver" that has a 'src' folder and an 'include' folder along with the CMakeLists.txt and the Package.xml. In the 'src' folder I have a file called ego_points.cpp and in the 'include' folder i have a header file called motor_driver.h.
In the ego_points.cpp file, I include the motor_driver.h file but when I run catkin_make in my workspace I get the following error:
/home/student/Desktop/Naes_Thesis/src/motor_driver/src/ego_points.cpp:7:26: fatal error: motor_driver.h: No such file or directory
#include "motor_driver.h"
^
compilation terminated.
make[2]: *** [motor_driver/CMakeFiles/motor_driver_node.dir/src/ego_points.cpp.o] Error 1
make[1]: *** [motor_driver/CMakeFiles/motor_driver_node.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
My CMakeLists.txt and my ego_points.cpp are provided below. Could someone please tell me what I am doing wrong? Thank you in advance.
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(motor_driver)
find_package(catkin REQUIRED COMPONENTS
rplidar_ros
roscpp
serial
std_msgs
sensor_msgs
message_generation
)
add_message_files(FILES
Motor_speeds.msg
cartesian.msg
)
generate_messages(DEPENDENCIES
std_msgs
sensor_msgs
motor_driver
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS rospy roscpp serial std_msgs message_runtime rplidar_ros sensor_msgs
)
include_directories(
/src
/launch
/include
${catkin_INCLUDE_DIRS}
)
add_executable(${PROJECT_NAME}_node src/ego_points.cpp)
target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES})
add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
install(TARGETS ${PROJECT_NAME}_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY include
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
)
install(FILES
ego_points.launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
ego_points.cpp:
#include "ros/ros.h"
#include "sensor_msgs/LaserScan.h"
#include "iostream"
#include "string"
#include "motor_driver/Motor_speeds.h"
#include "motor_driver/cartesian.h"
#include "motor_driver.h"
using namespace std;
using namespace motor_driver;
Points p1;
int main(int argc, char** argv) {
ros::init(argc, argv, "motor_driver_node");
ros::NodeHandle nh;
ros::Subscriber sub;
p1 = new Points();
ros::Rate r(1);
while (ros::ok) {
sub = nh.subscribe<sensor_msgs::LaserScan>("/scan",10, &p1.ScanCallback);
cout << "This is in the main loop" << endl;
cout << "This is the first value of p1 scanned data: " << p1.scannedData[0] << endl;
r.sleep();
ros::spin();
}
return 0;
}