-
Notifications
You must be signed in to change notification settings - Fork 946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] switch to ROS_LOGGER from CONSOLE_BRIDGE #874
Conversation
[Fix] clang format
bc3175d
to
185c62d
Compare
@@ -73,13 +73,14 @@ void moveit::tools::BackgroundProcessing::processingThread() | |||
action_lock_.unlock(); | |||
try | |||
{ | |||
CONSOLE_BRIDGE_logDebug("moveit.background: Begin executing '%s'", action_name.c_str()); | |||
ROS_DEBUG_NAMED("background_processing", "moveit.background: Begin executing '%s'", action_name.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the namespace introduced. However, then you can remove moveit.background:
from the message.
@@ -13,16 +13,16 @@ add_library(${MOVEIT_LIB_NAME} | |||
) | |||
set_target_properties(${MOVEIT_LIB_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION}) | |||
|
|||
target_link_libraries(${MOVEIT_LIB_NAME} moveit_robot_state ${catkin_LIBRARIES} ${console_bridge_LIBRARIES} ${urdfdom_LIBRARIES} ${urdfdom_headers_LIBRARIES} ${Boost_LIBRARIES}) | |||
target_link_libraries(${MOVEIT_LIB_NAME} moveit_robot_state ${catkin_LIBRARIES} ${urdfdom_LIBRARIES} ${urdfdom_headers_LIBRARIES} ${Boost_LIBRARIES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember to add ${ros_console_LIBRARIES}
instead everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your effort. I have a few comments to the naming of the loggers.
In general I like the idea of using a static const variable, e.g. logger_name
, to define the logger name only once per cpp file.
@@ -12,8 +12,6 @@ endif() | |||
|
|||
find_package(Boost REQUIRED system filesystem date_time thread iostreams) | |||
|
|||
find_package(console_bridge REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of console_bride, you need to require ros_console now...
} | ||
else if (type == AllowedCollision::CONDITIONAL) | ||
{ | ||
cdata->acm_->getAllowedCollision(cd1->getID(), cd2->getID(), dcf); | ||
if (cdata->req_->verbose) | ||
CONSOLE_BRIDGE_logDebug("Collision between '%s' and '%s' is conditionally allowed", cd1->getID().c_str(), | ||
cd2->getID().c_str()); | ||
ROS_DEBUG_NAMED("collision_detection_fcl", "Collision between '%s' and '%s' is conditionally allowed", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use the hierarchical logger scope collision_detection.fcl
here.
@@ -139,13 +139,13 @@ int main(int argc, char* argv[]) | |||
num_failed_calls++; | |||
++i; | |||
if (i % 100 == 0) | |||
ROS_INFO_NAMED("measure_ik_call_cost", | |||
ROS_INFO_NAMED("cached_ik_kinematics_plugin", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you changed the logger name here? In order to include cached_ik, I would suggest cached_ik.measure_ik_call_cost
. Remember that the package name (moveit_kinematics
) is always part of the logger name.
@@ -161,7 +161,7 @@ class IKFastKinematicsPlugin : public kinematics::KinematicsBase | |||
const size_t num_joints_; | |||
std::vector<int> free_params_; | |||
bool active_; // Internal variable that indicates whether solvers are configured and ready | |||
const std::string name_{ "ikfast" }; | |||
const std::string name_{ "ikfast_kinematics_plugin" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to keep the short name ikfast
. moveit_kinematics
is part of the logger name anyway.
@@ -52,19 +52,19 @@ ChainIkSolverPos_NR_JL_Mimic::ChainIkSolverPos_NR_JL_Mimic(const Chain& _chain, | |||
{ | |||
mimic_joints[i].reset(i); | |||
} | |||
ROS_DEBUG_NAMED("kdl", "Limits"); | |||
ROS_DEBUG_NAMED("kdl_kinematics_plugin", "Limits"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for ikfast
.
@@ -63,7 +63,7 @@ bool SrvKinematicsPlugin::initialize(const std::string& robot_description, const | |||
{ | |||
bool debug = false; | |||
|
|||
ROS_INFO_STREAM_NAMED("srv", "SrvKinematicsPlugin initializing"); | |||
ROS_INFO_STREAM_NAMED("srv_kinematics_plugin", "SrvKinematicsPlugin initializing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again. Keep short name.
@@ -481,8 +481,8 @@ class MoveGroupInterface::MoveGroupInterfaceImpl | |||
} | |||
else | |||
{ | |||
logError("Unable to transform from frame '%s' to frame '%s'", frame.c_str(), | |||
getRobotModel()->getModelFrame().c_str()); | |||
ROS_ERROR_NAMED("Unable to transform from frame '%s' to frame '%s'", frame.c_str(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the logger name is missing!
@@ -52,7 +52,7 @@ class MoveItSimpleControllerManager : public moveit_controller_manager::MoveItCo | |||
{ | |||
if (!node_handle_.hasParam("controller_list")) | |||
{ | |||
ROS_ERROR_STREAM_NAMED("manager", "No controller_list specified."); | |||
ROS_ERROR_STREAM_NAMED("moveit_simple_controller_manager", "No controller_list specified."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we don't need an additional name at all. moveit_simple_controller_manager
is already the package name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick run-through and I'm excited about this PR! I can re-review after @rhaschke's comments are addressed
Thanks @rhaschke @davetcoleman for the reviews. I've made some fixes on my patch following your suggestions. |
I encouraged @jeasinema to work on this patch and supervised it in person. Still, @davetcoleman, please look over it once more before you merge because it's just too big to verify everything in detail. This should be merged soon, because it probably conflicts with many other patches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeasinema Thanks a lot for your effort so far. May I ask for the following changes
- Use file-local variables
static const char* LOGGER
to specify the logger name once per cpp file. - I have suggested different logger names at various locations (see inline comments).
- Manually fix badly clang-formatted string literals.
"Collision checking is considered complete due to external callback. %s was found. %u contacts are " | ||
"stored.", | ||
cdata->res_->collision ? "Collision" : "No collision", (unsigned int)cdata->res_->contact_count); | ||
ROS_INFO_NAMED("collision_detection.fcl", "Collision checking is considered complete due to external callback. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you fix such weird line breaks in string literals. clang-format doesn't remove line breaks in string literals, but only adds new ones...
When I did that manually the last time, I tried to keep sentences (or phrases) on a single line.
@@ -106,7 +106,7 @@ int PR2ArmIKSolver::CartToJnt(const KDL::JntArray& q_init, const KDL::Frame& p_i | |||
if (free_angle_ == 0) | |||
{ | |||
if (verbose) | |||
ROS_DEBUG_NAMED("pr2_arm_kinematics_plugin", "Solving with %f", q_init(0)); | |||
ROS_DEBUG_NAMED("constraint_samplers", "pr2_arm_kinematics_plugin", "Solving with %f", q_init(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot use two logger names. This applies to all the following logging calls.
Why doesn't this raise a warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would raise an error with ROS_DEBUG_STREAM_NAMED
, but printf-style formatting is syntactically fine with three strings in the parameter list...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, this should finally end up in an printf-like command and gcc provides some extra checks for these...
|
||
moveit::ConstructException::ConstructException(const std::string& what_arg) : std::runtime_error(what_arg) | ||
{ | ||
CONSOLE_BRIDGE_logError("Error during construction of object: %s\nException thrown.", what_arg.c_str()); | ||
ROS_ERROR_NAMED("exceptions", "Error during construction of object: %s\nException thrown.", what_arg.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I suggest to drop the extra logger name and use ROS_ERROR()
only. Applies to next as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree.
It is not unlikely that we might want to silence errors from these classes only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Agreed.
@@ -295,7 +294,7 @@ const LinkModel* JointModelGroup::getLinkModel(const std::string& name) const | |||
LinkModelMapConst::const_iterator it = link_model_map_.find(name); | |||
if (it == link_model_map_.end()) | |||
{ | |||
CONSOLE_BRIDGE_logError("Link '%s' not found in group '%s'", name.c_str(), name_.c_str()); | |||
ROS_ERROR_NAMED("robot_model", "Link '%s' not found in group '%s'", name.c_str(), name_.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I suggest to use robot_model.jmg
as the logger name (in whole file).
@@ -93,7 +92,8 @@ bool IterativeSplineParameterization::computeTimeStamps(robot_trajectory::RobotT | |||
const robot_model::JointModelGroup* group = trajectory.getGroup(); | |||
if (!group) | |||
{ | |||
CONSOLE_BRIDGE_logError("It looks like the planner did not set the group the plan was computed for"); | |||
ROS_ERROR_NAMED("trajectory_processing", "It looks like the planner did not set the group the plan was computed " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger name: trajectory_processing.iterative_spline_parameterization
?
@@ -270,11 +270,12 @@ void ompl_interface::ConstraintsLibrary::loadConstraintApproximations(const std: | |||
std::ifstream fin((path + "/manifest").c_str()); | |||
if (!fin.good()) | |||
{ | |||
logWarn("Manifest not found in folder '%s'. Not loading constraint approximations.", path.c_str()); | |||
ROS_WARN_NAMED("constraints_library", "Manifest not found in folder '%s'. Not loading constraint approximations.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ompl.constraints_library
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package name already is ompl_interface
. Adding ompl.xyz
would be redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
@@ -54,7 +54,7 @@ ompl_interface::ConstrainedGoalSampler::ConstrainedGoalSampler( | |||
{ | |||
if (!constraint_sampler_) | |||
default_sampler_ = si_->allocStateSampler(); | |||
logDebug("Constructed a ConstrainedGoalSampler instance at address %p", this); | |||
ROS_DEBUG_NAMED("constrained_goal_sampler", "Constructed a ConstrainedGoalSampler instance at address %p", this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, logger name should be prefixed with ompl
: ompl.constrained_goal_sampler
.
@@ -116,7 +116,7 @@ bool ompl_interface::StateValidityChecker::isValidWithoutCache(const ompl::base: | |||
if (!si_->satisfiesBounds(state)) | |||
{ | |||
if (verbose) | |||
logInform("State outside bounds"); | |||
ROS_INFO_NAMED("state_validity_checker", "State outside bounds"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ompl.state_validity_checker
@@ -89,7 +89,7 @@ void ompl_interface::ModelBasedPlanningContext::setProjectionEvaluator(const std | |||
{ | |||
if (!spec_.state_space_) | |||
{ | |||
logError("No state space is configured yet"); | |||
ROS_ERROR_NAMED("model_based_planning_context", "No state space is configured yet"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only ompl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the ompl package is too big and confusing to use the top-level namespace here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And as you stated above, the package name is something like ompl already...
@@ -69,7 +69,8 @@ class MoveItSimpleControllerManager : public moveit_controller_manager::MoveItCo | |||
{ | |||
if (!controller_list[i].hasMember("name") || !controller_list[i].hasMember("joints")) | |||
{ | |||
ROS_ERROR_STREAM_NAMED("manager", "Name and joints must be specifed for each controller"); | |||
ROS_ERROR_STREAM_NAMED("manager", "Name and joints must be specifed for each " | |||
"controller"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typical example of bad clang-formatting that should be fixed manually.
I know this redundancy annoys you to no end, but I would like to keep this as is.
|
Yes, it does.
But you could have different LOGGER variables then.
Valid point. But failures can be fixed later too...
That's the one convincing me to some extend. However not sure, this balances out the redundancy drawback. Using modern IDEs, it's rather easy to click on the variable and see its definition. |
As long as you're the one who does that (for the next 10+ years).
I know a number of people who browse MoveIt source code on GitHub instead of cloning the repository and starting up their ema... eclipse. I still don't like your IDE-arguments, but we discussed this before.
And I'm not convinced the way he did it is very good... Lastly, I believe @jeasinema did a very good job already and I would not make this request depend on him going over all the changes yet another time. If you think this really blocks the request, then we should wait for a third opinion. |
I agree that @jeasinema did a great job on this. However, if we already touch most of the logging stuff anyway, we should try to commit the final solution and not start touching everything yet another time. |
While I agree this wasn't needed in this PR (already large enough, need to move fast) I certainly agree with @rhaschke this is a cleaner approach to do in the future. I've been using that standard in my personal projects for years and I've added it in several places in the MoveIt! codebase already (Robert pointed out one) @jeasinema thanks so much for this contribution! |
@jeasinema @v4hn Your changes introduced 10 new warnings on the ROS build farm: |
@davetcoleman @v4hn Should we consider compiler warnings as errors on Travis to avoid such issues in future? |
yes I am a strong fan of making our built more strict with warnings and (long term) clang-tidy checks |
I agree, Warnings should ideally trigger CI failure eventually, but CI should still run through for everything else.
Also, this is a big burden if warnings occur outside "our domain" and we can't fix them in the repository here.
Many ROS packages/headers do not compile with `-Wall -Wextra -pedantic` in my experience.
|
* [Fix] switch to ROS_LOGGER from CONSOLE_BRIDGE * [Fix] clang format * [Fix] manually fix bad clang-formatting in strings
* Limiting the scope of variables moveit#874 Limited the scope of variables in moveit_core/collision_detection * Update moveit_core/collision_detection/src/collision_octomap_filter.cpp Co-authored-by: AndyZe <andyz@utexas.edu> * Update moveit_core/collision_detection/src/collision_octomap_filter.cpp Co-authored-by: AndyZe <andyz@utexas.edu> * Update moveit_core/collision_detection/src/collision_octomap_filter.cpp Co-authored-by: AndyZe <andyz@utexas.edu> * convert float to double * change double to float * Feedback fixes * Introduced variables removed from previous merge commit * Updated GL_Renderer function definitions with double instead of float * Changed update() function arguments to float since it is a derived virtual function and needs to be overriden * Fixed all override errors in visualization * *Fixed override errors in perception *Changed reinterpret_cast to double* from float* * change variable types to fit function definition * Fixed clang-tidy warnings * Fixed scope of reusable variables --------- Co-authored-by: Salah Soliman <salahsoliman96@gmail.com> Co-authored-by: AndyZe <andyz@utexas.edu> Co-authored-by: Henning Kayser <henningkayser@picknik.ai>
Description
This pull request is an extended version of #859 and inspired by #860. As suggested by @davetcoleman and @v4hn, I switched to use ROS_LOGGER from CONSOLE_BRIDGE and removed the dependency from some cmake files.
Checklist