ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Porblem Publishing Sonar and IR Data

asked 2012-07-20 11:25:31 -0600

MarkyMark2012 gravatar image

updated 2014-01-28 17:13:06 -0600

ngrennan gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-07-20 12:04:17 -0600

Eric Perko gravatar image

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.

edit flag offensive delete link more

Comments

yes that was it. Thanks Eric

MarkyMark2012 gravatar image MarkyMark2012  ( 2012-07-22 19:10:43 -0600 )edit

Question Tools

Stats

Asked: 2012-07-20 11:25:31 -0600

Seen: 473 times

Last updated: Jul 20 '12