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
823c2823
Commit
823c2823
authored
Aug 06, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread errors now, error when unadvertising services
parent
5c6b9306
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
23 deletions
+44
-23
RosBridgeClient.h
src/comm/ros_bridge/include/RosBridgeClient.h
+25
-23
Server.cpp
src/comm/ros_bridge/include/Server.cpp
+5
-0
TopicPublisher.cpp
src/comm/ros_bridge/include/TopicPublisher.cpp
+6
-0
TopicSubscriber.cpp
src/comm/ros_bridge/include/TopicSubscriber.cpp
+4
-0
ROSBridge.cpp
src/comm/ros_bridge/src/ROSBridge.cpp
+4
-0
No files found.
src/comm/ros_bridge/include/RosBridgeClient.h
View file @
823c2823
...
@@ -135,28 +135,29 @@ public:
...
@@ -135,28 +135,29 @@ public:
// The execution can take up to 100 ms!
// The execution can take up to 100 ms!
bool
connected
(){
bool
connected
(){
auto
p
=
std
::
make_shared
<
std
::
promise
<
void
>>
();
// auto p = std::make_shared<std::promise<void>>();
auto
future
=
p
->
get_future
();
// auto future = p->get_future();
auto
callback
=
[](
std
::
shared_ptr
<
WsClient
::
Connection
>
connection
,
std
::
shared_ptr
<
std
::
promise
<
void
>>
p
)
{
// auto status_client = std::make_shared<WsClient>(server_port_path);
p
->
set_value
();
// status_client->on_open = [p](std::shared_ptr<WsClient::Connection>) {
connection
->
send_close
(
1000
);
// p->set_value();
};
// };
std
::
shared_ptr
<
WsClient
>
status_client
=
std
::
make_shared
<
WsClient
>
(
server_port_path
);
status_client
->
on_open
=
std
::
bind
(
callback
,
std
::
placeholders
::
_1
,
p
);
// std::thread t([status_client]{
// status_client->start();
std
::
async
([
status_client
]{
// status_client->on_open = NULL;
// status_client->on_message = NULL;
status_client
->
start
();
// status_client->on_close = NULL;
status_client
->
on_open
=
NULL
;
// status_client->on_error = NULL;
status_client
->
on_message
=
NULL
;
// });
status_client
->
on_close
=
NULL
;
status_client
->
on_error
=
NULL
;
// auto status = future.wait_for(std::chrono::milliseconds(20));
// status_client->stop();
});
// t.join();
// bool connected = status == std::future_status::ready;
auto
status
=
future
.
wait_for
(
std
::
chrono
::
milliseconds
(
100
));
// //std::cout << "connected(): " << connected << std::endl;
return
status
==
std
::
future_status
::
ready
;
// return connected;
return
true
;
}
}
// Adds a client to the client_map.
// Adds a client to the client_map.
...
@@ -234,6 +235,7 @@ public:
...
@@ -234,6 +235,7 @@ public:
std
::
cout
<<
client_name
<<
" has been removed"
<<
std
::
endl
;
std
::
cout
<<
client_name
<<
" has been removed"
<<
std
::
endl
;
#endif
#endif
});
});
it
->
second
.
reset
();
client_map
.
erase
(
it
);
client_map
.
erase
(
it
);
t
.
detach
();
t
.
detach
();
}
}
...
@@ -329,7 +331,7 @@ public:
...
@@ -329,7 +331,7 @@ public:
#ifdef DEBUG
#ifdef DEBUG
client
->
on_open
=
[
this
,
topic
,
message
,
client_name
](
std
::
shared_ptr
<
WsClient
::
Connection
>
connection
)
{
client
->
on_open
=
[
this
,
topic
,
message
,
client_name
](
std
::
shared_ptr
<
WsClient
::
Connection
>
connection
)
{
#else
#else
client
->
on_open
=
[
this
,
topic
,
message
,
ready
](
std
::
shared_ptr
<
WsClient
::
Connection
>
connection
)
{
client
->
on_open
=
[
this
,
topic
,
message
](
std
::
shared_ptr
<
WsClient
::
Connection
>
connection
)
{
#endif
#endif
#ifdef DEBUG
#ifdef DEBUG
...
...
src/comm/ros_bridge/include/Server.cpp
View file @
823c2823
...
@@ -88,9 +88,14 @@ void ROSBridge::ComPrivate::Server::reset()
...
@@ -88,9 +88,14 @@ void ROSBridge::ComPrivate::Server::reset()
{
{
if
(
_stopped
->
load
()
)
if
(
_stopped
->
load
()
)
return
;
return
;
std
::
cout
<<
"Server: _stopped->store(true)"
<<
std
::
endl
;
_stopped
->
store
(
true
);
for
(
const
auto
&
item
:
_serviceMap
){
for
(
const
auto
&
item
:
_serviceMap
){
std
::
cout
<<
"Server: unadvertiseService "
<<
item
.
second
<<
std
::
endl
;
_rbc
.
unadvertiseService
(
item
.
second
);
_rbc
.
unadvertiseService
(
item
.
second
);
std
::
cout
<<
"Server: removeClient "
<<
item
.
first
<<
std
::
endl
;
_rbc
.
removeClient
(
item
.
first
);
_rbc
.
removeClient
(
item
.
first
);
}
}
std
::
cout
<<
"Server: _serviceMap cleared "
<<
std
::
endl
;
_serviceMap
.
clear
();
_serviceMap
.
clear
();
}
}
src/comm/ros_bridge/include/TopicPublisher.cpp
View file @
823c2823
...
@@ -69,6 +69,8 @@ void ROSBridge::ComPrivate::TopicPublisher::start()
...
@@ -69,6 +69,8 @@ void ROSBridge::ComPrivate::TopicPublisher::start()
this
->
_rbc
.
unadvertise
(
it
.
second
);
this
->
_rbc
.
unadvertise
(
it
.
second
);
this
->
_rbc
.
removeClient
(
it
.
first
);
this
->
_rbc
.
removeClient
(
it
.
first
);
}
}
std
::
cout
<<
"TopicPublisher: publisher thread terminated."
<<
std
::
endl
;
});
});
}
}
...
@@ -76,11 +78,15 @@ void ROSBridge::ComPrivate::TopicPublisher::reset()
...
@@ -76,11 +78,15 @@ void ROSBridge::ComPrivate::TopicPublisher::reset()
{
{
if
(
_stopped
->
load
()
)
// stop called while thread not running.
if
(
_stopped
->
load
()
)
// stop called while thread not running.
return
;
return
;
std
::
cout
<<
"TopicPublisher: _stopped->store(true)."
<<
std
::
endl
;
_stopped
->
store
(
true
);
_stopped
->
store
(
true
);
std
::
cout
<<
"TopicPublisher: ask publisher thread to stop."
<<
std
::
endl
;
_cv
.
notify_one
();
// Wake publisher thread.
_cv
.
notify_one
();
// Wake publisher thread.
if
(
!
_pThread
)
if
(
!
_pThread
)
return
;
return
;
_pThread
->
join
();
_pThread
->
join
();
std
::
cout
<<
"TopicPublisher: publisher thread joined."
<<
std
::
endl
;
_queue
.
clear
();
_queue
.
clear
();
std
::
cout
<<
"TopicPublisher: queue cleard."
<<
std
::
endl
;
}
}
src/comm/ros_bridge/include/TopicSubscriber.cpp
View file @
823c2823
...
@@ -23,14 +23,18 @@ void ROSBridge::ComPrivate::TopicSubscriber::start()
...
@@ -23,14 +23,18 @@ void ROSBridge::ComPrivate::TopicSubscriber::start()
void
ROSBridge
::
ComPrivate
::
TopicSubscriber
::
reset
()
void
ROSBridge
::
ComPrivate
::
TopicSubscriber
::
reset
()
{
{
if
(
!
_stopped
->
load
()
){
if
(
!
_stopped
->
load
()
){
std
::
cout
<<
"TopicSubscriber: _stopped->store(true) "
<<
std
::
endl
;
_stopped
->
store
(
true
);
_stopped
->
store
(
true
);
{
{
for
(
auto
&
item
:
_topicMap
){
for
(
auto
&
item
:
_topicMap
){
std
::
cout
<<
"TopicSubscriber: unsubscribe "
<<
item
.
second
<<
std
::
endl
;
_rbc
.
unsubscribe
(
item
.
second
);
_rbc
.
unsubscribe
(
item
.
second
);
std
::
cout
<<
"TopicSubscriber: removeClient "
<<
item
.
first
<<
std
::
endl
;
_rbc
.
removeClient
(
item
.
first
);
_rbc
.
removeClient
(
item
.
first
);
}
}
}
}
_topicMap
.
clear
();
_topicMap
.
clear
();
std
::
cout
<<
"TopicSubscriber: _topicMap cleared "
<<
std
::
endl
;
}
}
}
}
...
...
src/comm/ros_bridge/src/ROSBridge.cpp
View file @
823c2823
...
@@ -43,9 +43,13 @@ void ROSBridge::ROSBridge::start()
...
@@ -43,9 +43,13 @@ void ROSBridge::ROSBridge::start()
void
ROSBridge
::
ROSBridge
::
reset
()
void
ROSBridge
::
ROSBridge
::
reset
()
{
{
std
::
cout
<<
"ROSBridge::reset: reset publisher"
<<
std
::
endl
;
_topicPublisher
.
reset
();
_topicPublisher
.
reset
();
std
::
cout
<<
"ROSBridge::reset: reset subscriber"
<<
std
::
endl
;
_topicSubscriber
.
reset
();
_topicSubscriber
.
reset
();
std
::
cout
<<
"ROSBridge::reset: reset server"
<<
std
::
endl
;
_server
.
reset
();
_server
.
reset
();
std
::
cout
<<
"ROSBridge::reset: _stopped->store(true)"
<<
std
::
endl
;
_stopped
->
store
(
true
);
_stopped
->
store
(
true
);
}
}
...
...
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