Skip to content

Commit

Permalink
Merge pull request #145 from nasa-jpl/dwai-bump-explicit-interpolatio…
Browse files Browse the repository at this point in the history
…n-delay

Bump ExplicitInterpolationCyclesDelay threshold
  • Loading branch information
dwai-wai authored Dec 24, 2024
2 parents 9731ff9 + 3c8ed3b commit 167fe27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 3.11)
project(fastcat
DESCRIPTION "C++ EtherCAT Device Command & Control Library"
VERSION 0.13.0
VERSION 0.13.3
LANGUAGES C CXX
)

Expand Down Expand Up @@ -74,7 +74,7 @@ find_package(YamlCpp REQUIRED 0.6.3)
include(FetchContent)
FetchContent_Declare(jsd
GIT_REPOSITORY https://github.com/nasa-jpl/jsd.git
GIT_TAG v3.0.1
GIT_TAG v3.1.0
)
FetchContent_MakeAvailable(jsd)

Expand Down
47 changes: 24 additions & 23 deletions src/manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ bool fastcat::Manager::Process(double external_time)
std::lock_guard<std::mutex> lock(parameter_mutex_);
for (auto it = jsd_map_.begin(); it != jsd_map_.end(); ++it) {
auto ifname = it->first;
auto jsd = it->second;
jsd_read(jsd, 1e6 / target_loop_rate_hz_);
auto jsd = it->second;
jsd_read(jsd, 1e6 / target_loop_rate_hz_);
if (jsd->wkc != jsd->expected_wkc && !IsFaulted()) {
ERROR("Bad working counter experienced on jsd bus %s", ifname.c_str());
jsd_inspect_context(jsd);
Expand Down Expand Up @@ -254,7 +254,7 @@ bool fastcat::Manager::Process(double external_time)

for (auto it = jsd_device_list_.begin(); it != jsd_device_list_.end(); ++it) {
(*it)->SetTime(read_time, monotonic_time);

if (!(*it)->Read()) {
WARNING("Bad Process on %s", (*it)->GetName().c_str());
}
Expand Down Expand Up @@ -471,7 +471,7 @@ bool fastcat::Manager::ConfigJSDBusFromYaml(const YAML::Node& node,
} else if (0 == device_class.compare("El1008")) {
device = std::make_shared<El1008>();

}else if (0 == device_class.compare("El3104")) {
} else if (0 == device_class.compare("El3104")) {
device = std::make_shared<El3104>();

} else if (0 == device_class.compare("El3202")) {
Expand Down Expand Up @@ -539,7 +539,7 @@ bool fastcat::Manager::ConfigJSDBusFromYaml(const YAML::Node& node,
jsd_device_list_.push_back(jsdDevice);
}

return jsd_init(jsd, ifname.c_str(), enable_ar);
return jsd_init(jsd, ifname.c_str(), enable_ar, 1.0e6 / target_loop_rate_hz_);
}

bool fastcat::Manager::ConfigFastcatBusFromYaml(const YAML::Node& node,
Expand Down Expand Up @@ -716,7 +716,7 @@ bool fastcat::Manager::ConfigOfflineBusFromYaml(const YAML::Node& node,
} else if (0 == device_class.compare("El1008")) {
device = std::make_shared<El1008Offline>();

}else if (0 == device_class.compare("Ild1900")) {
} else if (0 == device_class.compare("Ild1900")) {
device = std::make_shared<Ild1900Offline>();

} else if (0 == device_class.compare("GoldActuator")) {
Expand Down Expand Up @@ -1228,61 +1228,62 @@ bool fastcat::Manager::CheckDeviceNameIsUnique(std::string name)
return true;
}

void fastcat::Manager::SetExplicitInterpolationAlgorithmCubic() {
void fastcat::Manager::SetExplicitInterpolationAlgorithmCubic()
{
std::lock_guard<std::mutex> lock(parameter_mutex_);
for (auto device : jsd_device_list_) {
if (device->GetState()->type == GOLD_ACTUATOR_STATE ||
device->GetState()->type == PLATINUM_ACTUATOR_STATE) {
auto actuator = std::dynamic_pointer_cast<fastcat::Actuator>(device);
actuator->SetExplicitInterpolationAlgorithm(
ACTUATOR_EXPLICIT_INTERPOLATION_ALGORITHM_CUBIC
);
ACTUATOR_EXPLICIT_INTERPOLATION_ALGORITHM_CUBIC);
}
}
}

void fastcat::Manager::SetExplicitInterpolationAlgorithmLinear() {
void fastcat::Manager::SetExplicitInterpolationAlgorithmLinear()
{
std::lock_guard<std::mutex> lock(parameter_mutex_);
for (auto device : jsd_device_list_) {
if (device->GetState()->type == GOLD_ACTUATOR_STATE ||
device->GetState()->type == PLATINUM_ACTUATOR_STATE) {
auto actuator = std::dynamic_pointer_cast<fastcat::Actuator>(device);
actuator->SetExplicitInterpolationAlgorithm(
ACTUATOR_EXPLICIT_INTERPOLATION_ALGORITHM_LINEAR
);
ACTUATOR_EXPLICIT_INTERPOLATION_ALGORITHM_LINEAR);
}
}
}

void fastcat::Manager::SetExplicitInterpolationTimestampSourceCspMessage() {
void fastcat::Manager::SetExplicitInterpolationTimestampSourceCspMessage()
{
std::lock_guard<std::mutex> lock(parameter_mutex_);
for (auto device : jsd_device_list_) {
if (device->GetState()->type == GOLD_ACTUATOR_STATE ||
device->GetState()->type == PLATINUM_ACTUATOR_STATE) {
auto actuator = std::dynamic_pointer_cast<fastcat::Actuator>(device);
actuator->SetExplicitInterpolationTimestampSource(
ACTUATOR_EXPLICIT_INTERPOLATION_TIMESTAMP_CSP_MESSAGE
);
ACTUATOR_EXPLICIT_INTERPOLATION_TIMESTAMP_CSP_MESSAGE);
}
}
}

void fastcat::Manager::SetExplicitInterpolationTimestampSourceClock() {
void fastcat::Manager::SetExplicitInterpolationTimestampSourceClock()
{
std::lock_guard<std::mutex> lock(parameter_mutex_);
for (auto device : jsd_device_list_) {
if (device->GetState()->type == GOLD_ACTUATOR_STATE ||
device->GetState()->type == PLATINUM_ACTUATOR_STATE) {
auto actuator = std::dynamic_pointer_cast<fastcat::Actuator>(device);
actuator->SetExplicitInterpolationTimestampSource(
ACTUATOR_EXPLICIT_INTERPOLATION_TIMESTAMP_FASTCAT_CLOCK
);
ACTUATOR_EXPLICIT_INTERPOLATION_TIMESTAMP_FASTCAT_CLOCK);
}
}
}

bool fastcat::Manager::SetExplicitInterpolationCyclesDelay(size_t delay) {
if(delay > 10) {
ERROR("Cannot set cycles delay > 10 for explicit interpolation");
bool fastcat::Manager::SetExplicitInterpolationCyclesDelay(size_t delay)
{
if (delay > 50) {
ERROR("Cannot set cycles delay > 50 for explicit interpolation");
return false;
}
std::lock_guard<std::mutex> lock(parameter_mutex_);
Expand All @@ -1296,7 +1297,8 @@ bool fastcat::Manager::SetExplicitInterpolationCyclesDelay(size_t delay) {
return true;
}

bool fastcat::Manager::SetInterpolationCyclesStale(size_t cycles) {
bool fastcat::Manager::SetInterpolationCyclesStale(size_t cycles)
{
std::lock_guard<std::mutex> lock(parameter_mutex_);
for (auto device : jsd_device_list_) {
if (device->GetState()->type == GOLD_ACTUATOR_STATE ||
Expand All @@ -1307,4 +1309,3 @@ bool fastcat::Manager::SetInterpolationCyclesStale(size_t cycles) {
}
return true;
}

0 comments on commit 167fe27

Please sign in to comment.