Go to the documentation of this file.
35 #define DEFAULT_PEN_R 0xb3
36 #define DEFAULT_PEN_G 0xb8
37 #define DEFAULT_PEN_B 0xff
44 , turtle_image_(turtle_image)
83 QPen pen(QColor(req.r, req.g, req.b));
86 pen.setWidth(req.width);
107 QTransform transform;
108 transform.rotate(-
orient_ * 180.0 /
PI + 90.0);
112 bool Turtle::update(
double dt, QPainter& path_painter,
const QImage& path_image, qreal canvas_width, qreal canvas_height)
114 bool modified =
false;
120 for (; it != end; ++it)
124 QPointF old_pos =
pos_;
134 pos_.setY(std::max(0.0,
static_cast<double>(canvas_height - req.
pos.y())));
140 path_painter.setPen(
pen_);
155 QPointF old_pos =
pos_;
166 if (
pos_.x() < 0 ||
pos_.x() > canvas_width ||
167 pos_.y() < 0 ||
pos_.y() > canvas_height)
169 ROS_WARN(
"Oh no! I hit the wall! (Clamping from [x=%f, y=%f])",
pos_.x(),
pos_.y());
172 pos_.setX(std::min(std::max(
static_cast<double>(
pos_.x()), 0.0),
static_cast<double>(canvas_width)));
173 pos_.setY(std::min(std::max(
static_cast<double>(
pos_.y()), 0.0),
static_cast<double>(canvas_height)));
178 p.y = canvas_height -
pos_.y();
187 QRgb pixel = path_image.pixel((
pos_ *
meter_).toPoint());
188 color.r = qRed(pixel);
189 color.g = qGreen(pixel);
190 color.b = qBlue(pixel);
205 path_painter.setPen(
pen_);
void velocityCallback(const geometry_msgs::Twist::ConstPtr &vel)
bool teleportRelativeCallback(turtlesim::TeleportRelative::Request &, turtlesim::TeleportRelative::Response &)
bool teleportAbsoluteCallback(turtlesim::TeleportAbsolute::Request &, turtlesim::TeleportAbsolute::Response &)
ros::WallTime last_command_time_
Turtle(const ros::NodeHandle &nh, const QImage &turtle_image, const QPointF &pos, float orient)
QImage turtle_rotated_image_
ServiceServer advertiseService(AdvertiseServiceOptions &ops)
void publish(const boost::shared_ptr< M > &message) const
ros::ServiceServer set_pen_srv_
Publisher advertise(AdvertiseOptions &ops)
ros::ServiceServer teleport_absolute_srv_
ros::Subscriber velocity_sub_
V_TeleportRequest teleport_requests_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
bool update(double dt, QPainter &path_painter, const QImage &path_image, qreal canvas_width, qreal canvas_height)
bool setPenCallback(turtlesim::SetPen::Request &, turtlesim::SetPen::Response &)
void paint(QPainter &painter)
ros::ServiceServer teleport_relative_srv_
const std::string & getNamespace() const
ros::Publisher color_pub_
turtlesim
Author(s): Josh Faust, Dirk Thomas
autogenerated on Sat Apr 12 2025 02:28:03