ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
-1

Talker crashes terminates instantly?

asked 2015-05-01 10:36:20 -0600

215 gravatar image

Why does this publisher terminate.. I don't have a clue .. Code can be seen here.

pastebin.com/NGy9qwTm

It should just enter the values within the vector to the variable, and wait 1 second and then do it again..

edit retag flag offensive close merge delete

Comments

Is there any terminal output when it crashes? Do you get an error message, or does the program simply end?

Adam Allevato gravatar image Adam Allevato  ( 2015-05-01 11:13:18 -0600 )edit

it just simply end.. The terminal says that it finished cleanly.. ..

215 gravatar image 215  ( 2015-05-01 11:21:38 -0600 )edit

is "re" being printed? How many times? What have you tried?

Adam Allevato gravatar image Adam Allevato  ( 2015-05-01 11:41:49 -0600 )edit

So.. the talker and listener gets launched using xterm. and talker is opens instantly, and then closes.. So i am not able to see what it actually says..

215 gravatar image 215  ( 2015-05-01 11:44:20 -0600 )edit

even if i set the sleep duration to be 100000 it opens instantly and closes.

215 gravatar image 215  ( 2015-05-01 11:46:38 -0600 )edit

Ok... i narrowed it down into being something with the way i am converting.. because as soon it gets set it terminates.

215 gravatar image 215  ( 2015-05-01 13:13:25 -0600 )edit

Try to launch the talker using rosrun, so you can see its output in the terminal. Start adding printout statements to ensure that your program gets to each line, beginning at the very start of the program.

Adam Allevato gravatar image Adam Allevato  ( 2015-05-01 13:16:33 -0600 )edit

It seems to terminate when the variable is set from the vector...

215 gravatar image 215  ( 2015-05-01 18:36:16 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-05-02 09:42:52 -0600

This looks like a question that's more appropriate for StackOverflow - it's a general programming issue.

With that being said: if you're getting an error on line 93, it's because values doesn't contain an element at position i. Attempting to access this location in the vector causes your program to crash because the location doesn't exist in the vector.

Your i variable will loop from 0 to 100, which means it will try 101 vector elements. Ensure that you have at least this many elements in your vector by checking values.size() or printing it to the terminal.

Finally, just as a note, your code contains no way to break out of your loop. It will continue to check the i=100 element over and over until ROS is killed.

edit flag offensive delete link more

Comments

Problem wasn't in this file, but due some other node. I will delete since answering it here doesn't make any sense..

215 gravatar image 215  ( 2015-05-02 10:48:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-01 10:36:20 -0600

Seen: 482 times

Last updated: May 02 '15