Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
591ba07e
Commit
591ba07e
authored
Aug 24, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
e089277b
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
264 additions
and
1556 deletions
+264
-1556
qgroundcontrol.pro
qgroundcontrol.pro
+2
-1
WimaPolygonArray.h
src/Wima/Geometry/WimaPolygonArray.h
+5
-2
WimaController.cc
src/Wima/WimaController.cc
+94
-57
WimaController.h
src/Wima/WimaController.h
+2
-1
WimaController_new.cc
src/Wima/WimaController_new.cc
+0
-924
WimaController_new.h
src/Wima/WimaController_new.h
+0
-421
RosBridgeClient.cpp
src/comm/ros_bridge/include/RosBridgeClient.cpp
+82
-80
com_private.cpp
src/comm/ros_bridge/include/com_private.cpp
+0
-8
geopoint.cpp
.../ros_bridge/include/messages/geographic_msgs/geopoint.cpp
+1
-1
geopoint.h
...mm/ros_bridge/include/messages/geographic_msgs/geopoint.h
+0
-3
point32.h
src/comm/ros_bridge/include/messages/geometry_msgs/point32.h
+0
-3
polygon.h
src/comm/ros_bridge/include/messages/geometry_msgs/polygon.h
+0
-3
polygon_stamped.h
...s_bridge/include/messages/geometry_msgs/polygon_stamped.h
+0
-3
polygon_array.h
...dge/include/messages/jsk_recognition_msgs/polygon_array.h
+0
-4
heartbeat.h
src/comm/ros_bridge/include/messages/nemo_msgs/heartbeat.h
+0
-3
progress.h
src/comm/ros_bridge/include/messages/nemo_msgs/progress.h
+0
-3
header.h
src/comm/ros_bridge/include/messages/std_msgs/header.h
+0
-3
time.h
src/comm/ros_bridge/include/messages/std_msgs/time.h
+0
-3
ros_bridge.h
src/comm/ros_bridge/include/ros_bridge.h
+4
-1
topic_publisher.cpp
src/comm/ros_bridge/include/topic_publisher.cpp
+61
-32
topic_publisher.h
src/comm/ros_bridge/include/topic_publisher.h
+3
-0
ros_bridge.cpp
src/comm/ros_bridge/src/ros_bridge.cpp
+10
-0
No files found.
qgroundcontrol.pro
View file @
591ba07e
...
...
@@ -28,11 +28,12 @@ QGCROOT = $$PWD
DebugBuild
{
DESTDIR
=
$$
{
OUT_PWD
}
/
debug
DEFINES
+=
DEBUG
DEFINES
+=
ROS_BRIDGE_DEBUG
#
DEFINES
+=
ROS_BRIDGE_CLIENT_DEBUG
}
else
{
DESTDIR
=
$$
{
OUT_PWD
}
/
release
DEFINES
+=
DEBUG
DEFINES
+=
ROS_BRIDGE_
DEBUG
DEFINES
+=
NDEBUG
}
...
...
src/Wima/Geometry/WimaPolygonArray.h
View file @
591ba07e
...
...
@@ -13,6 +13,9 @@ public:
WimaPolygonArray
(
const
WimaPolygonArray
&
other
)
:
_polygons
(
other
.
_polygons
),
_dirty
(
true
)
{}
~
WimaPolygonArray
(){
_objs
.
clearAndDeleteContents
();
}
class
QmlObjectListModel
*
QmlObjectListModel
(){
if
(
_dirty
)
...
...
@@ -34,9 +37,9 @@ public:
private:
void
_updateObjects
(
void
){
_objs
.
clear
();
_objs
.
clear
AndDeleteContents
();
for
(
long
i
=
0
;
i
<
_polygons
.
size
();
++
i
){
_objs
.
append
(
&
_polygons
[
i
]
);
_objs
.
append
(
new
PolygonType
(
_polygons
[
i
])
);
}
}
...
...
src/Wima/WimaController.cc
View file @
591ba07e
This diff is collapsed.
Click to expand it.
src/Wima/WimaController.h
View file @
591ba07e
...
...
@@ -337,7 +337,7 @@ private slots:
void
_snakeStoreWorkerResults
();
void
_initStartSnakeWorker
();
void
_switchSnakeManager
(
QVariant
variant
);
void
_setupTopicService
();
bool
_doTopicServiceSetup
();
// Periodic tasks.
void
_eventTimerHandler
(
void
);
// Waypoint manager handling.
...
...
@@ -407,6 +407,7 @@ private:
int
_fallbackStatus
;
ROSBridgePtr
_pRosBridge
;
static
StatusMap
_nemoStatusMap
;
bool
_topicServiceSetupDone
;
// Periodic tasks.
QTimer
_eventTimer
;
...
...
src/Wima/WimaController_new.cc
deleted
100644 → 0
View file @
e089277b
This diff is collapsed.
Click to expand it.
src/Wima/WimaController_new.h
deleted
100644 → 0
View file @
e089277b
This diff is collapsed.
Click to expand it.
src/comm/ros_bridge/include/RosBridgeClient.cpp
View file @
591ba07e
This diff is collapsed.
Click to expand it.
src/comm/ros_bridge/include/com_private.cpp
View file @
591ba07e
...
...
@@ -20,18 +20,10 @@ bool ros_bridge::com_private::getTopic(const ros_bridge::com_private::JsonDoc &d
{
if
(
doc
.
HasMember
(
"topic"
)
&&
doc
[
"topic"
].
IsString
()
){
rapidjson
::
StringBuffer
sb1
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer1
(
sb1
);
doc
.
Accept
(
writer1
);
std
::
cout
<<
"getTopic doc: "
<<
sb1
.
GetString
()
<<
std
::
endl
;
rapidjson
::
StringBuffer
sb
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
sb
);
doc
[
"topic"
].
Accept
(
writer
);
topic
=
sb
.
GetString
();
std
::
cout
<<
"getTopic topic: "
<<
sb
.
GetString
()
<<
std
::
endl
;
return
true
;
}
else
return
false
;
...
...
src/comm/ros_bridge/include/messages/geographic_msgs/geopoint.cpp
View file @
591ba07e
#include "geopoint.h"
std
::
string
ros_bridge
::
messages
::
geographic_msgs
::
geo_point
::
messageType
(){
return
"geo
metry
_msgs/GeoPoint"
;
return
"geo
graphic
_msgs/GeoPoint"
;
}
src/comm/ros_bridge/include/messages/geographic_msgs/geopoint.h
View file @
591ba07e
...
...
@@ -109,9 +109,6 @@ bool toJson(const T&p, rapidjson::Value &value, rapidjson::Document::AllocatorTy
auto
altitude
=
detail
::
getAltitude
(
p
,
traits
::
Type2Type
<
Components
>
());
// If T has no member altitude() replace it by 0.0;
value
.
AddMember
(
"altitude"
,
rapidjson
::
Value
().
SetFloat
((
_Float64
)
altitude
),
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/geometry_msgs/point32.h
View file @
591ba07e
...
...
@@ -103,9 +103,6 @@ bool toJson(const T&p, rapidjson::Value &value, rapidjson::Document::AllocatorTy
auto
z
=
detail
::
getZ
(
p
,
Type2Type
<
Components
>
());
// If T has no member z() replace it by 0.
value
.
AddMember
(
"z"
,
rapidjson
::
Value
().
SetFloat
(
z
),
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/geometry_msgs/polygon.h
View file @
591ba07e
...
...
@@ -57,9 +57,6 @@ bool toJson(const PolygonType &poly, rapidjson::Value &value, rapidjson::Documen
}
value
.
AddMember
(
"points"
,
points
,
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/geometry_msgs/polygon_stamped.h
View file @
591ba07e
...
...
@@ -95,9 +95,6 @@ bool _toJson(const PolygonType &poly,
}
value
.
AddMember
(
"header"
,
header
,
allocator
);
value
.
AddMember
(
"polygon"
,
polygon
,
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/jsk_recognition_msgs/polygon_array.h
View file @
591ba07e
...
...
@@ -183,10 +183,6 @@ namespace detail {
detail
::
likelihoodToJson
(
p
,
jLikelihood
,
allocator
,
traits
::
Int2Type
<
HasLikelihood
::
value
>
());
value
.
AddMember
(
"likelihood"
,
jLikelihood
,
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/nemo_msgs/heartbeat.h
View file @
591ba07e
...
...
@@ -32,9 +32,6 @@ template <class HeartbeatType>
bool
toJson
(
const
HeartbeatType
&
heartbeat
,
rapidjson
::
Value
&
value
,
rapidjson
::
Document
::
AllocatorType
&
allocator
)
{
value
.
AddMember
(
"status"
,
std
::
int32_t
(
heartbeat
.
status
()),
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/nemo_msgs/progress.h
View file @
591ba07e
...
...
@@ -41,9 +41,6 @@ bool toJson(const ProgressType &p, rapidjson::Value &value, rapidjson::Document:
jProgress
.
PushBack
(
rapidjson
::
Value
().
SetInt
(
std
::
int32_t
(
p
.
progress
()[
i
])),
allocator
);
}
value
.
AddMember
(
"progress"
,
jProgress
,
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/std_msgs/header.h
View file @
591ba07e
...
...
@@ -62,9 +62,6 @@ bool toJson(const HeaderType &header,
header
.
frameId
().
length
(),
allocator
),
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/messages/std_msgs/time.h
View file @
591ba07e
...
...
@@ -37,9 +37,6 @@ bool toJson(const TimeType &time,
{
value
.
AddMember
(
"secs"
,
rapidjson
::
Value
().
SetUint
(
uint32_t
(
time
.
secs
())),
allocator
);
value
.
AddMember
(
"nsecs"
,
rapidjson
::
Value
().
SetUint
(
uint32_t
(
time
.
nSecs
())),
allocator
);
rapidjson
::
Value
jType
;
jType
.
SetString
(
messageType
().
c_str
(),
allocator
);
value
.
AddMember
(
"type"
,
jType
,
allocator
);
return
true
;
}
...
...
src/comm/ros_bridge/include/ros_bridge.h
View file @
591ba07e
...
...
@@ -23,13 +23,16 @@ public:
void
advertiseService
(
const
char
*
service
,
const
char
*
type
,
const
std
::
function
<
JsonDocUPtr
(
JsonDocUPtr
)
>
&
callback
);
void
advertiseTopic
(
const
char
*
topic
,
const
char
*
type
);
//! @brief Start ROS bridge.
void
start
();
//! @brief Stops ROS bridge.
void
reset
();
//! @return Returns true if connected to the rosbridge_server, false either.
//! @note
This function can block up to 100ms. However normal execution time is smaller
.
//! @note
\fn calls start()
.
bool
connected
();
bool
isRunning
();
...
...
src/comm/ros_bridge/include/topic_publisher.cpp
View file @
591ba07e
...
...
@@ -20,8 +20,6 @@ void ros_bridge::com_private::TopicPublisher::start()
return
;
_stopped
->
store
(
false
);
_pThread
=
std
::
make_unique
<
std
::
thread
>
([
this
]{
// Init.
std
::
unordered_map
<
std
::
string
,
std
::
string
>
topicMap
;
// Main Loop.
while
(
!
this
->
_stopped
->
load
()
){
std
::
unique_lock
<
std
::
mutex
>
lk
(
this
->
_mutex
);
...
...
@@ -39,38 +37,25 @@ void ros_bridge::com_private::TopicPublisher::start()
// Get topic and type from Json message and remove it.
std
::
string
topic
;
assert
(
com_private
::
getTopic
(
*
pJsonDoc
,
topic
));
assert
(
com_private
::
removeTopic
(
*
pJsonDoc
));
std
::
string
type
;
assert
(
com_private
::
getType
(
*
pJsonDoc
,
type
));
assert
(
com_private
::
removeType
(
*
pJsonDoc
));
// Check if topic must be advertised.
std
::
string
clientName
=
ros_bridge
::
com_private
::
_topicAdvertiserKey
+
topic
;
auto
it
=
topicMap
.
find
(
clientName
);
if
(
it
==
topicMap
.
end
())
{
// Need to advertise topic?
topicMap
.
insert
(
std
::
make_pair
(
clientName
,
topic
));
this
->
_rbc
.
addClient
(
clientName
);
this
->
_rbc
.
advertise
(
clientName
,
topic
,
type
);
this
->
_rbc
.
waitForTopic
(
topic
,
[
this
]{
return
this
->
_stopped
->
load
();
});
// Wait until topic is advertised.
}
bool
ret
=
com_private
::
getTopic
(
*
pJsonDoc
,
topic
);
assert
(
ret
);
(
void
)
ret
;
ret
=
com_private
::
removeTopic
(
*
pJsonDoc
);
assert
(
ret
);
(
void
)
ret
;
// Wait for topic (Rosbridge needs some time to process a advertise() request).
this
->
_rbc
.
waitForTopic
(
topic
,
[
this
]{
return
this
->
_stopped
->
load
();
});
// Publish Json message.
if
(
!
this
->
_stopped
->
load
()
)
this
->
_rbc
.
publish
(
topic
,
*
pJsonDoc
);
}
// while loop
// Tidy up.
for
(
auto
&
it
:
topicMap
){
this
->
_rbc
.
unadvertise
(
it
.
second
);
this
->
_rbc
.
removeClient
(
it
.
first
);
}
#ifdef ROS_BRIDGE_DEBUG
std
::
cout
<<
"TopicPublisher: publisher thread terminated."
<<
std
::
endl
;
#endif
});
}
...
...
@@ -87,7 +72,13 @@ void ros_bridge::com_private::TopicPublisher::reset()
return
;
_pThread
->
join
();
lk
.
lock
();
lk
.
lock
();
// Tidy up.
for
(
auto
&
it
:
this
->
_topicMap
){
this
->
_rbc
.
unadvertise
(
it
.
first
);
this
->
_rbc
.
removeClient
(
it
.
second
);
}
this
->
_topicMap
.
clear
();
_queue
.
clear
();
}
...
...
@@ -95,14 +86,52 @@ void ros_bridge::com_private::TopicPublisher::publish(
ros_bridge
::
com_private
::
JsonDocUPtr
docPtr
,
const
char
*
topic
)
{
std
::
cout
<<
"TopicPublisher
\"
topic
\"
: "
<<
topic
<<
std
::
endl
;
// Check if topic was advertised.
std
::
string
t
(
topic
);
std
::
unique_lock
<
std
::
mutex
>
lk
(
this
->
_mutex
);
auto
it
=
this
->
_topicMap
.
find
(
t
);
if
(
it
==
this
->
_topicMap
.
end
())
{
// Not yet advertised?
lk
.
unlock
();
#ifdef ROS_BRIDGE_DEBUG
std
::
cerr
<<
"TopicPublisher: topic "
<<
t
<<
" not yet advertised"
<<
std
::
endl
;
#endif
return
;
}
lk
.
unlock
();
// Add topic information to json doc.
auto
&
allocator
=
docPtr
->
GetAllocator
();
rapidjson
::
Value
key
(
"topic"
,
allocator
);
rapidjson
::
Value
value
(
topic
,
allocator
);
docPtr
->
AddMember
(
key
,
value
,
allocator
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
_mutex
);
lk
.
lock
();
_queue
.
push_back
(
std
::
move
(
docPtr
));
l
oc
k
.
unlock
();
lk
.
unlock
();
_cv
.
notify_one
();
// Wake publisher thread.
}
bool
ros_bridge
::
com_private
::
TopicPublisher
::
advertise
(
const
char
*
topic
,
const
char
*
type
)
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
this
->
_mutex
);
std
::
string
t
(
topic
);
auto
it
=
this
->
_topicMap
.
find
(
t
);
if
(
it
==
this
->
_topicMap
.
end
())
{
// Need to advertise topic?
std
::
string
clientName
=
std
::
string
(
ros_bridge
::
com_private
::
_topicAdvertiserKey
)
+
t
;
this
->
_topicMap
.
insert
(
std
::
make_pair
(
t
,
clientName
));
lk
.
unlock
();
this
->
_rbc
.
addClient
(
clientName
);
this
->
_rbc
.
advertise
(
clientName
,
t
,
type
);
return
true
;
}
else
{
lk
.
unlock
();
#if ROS_BRIDGE_DEBUG
std
::
cerr
<<
"TopicPublisher: topic "
<<
topic
<<
" already advertised"
<<
std
::
endl
;
#endif
return
false
;
}
}
src/comm/ros_bridge/include/topic_publisher.h
View file @
591ba07e
...
...
@@ -31,9 +31,12 @@ public:
void
reset
();
void
publish
(
JsonDocUPtr
docPtr
,
const
char
*
topic
);
bool
advertise
(
const
char
*
topic
,
const
char
*
type
);
private:
using
TopicMap
=
std
::
unordered_map
<
std
::
string
,
std
::
string
>
;
JsonQueue
_queue
;
TopicMap
_topicMap
;
std
::
mutex
_mutex
;
std
::
shared_ptr
<
std
::
atomic_bool
>
_stopped
;
RosbridgeWsClient
&
_rbc
;
...
...
src/comm/ros_bridge/src/ros_bridge.cpp
View file @
591ba07e
...
...
@@ -32,8 +32,15 @@ void ros_bridge::ROSBridge::advertiseService(const char *service,
_server
.
advertiseService
(
service
,
type
,
callback
);
}
void
ros_bridge
::
ROSBridge
::
advertiseTopic
(
const
char
*
topic
,
const
char
*
type
)
{
_topicPublisher
.
advertise
(
topic
,
type
);
}
void
ros_bridge
::
ROSBridge
::
start
()
{
if
(
!
_stopped
->
load
()
)
return
;
_stopped
->
store
(
false
);
_rbc
.
run
();
_topicPublisher
.
start
();
...
...
@@ -44,6 +51,8 @@ void ros_bridge::ROSBridge::start()
void
ros_bridge
::
ROSBridge
::
reset
()
{
auto
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
if
(
_stopped
->
load
()
)
return
;
_stopped
->
store
(
true
);
_topicPublisher
.
reset
();
_topicSubscriber
.
reset
();
...
...
@@ -56,6 +65,7 @@ void ros_bridge::ROSBridge::reset()
bool
ros_bridge
::
ROSBridge
::
connected
()
{
start
();
return
_rbc
.
connected
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment