segmentation fault (core dumped) caused by ros::spinOnce?
In these days, I spent all my time with coding, but there always problems with me, the newbie to ROS. And I try to search the answer here, but I still need some help.
For the question, main point is that I need to grab a picture from ROS message, then do some image processing, then grab another one.....
when I try to get cvimage from ROS, I use the callback function which is called by ros::spin()
. Then the program will always stay in callback function. So I try to do it with several ways.
The first method, I use ros::spin()
to call the callback function and get a frame, then I use ros::shutdown()
in order to exit the callback function. This method is works, but for each frame I need to init the ros again with ros::init(argc,argv,"XXX")
and redefine the node....So the final result is unsatisfactory because init the ros again cost a long time.
The second way, I try to deal the callback function with ros::spinOnce()
, it also works when I don't attend the image processing part.(I can get the frame and show it) Then I add the image processing part, it show the qustion "segmentation fault". According to some related question, I add launch-prefix="xterm -e gdb --args"
in the launch file, the final result is:
Temporary breakpoint 1, main( argc=<error reading variable: Cannot access memory at address 0x4>,argv=<error reading variable: Cannot access memory at address 0x4>)
So could someone help me to solve this problem? Thank you !