0
$\begingroup$

Rosanswers logo

Hi all,

Not sure what's the matter here. If I use rostopic list, when my publisher has advertises Sonar messages I see /Sonar in the list. However if I try just the IR data it sometimes works most of the time not. The ad code is simply:

    // Sonar Range Test
    /*  bool publish_sonar = true;
n.param("publish_sonar", publish_sonar, publish_sonar);
ros::Publisher sonar_pub;

if(publish_sonar) 
{
    sonar_pub = n.advertise<sensor_msgs::Range>("Sonar", 1000);
}

    */  // IR Range Test
bool publish_ir = true;
n.param("publish_ir", publish_ir, publish_ir);
ros::Publisher ir_pub;

if(ir_pub) 
{
    ir_pub = n.advertise<sensor_msgs::Range>("InfraRed", 1000);
}

Any suggestions would me v welcome - I want my node to publish both at the end of the day. The TF for both works fine.

Many Thanks

Mark


Originally posted by MarkyMark2012 on ROS Answers with karma: 1834 on 2012-07-20

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You probably want your IR if statement to be:

if(publish_ir)

not

if(ir_pub)

I would expect doing if(ros::Publisher) before it has been created using e.g. n.advertise to return false.


Originally posted by Eric Perko with karma: 8406 on 2012-07-20

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by MarkyMark2012 on 2012-07-22:
yes that was it. Thanks Eric

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.