Giter Site home page Giter Site logo

Comments (5)

cyborg-x1 avatar cyborg-x1 commented on August 29, 2024 2

I guess the problem here is that the node checks if the topic is already there and then subscribes it.
Well if you launch it in a launchfile probably the node of the scan merger is launched in the beginning... topics not there ... topics not subscribed

change the topic parser function like this, and it should work, as far as it does ...

void LaserscanMerger::laserscan_topic_parser()
{
    // LaserScan topics to subscribe
    ros::master::V_TopicInfo topics;
    ros::master::getTopics(topics);
    istringstream iss(laserscan_topics);
    vector<string> tokens;
    copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter<vector<string> >(tokens));
    vector<string> tmp_input_topics;
    for(int i=0;i<tokens.size();++i)
    {
//          for(int j=0;j<topics.size();++j)
//      {
//          if( (tokens[i].compare(topics[j].name) == 0) && (topics[j].datatype.compare("sensor_msgs/LaserScan") == 0) )
//          {
                tmp_input_topics.push_back(tokens[i]);
//          }
//      }
    }

from ira_laser_tools.

EwingKang avatar EwingKang commented on August 29, 2024

change the topic parser function like this, and it should work, as far as it does ...

I've bump into the same problem, and thanks to @cyborg-x1, the fix worked. Guess this behavior is more desirable considering the ROS philosophy....

from ira_laser_tools.

Fellfalla avatar Fellfalla commented on August 29, 2024

try this fix: https://answers.ros.org/question/225183/ira_laser_tools-merger-doesnt-subscribe-to-topics-from-laser-in-gazebo/

Basically he adds a success return value and loops over laserscan_topic_parser() until the topics are published.

from ira_laser_tools.

ryanduringhours avatar ryanduringhours commented on August 29, 2024

try this fix: https://answers.ros.org/question/225183/ira_laser_tools-merger-doesnt-subscribe-to-topics-from-laser-in-gazebo/

Basically he adds a success return value and loops over laserscan_topic_parser() until the topics are published.

I saw that thread and tried to make that fix. I feel like I'm doing it wrong. Could you post the modified source code or help me find where exactly im supposed to add this ros::Rate loop_rate(0.5); //-- 0.5 [Hz] -> 2.0 [s] while( !this->laserscan_topic_parser() ) { ROS_DEBUG("LaserscanMerger: Retrying to detect the topics to subscribe to..."); loop_rate.sleep(); }
Thanks

from ira_laser_tools.

SmitRmb avatar SmitRmb commented on August 29, 2024
// LaserScan topics to subscribe
	ros::master::V_TopicInfo topics;
	ros::master::getTopics(topics);

    istringstream iss(laserscan_topics);
	vector<string> tokens;
	copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter<vector<string> >(tokens));

	vector<string> tmp_input_topics;
	while(tokens.size() != tmp_input_topics.size())
	{	
		ros::master::getTopics(topics);
		
		for(int i=0;i<tokens.size();++i)
		{
			for(int j=0;j<topics.size();++j)
			{
				if( (tokens[i].compare(topics[j].name) == 0) && (topics[j].datatype.compare("sensor_msgs/LaserScan") == 0) )
				{
					tmp_input_topics.push_back(topics[j].name);
				}
			}
		}

		sort(tmp_input_topics.begin(),tmp_input_topics.end());
		std::vector<string>::iterator last = std::unique(tmp_input_topics.begin(), tmp_input_topics.end());
		tmp_input_topics.erase(last, tmp_input_topics.end());
		ROS_INFO_STREAM_THROTTLE(2.0, "Laserscan merger waiting for specified input topics. " <<  tmp_input_topics.size() << "/" << tokens.size() << " input topics found");
		if(tokens.size() == tmp_input_topics.size()) //Do not sleep if all input topics are found
		{
			break; 
		}
		ros::Duration(1.0).sleep(); 		
	}


	// Do not re-subscribe if the topics are the same
	if( (tmp_input_topics.size() != input_topics.size()) || !equal(tmp_input_topics.begin(),tmp_input_topics.end(),input_topics.begin()))
	{
....

This fix works for me. Waits until all input topics are available, and outputs a throttled ROS_INFO to let a user know how many of its selected input topics are available and how many are still to come.

from ira_laser_tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.