-
Notifications
You must be signed in to change notification settings - Fork 142
Fixed auto reconnection to the RTDE server. #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
174955d
ce23e6d
d7a622a
d3c06eb
e55432d
b64aef3
676797b
2b1197e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ class URProducer : public IProducer<T> | |
| URStream<T>& stream_; | ||
| Parser<T>& parser_; | ||
| std::chrono::seconds timeout_; | ||
| std::function<void()> on_rtde_reconnect_cb_; | ||
|
|
||
| bool running_; | ||
|
|
||
|
|
@@ -124,9 +125,28 @@ class URProducer : public IProducer<T> | |
| if (!running_) | ||
| return true; | ||
|
|
||
| if (stream_.getState() == SocketState::Connected) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| if (stream_.closed()) | ||
| return false; | ||
|
|
||
| if (stream_.getStreamType() == URStreamType::RTDE) | ||
| { | ||
| if (on_rtde_reconnect_cb_) | ||
| { | ||
| URCL_LOG_WARN("Failed to read from RTDE stream, invoking on reconnect callback and stopping the producer"); | ||
| on_rtde_reconnect_cb_(); | ||
| } | ||
| else | ||
| { | ||
| URCL_LOG_ERROR("Failed to read from RTDE stream without a reconnect handler stopping the producer"); | ||
| } | ||
| return false; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't really like the special handling of an RTDE producer here. Couldn't we generalize this by checking whether there is a reconnection callback registered? If none then we simply do not reconnect and if yes, trigger reconnect independent of the stream type. Sorry that I just come up with this now, but that seems cleaner to me.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reconnecting to the stream, will just not have any affect if it is a RTDE stream, but I will change the check. |
||
|
|
||
| URCL_LOG_WARN("Failed to read from stream, reconnecting in %ld seconds...", timeout_.count()); | ||
| std::this_thread::sleep_for(timeout_); | ||
|
|
||
|
|
@@ -140,6 +160,17 @@ class URProducer : public IProducer<T> | |
|
|
||
| return false; | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Sets the RTDE reconnection callback. RTDE requires setting up the communication again upon reconnection | ||
| * it is not enough to just reconnect to the stream. | ||
| * | ||
| * \param on_rtde_reconnect_cb Callback to be invoked when connection is lost to the RTDE stream. | ||
| */ | ||
| void setRTDEReconnectionCallback(std::function<void()> on_rtde_reconnect_cb) | ||
| { | ||
| on_rtde_reconnect_cb_ = on_rtde_reconnect_cb; | ||
| } | ||
| }; | ||
| } // namespace comm | ||
| } // namespace urcl | ||
Uh oh!
There was an error while loading. Please reload this page.