Ask Your Question
0

bash: syntax error near unexpected token `(' from ROS Tutorial

asked 2015-08-02 00:01:11 -0600

uzoayo gravatar image

updated 2015-08-02 01:09:18 -0600

gvdhoorn gravatar image

Currently trying to follow the Gentle Intro to ROS tutorial. I'm attempting to complete chapter 3 and follow these comands

int main (int argc , char ∗∗ argv ) {
8 // Ini t i a l i z e the ROS system.
9 r o s : : i n i t ( argc , argv , " he l l o_r o s " ) ;
10
11 // Establ ish thi s program as a ROS node .
12 r o s : : NodeHandle nh ;
13
14 // Send some output as a log message .
15 ROS_INFO_STREAM( "Hel lo , ␣ROS! " ) ;

My actual commands in ubuntu are:

int main(int argc, char **argv){ros::init(argc, argv, "hello_ros");ros::NodeHandle nh;                                            ROS_INFO_STREAM("Hello, ROS!") ;}

Which is exactly what the tutorial says but my terminal keeps returning the error

bash: syntax error near unexpected token `('

Please Please help

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2015-08-02 01:16:36 -0600

gvdhoorn gravatar image

Did you directly copy/paste the text from the PDF to your source file?

If so, that is most likely the cause of your problem: the PDF uses markup and character codes that are not valid C++. You can either download the examples in a workable format from the AGITR website, or copy them by really typing everything manually.


Edit:

Which is exactly what the tutorial says but my terminal keeps returning the error

bash: syntax error near unexpected token `('

Just for completeness: the book teaches you how to work with ROS by taking you through a set of exercises that get you to write C++ programs. I may be wrong, but your last comment seems to suggest you are trying to enter C++ statements directly into the terminal (bash). That won't work, you will have to create a set of source files with a text editor and compile them.

As section 1.2 explains, A Gentle Introduction to ROS is not an introduction to programming, so you may want to follow some introductory C++ tutorials online, or pick-up a book about it before trying to continue with AGITR.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-08-02 00:01:11 -0600

Seen: 892 times

Last updated: Aug 02 '15