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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2v
turtlesim_xl
Commits
f25e4a59
Commit
f25e4a59
authored
3 years ago
by
Joel Vongehr
Browse files
Options
Downloads
Patches
Plain Diff
added msg type img; poc for receiving msgs & drawing
parent
65e9b6d0
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
CMakeLists.txt
+14
-2
14 additions, 2 deletions
CMakeLists.txt
msg/img.msg
+4
-0
4 additions, 0 deletions
msg/img.msg
src/turtlesim_xl.cpp
+22
-4
22 additions, 4 deletions
src/turtlesim_xl.cpp
with
40 additions
and
6 deletions
CMakeLists.txt
+
14
−
2
View file @
f25e4a59
cmake_minimum_required
(
VERSION 3.0.2
)
cmake_minimum_required
(
VERSION 3.0.2
)
project
(
turtlesim_xl
)
project
(
turtlesim_xl
)
find_package
(
catkin REQUIRED COMPONENTS geometry_msgs message_generation rosconsole roscpp roscpp_serialization roslib rostime std_msgs std_srvs
)
find_package
(
catkin REQUIRED COMPONENTS
geometry_msgs
message_generation
rosconsole
roscpp
roscpp_serialization
roslib
rostime
std_msgs
std_srvs
)
find_package
(
Qt5Widgets REQUIRED
)
find_package
(
Qt5Widgets REQUIRED
)
find_package
(
Boost REQUIRED COMPONENTS thread
)
find_package
(
Boost REQUIRED COMPONENTS thread
)
...
@@ -10,13 +20,15 @@ include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
...
@@ -10,13 +20,15 @@ include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
link_directories
(
${
catkin_LIBRARY_DIRS
}
)
link_directories
(
${
catkin_LIBRARY_DIRS
}
)
add_message_files
(
DIRECTORY msg FILES
add_message_files
(
DIRECTORY msg FILES
Color.msg Pose.msg
)
Color.msg Pose.msg img.msg
)
add_service_files
(
DIRECTORY srv FILES
add_service_files
(
DIRECTORY srv FILES
Kill.srv
Kill.srv
SetPen.srv
SetPen.srv
Spawn.srv
Spawn.srv
TeleportAbsolute.srv
TeleportAbsolute.srv
TeleportRelative.srv
)
TeleportRelative.srv
)
generate_messages
(
DEPENDENCIES geometry_msgs std_msgs std_srvs
)
generate_messages
(
DEPENDENCIES geometry_msgs std_msgs std_srvs
)
catkin_package
(
CATKIN_DEPENDS geometry_msgs message_runtime std_msgs std_srvs
)
catkin_package
(
CATKIN_DEPENDS geometry_msgs message_runtime std_msgs std_srvs
)
...
...
This diff is collapsed.
Click to expand it.
msg/img.msg
0 → 100644
+
4
−
0
View file @
f25e4a59
int64 x
int64 y
# uint64[] img
string imgPath
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/turtlesim_xl.cpp
+
22
−
4
View file @
f25e4a59
...
@@ -32,9 +32,13 @@
...
@@ -32,9 +32,13 @@
#include
<ros/ros.h>
#include
<ros/ros.h>
#include
"turtlesim/turtle_frame.h"
#include
"turtlesim/turtle_frame.h"
#include
<turtlesim_xl/img.h>
class
TurtleApp
:
public
QApplication
class
TurtleApp
:
public
QApplication
{
{
turtlesim_xl
::
img
shapeData
;
ros
::
Subscriber
shapeSub
;
turtlesim
::
TurtleFrame
*
frame
;
public:
public:
ros
::
NodeHandlePtr
nh_
;
ros
::
NodeHandlePtr
nh_
;
...
@@ -42,18 +46,32 @@ public:
...
@@ -42,18 +46,32 @@ public:
:
QApplication
(
argc
,
argv
)
:
QApplication
(
argc
,
argv
)
{
{
ros
::
init
(
argc
,
argv
,
"turtlesim"
,
ros
::
init_options
::
NoSigintHandler
);
ros
::
init
(
argc
,
argv
,
"turtlesim"
,
ros
::
init_options
::
NoSigintHandler
);
ros
::
NodeHandle
n
;
nh_
.
reset
(
new
ros
::
NodeHandle
);
nh_
.
reset
(
new
ros
::
NodeHandle
);
// turtlesim::TurtleFrame fr;
// frame = &fr;
frame
=
new
turtlesim
::
TurtleFrame
();
shapeSub
=
n
.
subscribe
(
"/shapeData"
,
10
,
&
TurtleApp
::
updateShape
,
this
);
}
}
int
exec
(
std
::
string
shape
=
"rectangle"
)
int
exec
(
std
::
string
shape
=
"rectangle"
)
{
{
turtlesim
::
TurtleFrame
frame
;
frame
->
setShape
(
shape
)
;
frame
.
setShape
(
shape
);
ROS_INFO
(
"Offset before calling draw: x = %d; y = %d"
,
shapeData
.
x
,
shapeData
.
y
);
frame
.
drawShape
();
frame
->
drawShape
();
frame
.
show
();
frame
->
show
();
return
QApplication
::
exec
();
return
QApplication
::
exec
();
}
}
private
:
void
updateShape
(
turtlesim_xl
::
img
data
)
{
shapeData
=
data
;
ROS_INFO
(
"NEW SHAPE DATA SAVED"
);
frame
->
setShape
(
"triangle"
);
frame
->
drawShape
();
}
};
};
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
...
...
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