Skip to content

Commit

Permalink
transforms, fix logging
Browse files Browse the repository at this point in the history
Follows from moveit#21

Changes in the code, particularly in the for loops
are required due to the use of rclcpp macros
  • Loading branch information
vmayoral committed Mar 4, 2019
1 parent 1a1d052 commit 46dcd37
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions moveit_core/transforms/src/transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@
#include <moveit/transforms/transforms.h>
#include <tf2_eigen/tf2_eigen.h>
#include <boost/algorithm/string/trim.hpp>
#include <moveit/logging/logging.h>
#include "rclcpp/rclcpp.hpp"

namespace moveit
{
namespace core
{

// Logger
rclcpp::Logger logger_transforms = rclcpp::get_logger("transforms");

Transforms::Transforms(const std::string& target_frame) : target_frame_(target_frame)
{
boost::trim(target_frame_);
if (target_frame_.empty())
ROS_ERROR_NAMED("transforms", "The target frame for MoveIt! Transforms cannot be empty.");
if (target_frame_.empty()){
RCLCPP_ERROR(logger_transforms, "The target frame for MoveIt! Transforms cannot be empty.");
}
else
{
transforms_map_[target_frame_] = Eigen::Isometry3d::Identity();
Expand Down Expand Up @@ -96,7 +101,7 @@ const Eigen::Isometry3d& Transforms::getTransform(const std::string& from_frame)
// If no transform found in map, return identity
}

ROS_ERROR_NAMED("transforms", "Unable to transform from frame '%s' to frame '%s'. Returning identity.",
RCLCPP_ERROR(logger_transforms, "Unable to transform from frame '%s' to frame '%s'. Returning identity.",
from_frame.c_str(), target_frame_.c_str());

// return identity
Expand All @@ -114,8 +119,9 @@ bool Transforms::canTransform(const std::string& from_frame) const

void Transforms::setTransform(const Eigen::Isometry3d& t, const std::string& from_frame)
{
if (from_frame.empty())
ROS_ERROR_NAMED("transforms", "Cannot record transform with empty name");
if (from_frame.empty()){
RCLCPP_ERROR(logger_transforms, "Cannot record transform with empty name");
}
else
transforms_map_[from_frame] = t;
}
Expand All @@ -129,7 +135,7 @@ void Transforms::setTransform(const geometry_msgs::msg::TransformStamped& transf
}
else
{
ROS_ERROR_NAMED("transforms", "Given transform is to frame '%s', but frame '%s' was expected.",
RCLCPP_ERROR(logger_transforms, "Given transform is to frame '%s', but frame '%s' was expected.",
transform.child_frame_id.c_str(), target_frame_.c_str());
}
}
Expand Down

0 comments on commit 46dcd37

Please sign in to comment.