Error i am getting:
/home/user/catkin_ws/src/topic_publisher_pkg/src/simple_topic_publisher.cpp: line 5: syntax error near unexpected token (' /home/user/catkin_ws/src/topic_publisher_pkg/src/simple_topic_publisher.cpp: line 5: int main (int argc, char **argv){’
What is the exercise number you are at? Also, could you please confirm that you saved your .cpp file, made the corresponding changes to the CMakeLists.txt fie and then executed catkin make form inside the ~catkin_ws/ folder?
Then please post the command that you are running to start the executable.
However the correct command is without the .cpp at the end:
rosrun topic_publisher_pkg simple_topic_publisher
I could not reproduce the error you are getting thought.
My suggestion now is to remove the package you created by doing so:
cd ~catkin_ws/src
rm -rf topic_publisher_pkg
Then you start from scratch.
1.- Create a new package inside ~catkin_ws/src
2.- Fill in the source code
3.- Modify the CMakeLists.txt file
4.- Go to ~catkin_ws and run catkin_make, then source devel/setup.bash
5.- Finally execute your program using rosrun topic_publisher_pkg simple_topic_publisher
I found the solution,
Just like you had mentioned, I had to remove the .cpp extension when running the rosrun command
The other issue was that ROS was not finding the newly made package, so I run the command $ rospack profile
and checked with the command $ rospack find
Works now!