Ask Your Question

space's profile - activity

2021-05-26 15:40:23 -0500 marked best answer Boost thread blocking ros::spin

I have a class that has a member variable which is an object of another class

class SuperScanner {
     public:
      SuperScanner(ros::NodeHandle& nh, std::string cameraIP); 
       // Other functions
     private:
      Motor _motor;
      Camera _camera;
     // Other variables and functions
.....
}

Within a function in the SuperScanner class, I'm creating a new thread that invokes image acquisition and then starts the motor motion. The camera needs to start recording before the motion starts, but must continue for a certain duration of time while the motor still moves.To do this, I'm using boost threads.

SuperScanner::getData() {
  boost::function<void()> scanFunc = boost::bind(&Camera::startAcquiring, _camera, scanTime, 
  boost::ref(cameraStatus), boost::ref(_results));

  // Start acquiring
  std::shared_ptr<boost::thread> threadPtr = std::make_shared<boost::thread>(scanFunc);

  // Send motor to target position
  _motor.send();

  // Join thread
  threadPtr->join();

 _log.print("Finished the acquisition");
}

This seems to run into trouble sometimes, with the ros spin thread getting blocked and not executing any callbacks to other topics subscribed to in SuperScanner. The "Finished the acquisition" statement does get printed out though, so I know the thread has joined. A ronsode info on the node shows the list of topics, but says "communication with node failed". Could this have anything to do with the member variables within the instance of the _camera object getting updated in its startAcquiring() function?

Here's how the node gets started:

int main(int argc, char** argv)
{
  ros::init(argc, argv, "super_scanner");
  ros::NodeHandle n("~");

  n.param("/camera_scanner/device_ip", deviceIP, deviceIP);
  SuperScanner superScanner(n, deviceIp);
  ros::spin();
  return 0;
}
2021-03-20 22:30:01 -0500 received badge  Famous Question (source)
2021-02-11 17:40:16 -0500 received badge  Student (source)
2020-07-21 04:35:00 -0500 received badge  Notable Question (source)
2020-06-25 08:16:15 -0500 received badge  Popular Question (source)
2020-06-18 09:00:10 -0500 commented answer Boost thread blocking ros::spin

Yes, getData() is invoked in a ROS callback in the SuperScanner class. startAcquiring does not use any ROS callbacks tho

2020-06-18 00:29:11 -0500 commented answer Boost thread blocking ros::spin

My bad. I removed some other classes that were being constructed in main() for clarity for this question and ended up p

2020-06-18 00:28:12 -0500 commented answer Boost thread blocking ros::spin

My bad. I removed some other classes that were being constructed in main() for clarity for this question and ended up p

2020-06-18 00:26:06 -0500 edited question Boost thread blocking ros::spin

Boost thread blocking ros::spin I have a class that has a member variable which is an object of another class class Sup

2020-06-17 23:22:03 -0500 edited question Boost thread blocking ros::spin

Boost thread blocking ros::spin I have a class that has a member variable which is an object of another class class Sup

2020-06-17 23:19:57 -0500 asked a question Boost thread blocking ros::spin

Boost thread blocking ros::spin I have a class that has a member variable which is an object of another class class Sup

2020-03-24 10:47:38 -0500 received badge  Famous Question (source)
2019-05-22 10:16:57 -0500 received badge  Notable Question (source)
2019-01-25 13:49:06 -0500 received badge  Popular Question (source)
2018-12-06 09:57:26 -0500 received badge  Enthusiast
2018-11-28 15:46:19 -0500 edited question ROS Tests: catkin_add_executable_with_gtest does not rebuild target

ROS Tests: Not rebuilding with catkin_add_executable_with_gtest (no errors) Basically, when I switched from catkin_add_g

2018-11-28 15:45:48 -0500 edited question ROS Tests: catkin_add_executable_with_gtest does not rebuild target

ROSTests: Not rebuilding with catkin_add_executable_with_gtest (no errors) Basically, when I switched from catkin_add_gt

2018-11-28 14:09:24 -0500 edited question ROS Tests: catkin_add_executable_with_gtest does not rebuild target

ROSTests: Not rebuilding with catkin_add_executable_with_gtest (no errors) Basically, when I switched from catkin_add_gt

2018-11-28 13:59:31 -0500 edited question ROS Tests: catkin_add_executable_with_gtest does not rebuild target

ROSTests: Not rebuilding with catkin_add_executable_with_gtest (no errors) I'm trying to run some ROS unit and integrati

2018-11-28 13:59:31 -0500 received badge  Editor (source)
2018-11-28 13:59:07 -0500 edited question ROS Tests: catkin_add_executable_with_gtest does not rebuild target

ROSTests: Not rebuilding with catkin_add_executable_with_gtest (no errors) I'm trying to run some ROS unit and integrati

2018-11-28 13:58:22 -0500 asked a question ROS Tests: catkin_add_executable_with_gtest does not rebuild target

ROSTests: Not rebuilding with catkin_add_executable_with_gtest (no errors) I'm trying to run some ROS unit and integrati

2017-11-11 07:13:25 -0500 received badge  Famous Question (source)
2017-11-11 07:13:25 -0500 received badge  Notable Question (source)
2017-06-28 02:55:54 -0500 received badge  Popular Question (source)
2017-06-28 02:30:36 -0500 commented answer Multiple packages in catkin workspace?

Found the bit detailing what rospack profile does here: http://wiki.ros.org/rospack/Troubleshooting. Issue resolved. Tha

2017-06-28 02:30:21 -0500 commented answer Multiple packages in catkin workspace?

Found the bit detailing what rospack profile does here: http://wiki.ros.org/rospack/Troubleshooting Issue resolved. Than

2017-06-28 02:29:03 -0500 received badge  Supporter (source)
2017-06-28 02:28:39 -0500 marked best answer Multiple packages in catkin workspace?

Hi! I'm just starting out with ROS. I'm trying to create multiple packages in the same workspace, but tab complete fails for some inexplicable (to me) reason. I've outlined the steps below. Can anyone help me figure out why this is happening?

mkdir catkin_ws/src
cd catkin_ws/src/
catkin_init_workspace

In catkin_ws/src:

catkin_create_pkg pkg1

Then in catkin_ws

catkin_make
source devel/setup.bash

This allows me to tab complete rosrun pkg1 ...

However, when I create a second package in catkin_ws/src named 'pkg2' following the same steps, run catkin_make again and try to tab complete 'rosrun pk', I'm only shown 'pkg1'. Shouldn't ROS allow me to create multiple packages in the same folder?

2017-06-28 02:28:39 -0500 received badge  Scholar (source)
2017-06-28 02:12:55 -0500 commented question Multiple packages in catkin workspace?

I just tried again without changing anything and it works. Looks like you're right. rospack profile list the directory

2017-06-28 01:57:42 -0500 commented question Multiple packages in catkin workspace?

In catkin_ws/src: catkin_create_pkg pkg2 Then in catkin_ws catkin_make source devel/setup.bash

2017-06-28 01:39:58 -0500 asked a question Multiple packages in catkin workspace?

Multiple packages in catkin workspace? Hi! I'm just starting out with ROS. I'm trying to create multiple packages in the