Skip to content

Commit

Permalink
Merge pull request #60 from ethz-asl/feature/resetTranslationFunction
Browse files Browse the repository at this point in the history
Added DeviceTimeTranslator::resetTranslation method.
  • Loading branch information
HannesSommer authored Mar 5, 2020
2 parents be54835 + 892696b commit 8f99270
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class DeviceTimeTranslator {
* @return the current one way translator. Stays valid until the next update. Can be null.
*/
const OneWayTranslator * getCurrentOwt() const;

/**
* Reset the translation state while keeping the expected settings such as expected algorithm or switch time.
*/
void resetTranslation();
private:
void configCallback(DeviceTimeTranslatorConfig &config, uint32_t level);

Expand Down Expand Up @@ -153,7 +158,7 @@ class DeviceTimeUnwrapperAndTranslator {

ros::Time translate(UnwrappedStamp unwrappedStamp) const;
bool isReadyToTranslate() const;

FilterAlgorithm getCurrentFilterAlgorithm() const {
return translator.getCurrentFilterAlgorithm();
}
Expand All @@ -176,6 +181,13 @@ class DeviceTimeUnwrapperAndTranslator {
const OneWayTranslator* getCurrentOwt() const {
return translator.getCurrentOwt();
}

/**
* Reset the translation state while keeping the expected settings such as expected algorithm or switch time.
*/
void resetTranslation() {
translator.resetTranslation();
}
protected:
Unwrapper timestampUnwrapper;
DeviceTimeTranslator translator;
Expand Down
4 changes: 2 additions & 2 deletions cuckoo_time_translator/package.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0"?>
<package format="2">
<name>cuckoo_time_translator</name>
<version>0.0.2</version>
<version>0.0.3</version>
<description>This library intends to do most of the dirty work required within a device driver that emoploys one way device time translation.
This includes:
* handling the one way translator
* sending special timing messages (DeviceTimestamp) for debugging and evaluation (e.g. with ctt_introspect in the cuckoo_time_translator_python package)
* provide dynamic confiugration for the one way translation algorithm
* provide dynamic configuration for the one way translation algorithm
</description>

<author email="[email protected]">Hannes Sommer</author>
Expand Down
7 changes: 7 additions & 0 deletions cuckoo_time_translator/src/DeviceTimeTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ class DeviceTimeTranslator::Impl {
return timeTranslator_.get();
}

void resetTranslation() {
timeTranslator_.reset();
}
private:

template <typename Owt>
Expand Down Expand Up @@ -310,6 +313,10 @@ void DeviceTimeTranslator::setFilterAlgorithm(FilterAlgorithm filterAlgorithm) {
pImpl_->setExpectedAlgo(filterAlgorithm);
}

void DeviceTimeTranslator::resetTranslation() {
pImpl_->resetTranslation();
}

ros::Time DeviceTimeTranslator::update(const TimestampUnwrapper & timestampUnwrapper, const ros::Time & receiveTime, const double offsetSecs) {
if(!pImpl_) return receiveTime;

Expand Down

0 comments on commit 8f99270

Please sign in to comment.