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.
Is there any terminal output when it crashes? Do you get an error message, or does the program simply end?
it just simply end.. The terminal says that it finished cleanly.. ..
is "re" being printed? How many times? What have you tried?
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..
even if i set the sleep duration to be 100000 it opens instantly and closes.
Ok... i narrowed it down into being something with the way i am converting.. because as soon it gets set it terminates.
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.
It seems to terminate when the variable is set from the vector...