CGAL filtered kernel without lazy evaluation - geometry
I've been studying CGAL and I am having trouble trying to define a kernel that satisfies what I need.
I need a kernel that is thread safe but, at the same time, I want to store exact coordinates.
If I understood CGAL documentation correctly:
The exact_predicates_inexact_constructions_kernel is thread safe, but it stores coordinates as double values.
The exact_predicates_exact_constructions_kernel stores the exact coordinates, but is not thread safe (because of the lazy number type).
CGAL::Simple_cartesian is thread-safe and stores the coordinates exactly. However, it is much slower for my application.
I basically concluded that I need something like:
CGAL::Filtered_kernel<CGAL::Simple_cartesian<mpq_class>>
(a kernel that uses filtered interval arithmetic for performance, stores the exact coordinates (that will be used when the filter fails) and does not use a lazy number type).
I think this kernel would be slower than exact_predicates_exact_constructions_kernel, but it would be thread-safe and much faster than a non-filtered kernel. (furthermore, I think lazy number types would not be so useful for my application because I want to output the exact coordinates anyway and, thus, they will have to be computed at some point -- that is, the only "optimization" I need is fast filtered predicates)
The problem is: I tried to compile a test application with this kernel and the compilation always fails. Is there a reason why I cannot create a filtered kernel that keeps not only the floating-point intervals but also the exact coordinates?
PS: I am using CGAL 4.10 on Linux
Thanks!
Update:
Minimum example that fails:
#include <CGAL/gmpxx.h> //needed to use mpq_class as the field type
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Filtered_kernel.h>
#include <CGAL/Lazy_kernel.h>
//typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; //works...
//typedef CGAL::Filtered_kernel<CGAL::Simple_cartesian<double>> Kernel; //works...
//typedef CGAL::Simple_cartesian<mpq_class> Kernel; //works!
//typedef CGAL::Filtered_kernel<CGAL::Simple_cartesian<CGAL::Gmpq>> Kernel; //works! (but Gmpq is not thread safe, while mpq_class is)
typedef CGAL::Filtered_kernel<CGAL::Simple_cartesian<mpq_class>> Kernel;
typedef Kernel::Point_3 Point_3;
int main() {
Point_3 a(0,0,0);
Point_3 b(1,0,0);
Point_3 c(0,1,0);
Point_3 d(1,1,1);
//The code compiles if I remove the line below
CGAL::Orientation orientationP0Triangle = CGAL::orientation(a,b,c,d);
}
Error message:
In file included from /usr/local/include/CGAL/Cartesian_converter.h:35:0,
from /usr/local/include/CGAL/Filtered_kernel.h:27,
from /usr/local/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:29,
from cgalSimpleExample.cpp:2:
/usr/local/include/CGAL/NT_converter.h: In instantiation of ‘NT2 CGAL::NT_converter<NT1, NT2>::operator()(const NT1&) const [with NT1 = __gmp_expr<__mpq_struct [1], __mpq_struct [1]>; NT2 = CGAL::Gmpq]’:
/usr/local/include/CGAL/Cartesian_converter.h:293:45: required from ‘typename K2::Point_3 CGAL::Cartesian_converter<K1, K2, Converter>::operator()(const typename K1::Point_3&) const [with K1 = CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >; K2 = CGAL::Simple_cartesian<CGAL::Gmpq>; Converter = CGAL::NT_converter<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Gmpq>; typename K2::Point_3 = CGAL::Point_3<CGAL::Simple_cartesian<CGAL::Gmpq> >; typename K1::Point_3 = CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >]’
/usr/local/include/CGAL/Filtered_predicate.h:175:27: required from ‘CGAL::Filtered_predicate<EP, AP, C2E, C2A, Protection>::result_type CGAL::Filtered_predicate<EP, AP, C2E, C2A, Protection>::operator()(const Args& ...) const [with Args = {CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> >, true> >, CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> >, true> >, CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> >, true> >, CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> >, true> >}; EP = CGAL::CartesianKernelFunctors::Orientation_3<CGAL::Simple_cartesian<CGAL::Gmpq> >; AP = CGAL::CartesianKernelFunctors::Orientation_3<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >; C2E = CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >, CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::NT_converter<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Gmpq> >; C2A = CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Interval_nt<false> > >; bool Protection = true; CGAL::Filtered_predicate<EP, AP, C2E, C2A, Protection>::result_type = CGAL::Sign]’
/usr/local/include/CGAL/internal/Static_filters/Orientation_3.h:170:41: required from ‘CGAL::internal::Static_filters_predicates::Orientation_3<K_base>::result_type CGAL::internal::Static_filters_predicates::Orientation_3<K_base>::operator()(const Point_3&, const Point_3&, const Point_3&, const Point_3&) const [with K_base = CGAL::Filtered_kernel_base<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<__gmp_expr<__mpq_struct [1], __mpq_struct [1]>, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >, CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > > >; CGAL::internal::Static_filters_predicates::Orientation_3<K_base>::result_type = CGAL::Sign; CGAL::internal::Static_filters_predicates::Orientation_3<K_base>::Point_3 = CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >]’
/usr/local/include/CGAL/Kernel/global_functions_internal_3.h:860:45: required from ‘typename K::Orientation CGAL::internal::orientation(const typename K::Point_3&, const typename K::Point_3&, const typename K::Point_3&, const typename K::Point_3&, const K&) [with K = CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > >; typename K::Orientation = CGAL::Sign; typename K::Point_3 = CGAL::Point_3<CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > > >]’
/usr/local/include/CGAL/Kernel/global_functions_3.h:1047:47: required from ‘typename K::Orientation CGAL::orientation(const CGAL::Point_3<R>&, const CGAL::Point_3<R>&, const CGAL::Point_3<R>&, const CGAL::Point_3<R>&) [with K = CGAL::Filtered_kernel<CGAL::Simple_cartesian<__gmp_expr<__mpq_struct [1], __mpq_struct [1]> > >; typename K::Orientation = CGAL::Sign]’
cgalSimpleExample.cpp:19:69: required from here
/usr/local/include/CGAL/NT_converter.h:41:21: error: no matching function for call to ‘CGAL::Gmpq::Gmpq(const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>&)’
return NT2(a);
^
/usr/local/include/CGAL/NT_converter.h:41:21: note: candidates are:
In file included from /usr/local/include/CGAL/Gmp_coercion_traits.h:33:0,
from /usr/local/include/CGAL/Gmpz.h:33,
from /usr/local/include/CGAL/internal/Exact_type_selector.h:36,
from /usr/local/include/CGAL/Filtered_kernel.h:35,
from /usr/local/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:29,
from cgalSimpleExample.cpp:2:
/usr/local/include/CGAL/GMP/Gmpq_type.h:193:3: note: CGAL::Gmpq::Gmpq(const string&, int)
Gmpq(const std::string& str, int base = 10)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:193:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘const string& {aka const std::basic_string<char>&}’
/usr/local/include/CGAL/GMP/Gmpq_type.h:174:3: note: CGAL::Gmpq::Gmpq(const CGAL::Gmpfr&)
Gmpq(const Gmpfr &f)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:174:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘const CGAL::Gmpfr&’
/usr/local/include/CGAL/GMP/Gmpq_type.h:168:3: note: CGAL::Gmpq::Gmpq(double)
Gmpq(double d)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:168:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘double’
/usr/local/include/CGAL/GMP/Gmpq_type.h:161:3: note: CGAL::Gmpq::Gmpq(const CGAL::Gmpz&, const CGAL::Gmpz&)
Gmpq(const Gmpz& n, const Gmpz& d)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:161:3: note: candidate expects 2 arguments, 1 provided
/usr/local/include/CGAL/GMP/Gmpq_type.h:155:3: note: CGAL::Gmpq::Gmpq(long unsigned int, long unsigned int)
Gmpq(unsigned long n, unsigned long d)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:155:3: note: candidate expects 2 arguments, 1 provided
/usr/local/include/CGAL/GMP/Gmpq_type.h:149:3: note: CGAL::Gmpq::Gmpq(long int, long unsigned int)
Gmpq(signed long n, unsigned long d)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:149:3: note: candidate expects 2 arguments, 1 provided
/usr/local/include/CGAL/GMP/Gmpq_type.h:139:3: note: CGAL::Gmpq::Gmpq(int, int)
Gmpq(int n, int d)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:139:3: note: candidate expects 2 arguments, 1 provided
/usr/local/include/CGAL/GMP/Gmpq_type.h:136:3: note: CGAL::Gmpq::Gmpq(const CGAL::Gmpz&)
Gmpq(const Gmpz& n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:136:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘const CGAL::Gmpz&’
/usr/local/include/CGAL/GMP/Gmpq_type.h:124:3: note: CGAL::Gmpq::Gmpq(long long int)
Gmpq(long long n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:124:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘long long int’
/usr/local/include/CGAL/GMP/Gmpq_type.h:116:3: note: CGAL::Gmpq::Gmpq(long long unsigned int)
Gmpq(unsigned long long n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:116:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘long long unsigned int’
/usr/local/include/CGAL/GMP/Gmpq_type.h:104:3: note: CGAL::Gmpq::Gmpq(long unsigned int)
Gmpq(unsigned long n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:104:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘long unsigned int’
/usr/local/include/CGAL/GMP/Gmpq_type.h:101:3: note: CGAL::Gmpq::Gmpq(long int)
Gmpq(long n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:101:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘long int’
/usr/local/include/CGAL/GMP/Gmpq_type.h:98:3: note: CGAL::Gmpq::Gmpq(unsigned int)
Gmpq(unsigned int n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:98:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘unsigned int’
/usr/local/include/CGAL/GMP/Gmpq_type.h:95:3: note: CGAL::Gmpq::Gmpq(int)
Gmpq(int n)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:95:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘int’
/usr/local/include/CGAL/GMP/Gmpq_type.h:92:3: note: CGAL::Gmpq::Gmpq(const __mpq_struct*)
Gmpq(const mpq_t q)
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:92:3: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘const __mpq_struct*’
/usr/local/include/CGAL/GMP/Gmpq_type.h:90:3: note: CGAL::Gmpq::Gmpq()
Gmpq() {}
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:90:3: note: candidate expects 0 arguments, 1 provided
/usr/local/include/CGAL/GMP/Gmpq_type.h:69:7: note: CGAL::Gmpq::Gmpq(const CGAL::Gmpq&)
class Gmpq
^
/usr/local/include/CGAL/GMP/Gmpq_type.h:69:7: note: no known conversion for argument 1 from ‘const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>’ to ‘const CGAL::Gmpq&’
I think I found a solution: I should've compiled my program with the flag CGAL_USE_GMPXX
Related
Invoke the element in `Rcpp::List` for futher use directly
In an application, I use List to contain some variables (double, arma::mat and other types), and then take the arma::mat component in this list for futher use directly, such as matrix addition. However, some error is thrown. Below is a toy example to throw the same error as I met: // [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadillo.h> using namespace Rcpp; arma::mat f(){ arma::mat x = arma::randn(3, 4) ; List y = List::create( ::Named("a") = arma::randn(3, 4) ) ; return x - y["a"] ; } The error information is ambiguous overload for 'operator-' (operand types are 'arma::mat' {aka 'arma::Mat<double>'} and 'Rcpp::Vector<19>::NameProxy' {aka 'Rcpp::internal::generic_name_proxy<19, Rcpp::PreserveStorage>'}) Is there any way to use the y["a"] directly in numerical computation?
You need cast back from the SEXP type you create when adding to an (R or Rcpp, it's the same) List. Correcting that and adding a missing exports tag gives us what is below where I also added the sample invocation (another nice feature). Code // [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadillo.h> using namespace Rcpp; // [[Rcpp::export]] arma::mat f(){ arma::mat x = arma::randn(3, 4) ; List y = List::create( ::Named("a") = arma::randn(3, 4) ) ; return x - Rcpp::as<arma::mat>(y["a"]); } /*** R set.seed(42) # reproducible RNG draws f() */ Output > Rcpp::sourceCpp("~/git/stackoverflow/71612260/answer.cpp") > set.seed(42) # reproducible RNG draws > f() [,1] [,2] [,3] [,4] [1,] -0.471335 -2.337283 1.205825 0.537811 [2,] 0.119150 1.251941 0.486474 -0.513627 [3,] 3.309860 -0.654003 -0.146678 -0.835439 >
Warnings when installing R package with Rcpp
I am tring to build an R package with Rcpp using Rstudio. When I click "install and restart", Rstudio outputs hundreds of warning information and I cannot easily find the error information. I tried to find out reason to avoid the warning information but failed. It seems the warnings are from Rcpp package. BTW, the package can still work. The below is the additional options for R CMD INSTALL --no-multiarch --with-keep.source The information can be replicated using the below commands library(devtools) # author version: 2.3.0, use install.packages("devtools") first install_github("GeneticAnalysisinBiobanks/GRAB", INSTALL_opts=c("--no-multiarch")) # The INSTALL_opts is required in Windows OS. My working environment: > sessionInfo() R version 4.1.0 (2021-05-18) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042) Matrix products: default locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936 [3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.936 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] devtools_2.4.2 usethis_2.0.1 loaded via a namespace (and not attached): [1] rstudioapi_0.13 magrittr_2.0.1 pkgload_1.2.1 R6_2.5.0 [5] rlang_0.4.11 fastmap_1.1.0 tools_4.1.0 pkgbuild_1.2.0 [9] sessioninfo_1.1.1 cli_3.0.0 withr_2.4.2 ellipsis_0.3.2 [13] remotes_2.4.0 rprojroot_2.0.2 lifecycle_1.0.0 crayon_1.4.1 [17] processx_3.5.2 purrr_0.3.4 callr_3.7.0 fs_1.5.0 [21] ps_1.6.0 curl_4.3.1 testthat_3.0.4 memoise_2.0.0 [25] glue_1.4.2 cachem_1.0.5 compiler_4.1.0 desc_1.3.0 [29] prettyunits_1.1.1 The below include the warning information when I install and restart the package. In file included from C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/RcppCommon.h:118, from C:/Users/wenjianb/Documents/R/win-library/4.1/RcppArmadillo/include/RcppArmadilloForward.h:26, from C:/Users/wenjianb/Documents/R/win-library/4.1/RcppArmadillo/include/RcppArmadillo.h:31, from RcppExports.cpp:4: C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'const char* Rcpp::type2name(SEXP)': C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'const char* (*)(SEXPREC*)'} [-Wcast-function-type] #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ ) ^ C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:74:26: note: in expansion of macro 'GET_CALLABLE' static Fun fun = GET_CALLABLE("type2name"); ^~~~~~~~~~~~ C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::enterRNGScope()': C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'long unsigned int (*)()'} [-Wcast-function-type] #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ ) ^ C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:81:30: note: in expansion of macro 'GET_CALLABLE' static Fun fun = GET_CALLABLE("enterRNGScope"); ^~~~~~~~~~~~ C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::exitRNGScope()': C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'long unsigned int (*)()'} [-Wcast-function-type] #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ ) ^ C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:87:30: note: in expansion of macro 'GET_CALLABLE' static Fun fun = GET_CALLABLE("exitRNGScope"); ^~~~~~~~~~~~ C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h: In function 'long unsigned int Rcpp::internal::beginSuspendRNGSynchronization()': C:/Users/wenjianb/Documents/R/win-library/4.1/Rcpp/include/Rcpp/routines.h:70:73: warning: cast between incompatible function types from 'DL_FUNC' {aka 'void* (*)()'} to 'Fun' {aka 'long unsigned int (*)()'} [-Wcast-function-type] #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ ) ^ The other warnings are all similar to the above. Thank you all in advance. Wenjian
error: 'SetPosition' was not declared in this scope
Arduino: 1.6.9 (Windows 10), Board: "Arduino Mega ADK" In file included from C:\Users\Disheet\Downloads\humanoid_1\humanoid_1.ino:1:0: C:\Users\Disheet\Documents\Arduino\libraries\ax12v2/ax12.h:66:23: error: conflicting declaration 'typedef unsigned char boolean' typedef unsigned char boolean; ^ In file included from sketch\humanoid_1.ino.cpp:1:0: C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:117:14: error: 'boolean' has a previous declaration as 'typedef bool boolean' typedef bool boolean; ^ C:\Users\Disheet\Downloads\humanoid_1\humanoid_1.ino: In function 'void setup()': humanoid_1:5: error: 'SetPosition' was not declared in this scope SetPosition(1,0);////id,posiotin 0-1023 ^ C:\Users\Disheet\Downloads\humanoid_1\humanoid_1.ino: In function 'void loop()': humanoid_1:13: error: 'SetPosition' was not declared in this scope SetPosition(1,512); ^ Multiple libraries were found for "ax12.h" Used: C:\Users\Disheet\Documents\Arduino\libraries\ax12v2 Not used: C:\Users\Disheet\Documents\Arduino\libraries\Bioloid exit status 1 'SetPosition' was not declared in this scope This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
You'll need to find typedef unsigned char boolean; in your library and change it to match the version in Arduino.h. boolean is already a typedef in Arduino.h, and it is a bool ,not unsigned char. In the AX12 library search for this: https://github.com/7Robot/Arduino/blob/master/AX12/libraries/ax12/ax12.h#L66 And change it to typedef bool boolean;. This was updated a while ago, so your IDE version is newer than the AX12 library.
RH support for frontend::OutDigitalTunerPort appears missing most FEI functions
I have a component which uses frontend::OutDigitalTunerPort to make FEI calls to a RH device. Here is the generated code in XXX_base.cpp: device_fei_out = new frontend::OutDigitalTunerPort("device_fei_out"); addPort("device_fei_out", device_fei_out); Here is a sample usage which compiles properly: device_fei_out->setTunerOutputSampleRate(id, freq); Here is a sample usage which does NOT compile: device_fei_out->setTunerCenterFrequency(id); Apparently this FEI call is not defined in the appropriate template definitions - the compile bug points to /usr/local/redhawk/core/include/frontend/fe_tuner_port_impl.h. Looking at this code - I can see that only the working FEI call above is defined in the following classes: OutDigitalTunerPortT digital_tuner_delegation Where ALL other "set" FEI functions are defined in: OutAnalogTunerPortT analog_tuner_delegation So does this mean that frontend::OutDigitalTunerPort only supports this one "set" function ? How else can I make all the FEI calls to RH device ? Below is one of the compile error details - there is similar for 'operator !=' : /usr/local/redhawk/core/include/frontend/fe_tuner_port_impl.h:329: error: no match for ‘operator=’ in ‘i = ((frontend::OutAnalogTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>*)this)->frontend::OutAnalogTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::.frontend::OutFrontendTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::.frontend::OutFrontendPort<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::outConnections.std::vector<_Tp, _Alloc>::begin with _Tp = std::pair<_CORBA_ObjRef_Var, std::basic_string, std::allocator > >, _Alloc = std::allocator, std::basic_string, std::allocator > > >’ double freq=0.5; std::string id1("usrp-to-wavemaster"); device_fei_out->setTunerCenterFrequency(id1, freq); /usr/local/redhawk/core/include/frontend/fe_tuner_port_impl.h: In member function ‘void frontend::OutAnalogTunerPortT::setTunerCenterFrequency(std::string&, double) [with PortType_var = _CORBA_ObjRef_Var, PortType = FRONTEND::DigitalTuner]’: WaveformMaster.cpp:124: instantiated from here /usr/local/redhawk/core/include/frontend/fe_tuner_port_impl.h:329: error: no match for ‘operator=’ in ‘i = ((frontend::OutAnalogTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>)this)->frontend::OutAnalogTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::.frontend::OutFrontendTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::.frontend::OutFrontendPort<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::outConnections.std::vector<_Tp, _Alloc>::begin with _Tp = std::pair<_CORBA_ObjRef_Var, std::basic_string, std::allocator > >, _Alloc = std::allocator, std::basic_string, std::allocator > > >’ /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h:669: note: candidates are: __gnu_cxx::__normal_iterator, std::basic_string, std::allocator > >, std::vector, std::basic_string, std::allocator > >, std::allocator, std::basic_string, std::allocator > > > > >& __gnu_cxx::__normal_iterator, std::basic_string, std::allocator > >, std::vector, std::basic_string, std::allocator > >, std::allocator, std::basic_string, std::allocator > > > > >::operator=(const __gnu_cxx::__normal_iterator, std::basic_string, std::allocator > >, std::vector, std::basic_string, std::allocator > >, std::allocator, std::basic_string, std::allocator > > > > >&) WaveformMaster.cpp:124: instantiated from here /usr/local/redhawk/core/include/frontend/fe_tuner_port_impl.h:329: error: no match for ‘operator!=’ in ‘i != ((frontend::OutAnalogTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>*)this)->frontend::OutAnalogTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::.frontend::OutFrontendTunerPortT<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::.frontend::OutFrontendPort<_CORBA_ObjRef_Var, FRONTEND::DigitalTuner>::outConnections.std::vector<_Tp, _Alloc>::end with _Tp = std::pair<_CORBA_ObjRef_Var, std::basic_string, std::allocator > >, _Alloc = std::allocator, std::basic_string, std::allocator > > >’ /usr/include/omniORB4/fixed.h:57: note: candidates are: CORBA::Boolean operator!=(const CORBA::Fixed&, const CORBA::Fixed&) /usr/local/redhawk/core/include/bulkio/bulkio_out_port.h:718: note: bool operator!=(const bulkio::connection_descriptor_struct&, const bulkio::connection_descriptor_struct&) /usr/local/redhawk/core/include/frontend/fe_tuner_struct_props.h:116: note: bool operator!=(const frontend::frontend_tuner_allocation_struct&, const frontend::frontend_tuner_allocation_struct&) /usr/local/redhawk/core/include/frontend/fe_tuner_struct_props.h:173: note: bool operator!=(const frontend::frontend_listener_allocation_struct&, const frontend::frontend_listener_allocation_struct&) /usr/local/redhawk/core/include/frontend/fe_tuner_struct_props.h:272: note: bool operator!=(const frontend::default_frontend_tuner_status_struct_struct&, const frontend::default_frontend_tuner_status_struct_struct&) /usr/local/redhawk/core/include/frontend/fe_tuner_struct_props.h:308: note: bool operator!=(const std::vector >&, const std::vector >&) /usr/local/redhawk/core/include/frontend/fe_tuner_port_impl.h: In member function ‘void frontend::OutAnalogTunerPortT::setTunerBandwidth(std::string&, double) [with PortType_var = _CORBA_ObjRef_Var, PortType = FRONTEND::DigitalTuner]’:
The setTunerCenterFrequency(..) function takes in two arguments (std::string& id, double freq), you are calling with just id, this might be the cause of your compile problem. If this is not the cause of your problem, please provide more details of your source code and all error output along with the REDHAWK version that you are using. OutDigitalTunerPort supports all the OutAnalogTunerPortT functions. OutDigitalTunerPort inherits from OutDigitalTunerPortT which inherits from OutAnalogTunerPortT (so yes, it has all the functions of OutAnalogTunerPort plus the addition of the getTunerOutputSampleRate and setTunerOutputSampleRate functions).
How do you post a boost packaged_task to an io_service in C++03?
This is a follow-on from a previous question (here), but I'm working on a multithreaded application and I would like to post a Boost packaged_task to a threaded io_service. I'm stuck using a C++03 compiler (so std::move is out), and the packaged_task is not copyable. I've tried wrapping it in a shared_ptr and passing that, and a lot of other things. Here is my current attempt and the subsequent compiler errors. Any idea how to get this to work? boost::asio::io_service io_service; boost::thread_group threads; boost::asio::io_service::work work(io_service); for (int i = 0; i < maxNumThreads; ++i) { threads.create_thread(boost::bind(&boost::asio::io_service::run, &io_service)); } std::vector<boost::shared_future<bool> > pending_data; // vector of futures bool process_data(int,int){...} ... for(int theTime = 0; theTime != totalScenarioTime; ++theTime) { for(int i = 0; i < numSmallTasks; ++i) { boost::packaged_task<bool> task(boost::bind(&process_data,i,theTime)); boost::shared_future<bool> fut(task.get_future()); pending_data.push_back(fut); // C++11 possible: (std::move(fut) when fut is a unique_future); io_service.post(task); // C++11 possible: (std::move(task)); } // After loop - wait until all futures are evaluated boost::wait_for_all(pending_data.begin(), pending_data.end()); pending_data.clear(); } This results in: In file included from ../boostlibs/boost/asio/io_service.hpp:767:0, from ../boostlibs/boost/asio/basic_io_object.hpp:19, from ../boostlibs/boost/asio/basic_socket.hpp:19, from ../boostlibs/boost/asio/basic_datagram_socket.hpp:20, from ../boostlibs/boost/asio.hpp:20, from ../main.cpp:13: ../boostlibs/boost/asio/impl/io_service.hpp: In member function ‘void boost::asio::io_service::post(const CompletionHandler&) [with CompletionHandler = boost::packaged_task<bool>]’: ../main.cpp:256:23: instantiated from here ../boostlibs/boost/asio/impl/io_service.hpp:95:67: error: no matching function for call to ‘boost::packaged_task<bool>::packaged_task(const boost::packaged_task<bool>&)’ ../boostlibs/boost/asio/impl/io_service.hpp:95:67: note: candidates are: ../boostlibs/boost/thread/future.hpp:1372:9: note: boost::packaged_task<R>::packaged_task(boost::detail::thread_move_t<boost::packaged_task<R> >) [with R = bool] ../boostlibs/boost/thread/future.hpp:1372:9: note: no known conversion for argument 1 from ‘const boost::packaged_task<bool>’ to ‘boost::detail::thread_move_t<boost::packaged_task<bool> >’ ../boostlibs/boost/thread/future.hpp:1318:9: note: boost::packaged_task<R>::packaged_task() [with R = bool] ../boostlibs/boost/thread/future.hpp:1318:9: note: candidate expects 0 arguments, 1 provided ../boostlibs/boost/thread/future.hpp:1314:9: note: boost::packaged_task<R>::packaged_task(boost::packaged_task<R>&) [with R = bool, boost::packaged_task<R> = boost::packaged_task<bool>] ../boostlibs/boost/thread/future.hpp:1314:9: note: no known conversion for argument 1 from ‘const boost::packaged_task<bool>’ to ‘boost::packaged_task<bool>&’ ../boostlibs/boost/asio/detail/handler_type_requirements.hpp:95:26: error: initializing argument 1 of ‘T& boost::asio::detail::lvref(T) [with T = boost::packaged_task<bool>]’ ../boostlibs/boost/asio/impl/io_service.hpp:95:67: error: no matching function for call to ‘boost::packaged_task<bool>::packaged_task(const boost::packaged_task<bool>&)’ ../boostlibs/boost/asio/impl/io_service.hpp:95:67: note: candidates are: ../boostlibs/boost/thread/future.hpp:1372:9: note: boost::packaged_task<R>::packaged_task(boost::detail::thread_move_t<boost::packaged_task<R> >) [with R = bool] ../boostlibs/boost/thread/future.hpp:1372:9: note: no known conversion for argument 1 from ‘const boost::packaged_task<bool>’ to ‘boost::detail::thread_move_t<boost::packaged_task<bool> >’ ../boostlibs/boost/thread/future.hpp:1318:9: note: boost::packaged_task<R>::packaged_task() [with R = bool] ../boostlibs/boost/thread/future.hpp:1318:9: note: candidate expects 0 arguments, 1 provided ../boostlibs/boost/thread/future.hpp:1314:9: note: boost::packaged_task<R>::packaged_task(boost::packaged_task<R>&) [with R = bool, boost::packaged_task<R> = boost::packaged_task<bool>] ../boostlibs/boost/thread/future.hpp:1314:9: note: no known conversion for argument 1 from ‘const boost::packaged_task<bool>’ to ‘boost::packaged_task<bool>&’ ../boostlibs/boost/asio/detail/handler_type_requirements.hpp:96:32: error: initializing argument 1 of ‘const T& boost::asio::detail::clvref(T) [with T = boost::packaged_task<bool>]’ ../boostlibs/boost/asio/impl/io_service.hpp:97:3: error: no matching function for call to ‘boost::packaged_task<bool>::packaged_task(const boost::packaged_task<bool>&)’ ../boostlibs/boost/asio/impl/io_service.hpp:97:3: note: candidates are: ../boostlibs/boost/thread/future.hpp:1372:9: note: boost::packaged_task<R>::packaged_task(boost::detail::thread_move_t<boost::packaged_task<R> >) [with R = bool] ../boostlibs/boost/thread/future.hpp:1372:9: note: no known conversion for argument 1 from ‘const boost::packaged_task<bool>’ to ‘boost::detail::thread_move_t<boost::packaged_task<bool> >’ ../boostlibs/boost/thread/future.hpp:1318:9: note: boost::packaged_task<R>::packaged_task() [with R = bool] ../boostlibs/boost/thread/future.hpp:1318:9: note: candidate expects 0 arguments, 1 provided ../boostlibs/boost/thread/future.hpp:1314:9: note: boost::packaged_task<R>::packaged_task(boost::packaged_task<R>&) [with R = bool, boost::packaged_task<R> = boost::packaged_task<bool>] ../boostlibs/boost/thread/future.hpp:1314:9: note: no known conversion for argument 1 from ‘const boost::packaged_task<bool>’ to ‘boost::packaged_task<bool>&’ ../boostlibs/boost/asio/detail/impl/task_io_service.hpp:54:6: error: initializing argument 1 of ‘void boost::asio::detail::task_io_service::post(Handler) [with Handler = boost::packaged_task<bool>]’ Using boost::move(task) results in the two errors: error: no match for call to ‘(boost::detail::thread_move_t<boost::packaged_task<bool> >) ()’ error: no match for call to ‘(boost::detail::thread_move_t<boost::packaged_task<bool> >) ()’
boost::packaged_task supports boost::move since Boost version 1.50, see corresponding ticket. But the problem is that io_service::post completion handler parameter must be CopyConstructible as noted in Asio handler requirements. Therefore boost::packaged_task cannot be posted directly or by moving. (Thanks to Igor R. for this issue). There is workaround using pointers, e.g. you could wrap boost::packaged_task with boost::shared_ptr and bind it to operator(): typedef boost::packaged_task<bool> task_t; boost::shared_ptr<task_t> task = boost::make_shared<task_t>( boost::bind(&process_data, i, theTime)); io_service.post(boost::bind(&task_t::operator(), task));