Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
turtlesim_xl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2v
turtlesim_xl
Commits
9e19e97b
Commit
9e19e97b
authored
Sep 13, 2021
by
Silas Dohm
Browse files
Options
Downloads
Patches
Plain Diff
label can be turned on and off
parent
48440013
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/turtlesim/turtle.h
+2
-1
2 additions, 1 deletion
include/turtlesim/turtle.h
src/turtle.cpp
+8
-6
8 additions, 6 deletions
src/turtle.cpp
src/turtle_frame.cpp
+3
-3
3 additions, 3 deletions
src/turtle_frame.cpp
srv/SetLabel.srv
+2
-1
2 additions, 1 deletion
srv/SetLabel.srv
with
15 additions
and
11 deletions
include/turtlesim/turtle.h
+
2
−
1
View file @
9e19e97b
...
...
@@ -97,7 +97,8 @@ private:
ros
::
WallTime
last_command_time_
;
float
meter_
;
QString
label
=
"0"
;
bool
label_on_
=
false
;
QString
label_
=
""
;
struct
TeleportRequest
{
...
...
This diff is collapsed.
Click to expand it.
src/turtle.cpp
+
8
−
6
View file @
9e19e97b
...
...
@@ -92,7 +92,8 @@ bool Turtle::setPenCallback(turtlesim::SetPen::Request& req, turtlesim::SetPen::
}
bool
Turtle
::
setLabelCallback
(
turtlesim_xl
::
SetLabel
::
Request
&
req
,
turtlesim_xl
::
SetLabel
::
Response
&
){
Turtle
::
label
=
QString
(
req
.
name
.
c_str
());
Turtle
::
label_
=
QString
(
req
.
name
.
c_str
());
label_on_
=
req
.
on
;
return
true
;
}
bool
Turtle
::
teleportRelativeCallback
(
turtlesim
::
TeleportRelative
::
Request
&
req
,
turtlesim
::
TeleportRelative
::
Response
&
)
...
...
@@ -220,14 +221,15 @@ bool Turtle::update(double dt, QPainter& path_painter, const QImage& path_image,
void
Turtle
::
paint
(
QPainter
&
painter
)
{
QPointF
p
=
pos_
*
meter_
;
QPointF
pl
=
pos_
*
meter_
;
pl
.
rx
()
-=
0.3
*
turtle_rotated_image_
.
width
();
//pl.ry() -= 0.5 * turtle_rotated_image_.height();
p
.
rx
()
-=
0.5
*
turtle_rotated_image_
.
width
();
p
.
ry
()
-=
0.5
*
turtle_rotated_image_
.
height
();
painter
.
drawImage
(
p
,
turtle_rotated_image_
);
if
(
label_on_
){
QPointF
pl
=
pos_
*
meter_
;
pl
.
rx
()
-=
0.3
*
turtle_rotated_image_
.
width
();
painter
.
setPen
(
Qt
::
red
);
painter
.
drawText
(
pl
,
Turtle
::
label
);
painter
.
drawText
(
pl
,
Turtle
::
label_
);
}
}
}
This diff is collapsed.
Click to expand it.
src/turtle_frame.cpp
+
3
−
3
View file @
9e19e97b
...
...
@@ -35,9 +35,9 @@
#include
<cstdlib>
#include
<ctime>
#define DEFAULT_BG_R 0x
2a
#define DEFAULT_BG_G 0x
2a
#define DEFAULT_BG_B 0x
2e
#define DEFAULT_BG_R 0x
00
#define DEFAULT_BG_G 0x
00
#define DEFAULT_BG_B 0x
00
#define FRAME_WIDTH 1200
#define FRAME_HEIGHT 800
...
...
This diff is collapsed.
Click to expand it.
srv/SetLabel.srv
+
2
−
1
View file @
9e19e97b
string name
uint8 on
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment