Skip to content
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

Various fixes for compat with ViSP 3.6.0 #137

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
247 changes: 173 additions & 74 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,174 @@
{
"cmake.configureOnOpen": true,
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"semaphore": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}
"editor.tabSize": 2,
"C_Cpp.vcFormat.indent.braces": false,
"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "sameLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.namespace": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "newLine",
"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyFunction": true,
"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyType": true,
"C_Cpp.vcFormat.space.beforeInitializerListOpenBrace": true,
"C_Cpp.vcFormat.space.betweenEmptyBraces": true,
"C_Cpp.clang_format_style": "Visual Studio",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "newLine",
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "right",
"C_Cpp.vcFormat.space.beforeEmptySquareBrackets": false,
"C_Cpp.vcFormat.space.beforeOpenSquareBracket": false,
"files.associations": {
"*.dox": "doxygen",
"bitset": "cpp",
"optional": "cpp",
"*.in": "cmake",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"hash_map": "cpp",
"hash_set": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"__bit_reference": "cpp",
"__bits": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"__verbose_abort": "cpp",
"ios": "cpp",
"locale": "cpp",
"queue": "cpp",
"stack": "cpp",
"__nullptr": "cpp",
"__string": "cpp",
"compare": "cpp",
"concepts": "cpp",
"*.ipp": "cpp",
"any": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"stop_token": "cpp",
"view": "cpp",
"mixinvector": "cpp",
"charconv": "cpp",
"coroutine": "cpp",
"resumable": "cpp",
"format": "cpp",
"ranges": "cpp",
"span": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
},
"C_Cpp.vcFormat.indent.namespaceContents": false,
"editor.formatOnSave": true,
"C_Cpp.vcFormat.indent.accessSpecifiers": false,
"C_Cpp.vcFormat.indent.preserveWithinParentheses": true,
"C_Cpp.vcFormat.indent.preprocessor": "leftmostColumn",
"C_Cpp.vcFormat.indent.multiLineRelativeTo": "innermostParenthesis",
"C_Cpp.vcFormat.indent.withinParentheses": "alignToParenthesis",
"editor.detectIndentation": false,
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"editor.defaultFormatter": "ms-vscode.cpptools",
"editor.formatOnSaveMode": "file",
"C_Cpp.formatting": "vcFormat",
"C_Cpp.vcFormat.space.aroundBinaryOperator": "ignore",
"editor.comments.insertSpace": true,
"C_Cpp.vcFormat.indent.preserveComments": true,
"C_Cpp.doxygen.generatedStyle": "/*!",
"files.insertFinalNewline": true,
"C_Cpp.doxygen.sectionTags": [
"attention",
"tparam",
"param",
"result",
"retval",
"exception",
"deprecated",
"warning",
"note"
],
"editor.rulers": [
{"column": 120, "color": "#ffcc00"}
],
}
51 changes: 31 additions & 20 deletions visp_auto_tracker/src/tracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace tracking
Tracker_::Tracker_(CmdLine &cmd, vpDetectorBase *detector, vpMbTracker *tracker, bool flush_display)
:

cmd(cmd), iter_(0), flashcode_center_(640 / 2, 480 / 2), detector_(detector), tracker_(tracker),
flush_display_(flush_display)
cmd(cmd), iter_(0), flashcode_center_(640 / 2, 480 / 2), detector_(detector), tracker_(tracker),
flush_display_(flush_display)
{
RCLCPP_INFO_STREAM(rclcpp::get_logger("rclcpp"), "starting tracker");
cvTrackingBox_init_ = false;
Expand Down Expand Up @@ -121,7 +121,8 @@ bool Tracker_::flashcode_detected(input_ready const &evt)
if (cmd.get_code_message().empty()) {
cmd.set_code_message_index(0); // we retain the largest code at index 0
return true;
} else {
}
else {
for (size_t i = 0; i < detector_->getNbObjects(); i++) {
if (detector_->getMessage(i) == cmd.get_code_message()) {
cmd.set_code_message_index(i);
Expand Down Expand Up @@ -152,7 +153,8 @@ bool Tracker_::flashcode_redetected(input_ready const &evt)
if (cmd.get_code_message().empty()) {
cmd.set_code_message_index(0); // we retain the largest code at index 0
return true;
} else {
}
else {
for (size_t i = 0; i < detector_->getNbObjects(); i++) {
if (detector_->getMessage(i) == cmd.get_code_message()) {
cmd.set_code_message_index(i);
Expand Down Expand Up @@ -217,7 +219,8 @@ bool Tracker_::model_detected(msm::front::none const &)
cMo_ = cMo_lag;
pose.computePose(vpPose::VIRTUAL_VS, cMo_);
// vpDisplay::displayFrame(*I_,cMo_,cam_,0.01,vpColor::none,2);
} catch (vpException &e) {
}
catch (vpException &e) {
RCLCPP_INFO_STREAM(rclcpp::get_logger("rclcpp"), "Pose computation failed: " << e.getStringMessage());
return false;
}
Expand Down Expand Up @@ -262,7 +265,8 @@ bool Tracker_::model_detected(msm::front::none const &)
tracker_->track(Igray_); // track the object on this image
tracker_->getPose(cMo_); // get the pose
}
} catch (vpException &e) {
}
catch (vpException &e) {
RCLCPP_INFO_STREAM(rclcpp::get_logger("rclcpp"), "Tracking failed");
RCLCPP_INFO_STREAM(rclcpp::get_logger("rclcpp"), e.getStringMessage());
return false;
Expand Down Expand Up @@ -334,7 +338,7 @@ bool Tracker_::mbt_success(input_ready const &evt)

boost::accumulators::accumulator_set<unsigned char, boost::accumulators::stats<boost::accumulators::tag::median(
boost::accumulators::with_p_square_quantile)> >
acc;
acc;

int region_width = std::max((int)(std::abs(_u - _u_inner) * cmd.get_adhoc_recovery_size()), 1);
int region_height = std::max((int)(std::abs(_v - _v_inner) * cmd.get_adhoc_recovery_size()), 1);
Expand All @@ -353,7 +357,8 @@ bool Tracker_::mbt_success(input_ready const &evt)
return false;
}
}
} catch (vpException &e) {
}
catch (vpException &e) {
RCLCPP_INFO_STREAM(rclcpp::get_logger("rclcpp"), "Tracking lost");
return false;
}
Expand Down Expand Up @@ -399,7 +404,8 @@ void Tracker_::track_model(input_ready const &evt)
tracker_me->getMovingEdge(tracker_me_config_);
tracker_me_config_.setRange(range);
tracker_me->setMovingEdge(tracker_me_config_);
} else
}
else
RCLCPP_INFO_STREAM(rclcpp::get_logger("rclcpp"),
"error: could not init moving edges on tracker that doesn't support them.");
}
Expand Down Expand Up @@ -459,21 +465,26 @@ void Tracker_::updateMovingEdgeSites(visp_tracker::msg::MovingEdgeSites &sites)

for (; sitesIterator != line->meline->list.end(); ++sitesIterator)
#endif
{
visp_tracker::msg::MovingEdgeSite movingEdgeSite;
movingEdgeSite.x = sitesIterator->ifloat;
movingEdgeSite.y = sitesIterator->jfloat;
sites.moving_edge_sites.push_back(movingEdgeSite);
}
noVisibleLine = false;
{
visp_tracker::msg::MovingEdgeSite movingEdgeSite;
#if VISP_VERSION_INT >= VP_VERSION_INT(3, 6, 0) // ViSP >= 3.6.0
movingEdgeSite.x = sitesIterator->m_ifloat;
movingEdgeSite.y = sitesIterator->m_jfloat;
#else
movingEdgeSite.x = sitesIterator->ifloat;
movingEdgeSite.y = sitesIterator->jfloat;
#endif
sites.moving_edge_sites.push_back(movingEdgeSite);
}
noVisibleLine = false;
}
#if VISP_VERSION_INT >= VP_VERSION_INT(3, 0, 0) // ViSP >= 3.0.0
}
}
#endif
}
if (noVisibleLine)
RCLCPP_DEBUG_THROTTLE(rclcpp::get_logger("rclcpp"), clock, 10, "no distance lines");
#endif
}
if (noVisibleLine)
RCLCPP_DEBUG_THROTTLE(rclcpp::get_logger("rclcpp"), clock, 10, "no distance lines");
}

void Tracker_::updateKltPoints(visp_tracker::msg::KltPoints &klt)
Expand Down
Loading