ros::InvalidNameException error [closed]
Hello, I am trying to create an executable node called "motor_driver_node" in a package called "motor_driver". The purpose of this node is to run a C++ file called "ego_points.cpp". The node was created when I compiled my workspace with "catkin_make" however when I attempt to run the node, I get the following error:
student@MENG2321103LT02:~/Desktop/Naes_Thesis/src$ rosrun motor_driver motor_driver_node
terminate called after throwing an instance of 'ros::InvalidNameException'
what(): Character [.] at element [10] is not valid in Graph Resource Name [ego_points.cpp]. Valid characters are a-z, A-Z,
0-9, / and _.
Aborted (core dumped)
Here is my CMakeLists.txt file for the motor_driver_package:
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
)
find_package(Boost REQUIRED COMPONENTS system)
add_message_files(FILES
Motor_speeds.msg
cartesian.msg
)
generate_messages(DEPENDENCIES
std_msgs
sensor_msgs
motor_driver
)
catkin_package(
CATKIN_DEPENDS rospy roscpp serial std_msgs message_runtime rplidar_ros sensor_msgs
)
${catkin_EXPORTED_TARGETS})
add_executable(${PROJECT_NAME}_node src/ego_points.cpp)
add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_node
${catkin_LIBRARIES}
)
Here is my Package.XML:
<?xml version="1.0"?>
<package>
<name>motor_driver</name>
<version>0.0.0</version>
<description>The motor_driver package</description>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>serial</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>rplidar_ros</build_depend>
<build_depend>sensor_msgs</build_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>rospy</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>serial</run_depend>
<run_depend>rplidar_ros</run_depend>
<run_depend>std_msgs</run_depend>
</package>
I assume that this error doesn't have anything to do with the ego_points.cpp file itself but I am putting it here anyways:
#include "ros/ros.h"
#include "sensor_msgs/LaserScan.h"
#include "iostream"
using namespace std;
void ScanCallback(const sensor_msgs::LaserScan::ConstPtr& scan) {
int test = scan->ranges[1];
cout << test << endl;
}
int main(int argc, char** argv) {
ros::init(argc, argv, "ego_points.cpp"); //This is always the first thing that has to happen. Allows it to use ROS.
ros::NodeHandle nh; //First NodeHandle constructed will fully initialize this node.
ros::Subscriber scanSub;
scanSub = nh.subscribe<sensor_msgs::LaserScan>("/Scan",10, &ScanCallback);
ros::spin();
return 0;
}
Can someone please let me know what I am doing wrong? Thank you in advance.