Ask Your Question
1

How can I programmatically set the rosconsole verbosity of an object?

asked 2016-12-18 21:00:05 -0500

spmaniato gravatar image

updated 2016-12-18 21:08:45 -0500

I have a local planner plugin that instantiates a base_local_planner::TrajectoryPlannerROS object and then calls checkTrajectory on it. Specifically, this is the function that gets called eventually: TrajectoryPlanner::checkTrajectory (link to source code)

During execution of my local planner, that function is called a lot in order to evaluate velocity command candidates. As a result, it spams this warning:

ROS_WARN("Invalid Trajectory %f, %f, %f, cost: %f", vx_samp, vy_samp, vtheta_samp, cost);

I know that, from the command line, I can call the set_loggers service of the corresponding node in order to set the logger level to ERROR and thus prevent the spamming.

Is there a way to set the logger level when I instantiate the TrajectoryPlannerROS object in my local planner?

I would like to avoid:

  • making a service call (whether programmatic or via the command line)
  • forking base_local_planner and changing the ROS_WARN to ROS_DEBUG

The rosconsole wiki page has some relevant info, but it seems overkill for what I want to achieve. (Although I've never used anything but the ROS_* macros, so it may just be lack of familiarity.)

References:

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-12-19 01:19:37 -0500

ahendrix gravatar image

The rosconsole page that you link to has a section on setting the logger level that includes some example C++ code for changing the logger level. Is this what you're looking for?

If you want to change the logger level for the entire DWA local planner, you might want to consider switching all of its logger macros to use the named logger macros. This will allow you to the logger level for DWA separately from the rest of your code. This is probably a useful enough change that it would be worth submitting it into the public ROS navigation stack.

edit flag offensive delete link more

Comments

This excerpt from example.cpp does look promising: log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME".test"); I'll start there. Thanks Austin!

spmaniato gravatar image spmaniato  ( 2016-12-19 09:00:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2016-12-18 21:00:05 -0500

Seen: 463 times

Last updated: Dec 19 '16