23 #include <std_msgs/ColorRGBA.h> 24 #include <visualization_msgs/MarkerArray.h> 25 #include <cob_twist_controller/TwistControllerConfig.h> 47 if (!nh_.
getParam(
"root_frame", this->root_frame_))
49 ROS_ERROR(
"Failed to get parameter \"root_frame\".");
53 this->base_link_ =
"base_link";
55 if (!nh_.
getParam(
"chain_tip_link", this->chain_tip_link_))
57 ROS_ERROR(
"Failed to get parameter \"chain_tip_link\".");
61 if (!nh_.
getParam(
"frame_tracker/target_frame", this->target_frame_))
63 ROS_ERROR_STREAM(
"Please provide a 'frame_tracker/target_frame' parameter in this node's namespace.");
67 marker_pub_ = this->nh_.
advertise<visualization_msgs::MarkerArray>(
"trajectory_marker", 1,
true);
80 std_msgs::ColorRGBA green;
81 green.g = green.a = 1.0;
83 tip_marker_.ns =
"tip_marker";
85 std_msgs::ColorRGBA red;
88 target_marker_.ns =
"target_marker";
90 std_msgs::ColorRGBA blue;
91 blue.b = blue.a = 1.0;
93 base_marker_.ns =
"base_marker";
95 marker_timer_.start();
102 visualization_msgs::MarkerArray marker_array;
103 geometry_msgs::Point point;
105 if (tf_listener_.
frameExists(this->chain_tip_link_))
107 if (tip_marker_.points.size() > 10000)
109 tip_marker_.points.clear();
111 point =
getPoint(this->root_frame_, this->chain_tip_link_);
112 tip_marker_.points.push_back(point);
113 marker_array.markers.push_back(tip_marker_);
118 if (target_marker_.points.size() > 10000)
120 target_marker_.points.clear();
122 point =
getPoint(this->root_frame_, this->target_frame_);
123 target_marker_.points.push_back(point);
124 marker_array.markers.push_back(target_marker_);
129 if (nh_.
param(
"twist_controller/kinematic_extension", 0) == cob_twist_controller::TwistController_BASE_ACTIVE)
131 if (base_marker_.points.size() > 10000)
133 base_marker_.points.clear();
135 point =
getPoint(this->root_frame_, this->base_link_);
136 base_marker_.points.push_back(point);
137 marker_array.markers.push_back(base_marker_);
141 if (!marker_array.markers.empty())
143 this->marker_pub_.
publish(marker_array);
149 visualization_msgs::Marker box_marker;
150 box_marker.type = visualization_msgs::Marker::LINE_STRIP;
152 box_marker.action = visualization_msgs::Marker::ADD;
157 box_marker.scale.x = 0.01;
158 box_marker.color = color;
159 box_marker.pose.orientation.w = 1.0;
164 geometry_msgs::Point
getPoint(std::string from, std::string to)
166 geometry_msgs::Point point;
188 int main(
int argc,
char** argv)
190 ros::init(argc, argv,
"debug_trajectory_marker_node");
195 ROS_ERROR(
"Failed to initialize DebugTrajectoryMarker.");
geometry_msgs::Point getPoint(std::string from, std::string to)
ros::Publisher marker_pub_
void publish(const boost::shared_ptr< M > &message) const
void publishMarker(const ros::TimerEvent &event)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
visualization_msgs::Marker base_marker_
ROSCPP_DECL void spin(Spinner &spinner)
TFSIMD_FORCE_INLINE const tfScalar & x() const
visualization_msgs::Marker target_marker_
TFSIMD_FORCE_INLINE const tfScalar & z() const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
TFSIMD_FORCE_INLINE const tfScalar & y() const
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
const std::string & getNamespace() const
ROSCPP_DECL bool isShuttingDown()
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
std::string target_frame_
visualization_msgs::Marker tip_marker_
std::string chain_tip_link_
tf::TransformListener tf_listener_
uint32_t getNumSubscribers() const
#define ROS_WARN_STREAM_ONCE(args)
bool getParam(const std::string &key, std::string &s) const
#define ROS_ERROR_STREAM(args)
visualization_msgs::Marker getMarker(std_msgs::ColorRGBA color)