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
5ff8e079
Commit
5ff8e079
authored
Aug 19, 2021
by
Joel Vongehr
Browse files
Options
Downloads
Patches
Plain Diff
added first version of parameter for drawing
parent
cdb78617
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/turtlesim/turtle_frame.h
+5
-0
5 additions, 0 deletions
include/turtlesim/turtle_frame.h
src/turtle_frame.cpp
+32
-5
32 additions, 5 deletions
src/turtle_frame.cpp
src/turtlesim_xl.cpp
+12
-2
12 additions, 2 deletions
src/turtlesim_xl.cpp
with
49 additions
and
7 deletions
include/turtlesim/turtle_frame.h
+
5
−
0
View file @
5ff8e079
...
...
@@ -59,6 +59,9 @@ public:
std
::
string
spawnTurtle
(
const
std
::
string
&
name
,
float
x
,
float
y
,
float
angle
);
std
::
string
spawnTurtle
(
const
std
::
string
&
name
,
float
x
,
float
y
,
float
angle
,
size_t
index
);
void
setShape
(
std
::
string
shape
);
void
drawShape
();
protected:
void
paintEvent
(
QPaintEvent
*
event
);
...
...
@@ -99,6 +102,8 @@ private:
float
meter_
;
float
width_in_meters_
;
float
height_in_meters_
;
std
::
string
shape
;
};
}
This diff is collapsed.
Click to expand it.
src/turtle_frame.cpp
+
32
−
5
View file @
5ff8e079
...
...
@@ -44,7 +44,10 @@
namespace
turtlesim
{
TurtleFrame
::
TurtleFrame
(
QWidget
*
parent
,
Qt
::
WindowFlags
f
)
TurtleFrame
::
TurtleFrame
(
QWidget
*
parent
,
Qt
::
WindowFlags
f
)
:
TurtleFrame
(
"rectangle"
,
parent
,
f
)
{}
TurtleFrame
::
TurtleFrame
(
std
::
string
shape
,
QWidget
*
parent
,
Qt
::
WindowFlags
f
)
:
QFrame
(
parent
,
f
)
,
path_image_
(
FRAME_WIDTH
,
FRAME_HEIGHT
,
QImage
::
Format_ARGB32
)
,
path_painter_
(
&
path_image_
)
...
...
@@ -105,8 +108,8 @@ TurtleFrame::TurtleFrame(QWidget* parent, Qt::WindowFlags f)
clear
();
//temp draw shape (hardcoded) -----------------------------------
path_painter_
.
setPen
(
QColor
(
0xff
,
0xff
,
0xff
))
;
path_painter_
.
drawRect
((
12
-
5
)
*
meter_
,
FRAME_HEIGHT
-
(
7
-
5
)
*
meter_
,
5
*
meter_
,
-
5
*
meter_
);
//
path_painter_.setPen(QColor(0xff,0xff,0xff));
//
path_painter_.drawRect((12-5)*meter_,FRAME_HEIGHT-(7-5)*meter_,5*meter_,-5*meter_);
//QPointF tmp01;
//tmp01.setX((12-5)*meter_);
//tmp01.setY(FRAME_HEIGHT-(7)*meter_);
...
...
@@ -293,4 +296,28 @@ bool TurtleFrame::resetCallback(std_srvs::Empty::Request&, std_srvs::Empty::Resp
return
true
;
}
void
TurtleFrame
::
drawShape
()
{
path_painter_
.
setPen
(
QColor
(
0xff
,
0xff
,
0xff
));
int
xTurtleStart
=
12
*
meter_
;
int
yTurtleStart
=
FRAME_HEIGHT
-
7
*
meter_
;
if
(
shape
==
"triangle"
)
{
int
xTopRight
=
xTurtleStart
;
int
xTopLeft
=
xTopRight
/
2
;
int
xBottom
=
(
xTopLeft
+
xTopRight
)
/
2
;
int
yTop
=
yTurtleStart
;
int
yBottom
=
yTop
+
5
*
meter_
;
path_painter_
.
drawLine
(
xTopLeft
,
yTop
,
xTopRight
,
yTop
);
path_painter_
.
drawLine
(
xTopLeft
,
yTop
,
xBottom
,
yBottom
);
path_painter_
.
drawLine
(
xBottom
,
yBottom
,
xTopRight
,
yTop
);
}
else
{
path_painter_
.
drawRect
((
12
-
5
)
*
meter_
,
FRAME_HEIGHT
-
(
7
-
5
)
*
meter_
,
5
*
meter_
,
-
5
*
meter_
);
}
}
void
TurtleFrame
::
setShape
(
std
::
string
shape
)
{
this
->
shape
=
shape
;
}
}
This diff is collapsed.
Click to expand it.
src/turtlesim_xl.cpp
+
12
−
2
View file @
5ff8e079
...
...
@@ -45,9 +45,11 @@ public:
nh_
.
reset
(
new
ros
::
NodeHandle
);
}
int
exec
()
int
exec
(
std
::
string
shape
=
"rectangle"
)
{
turtlesim
::
TurtleFrame
frame
;
frame
.
setShape
(
shape
);
frame
.
drawShape
();
frame
.
show
();
return
QApplication
::
exec
();
...
...
@@ -56,7 +58,15 @@ public:
int
main
(
int
argc
,
char
**
argv
)
{
/*
argv with launch file:
0: path to node
1: additional argument (the result of shape=... in this case)
2: name of the node
3: path to log
*/
TurtleApp
app
(
argc
,
argv
);
return
app
.
exec
();
std
::
string
shape
=
argv
[
1
];
return
app
.
exec
(
shape
);
}
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