complie error - ambiguous call - unrotate (Rot3 and Sphere2)

Issue #36 resolved
Vadim Indelman created an issue

Compiling on Mac, the following error occurs:

/Users/vindelman3/borg/gtsam/gtsam/geometry/Pose3.cpp:212: error: call of overloaded ‘unrotate(gtsam::Point3)’ is ambiguous /Users/vindelman3/borg/gtsam/gtsam/geometry/Rot3.h:324: note: candidates are: gtsam::Point3 gtsam::Rot3::unrotate(const gtsam::Point3&, boost::optional<gtsam::Matrix&>, boost::optional<gtsam::Matrix&>) const /Users/vindelman3/borg/gtsam/gtsam/geometry/Rot3.h:336: note: gtsam::Sphere2 gtsam::Rot3::unrotate(const gtsam::Sphere2&, boost::optional<gtsam::Matrix&>, boost::optional<gtsam::Matrix&>) const

Tried to change call in Pose3.cpp lin 212 to Point3 d = R_.unrotate((Point3)(T.translation() - t_)); but that does not help.

Comments (16)

  1. Frank Dellaert

    I will solve by moving rotate and unrotate back to Sphere2, and making them friends. In retrospect have never liked including Sphere2 in Rot3 - header bloat.

  2. Frank Dellaert

    As I'm looking at it, I realize I like having the * operator. It makes sense. Before I go any further, could you see whether removing the Sphere2(Point3) constructor resolves the issue? You can replace all constructor calls with the named constructor Sphere2 ::FromPoint3 to make it compile.

  3. Vadim Indelman reporter

    After doing that I was able to compile 68%, and then got some errors related to CombinedIMU factor:

    /Users/vindelman3/borg/gtsam/gtsam/navigation/CombinedImuFactor.h:346: error: using ‘typename’ outside of template In file included from /Users/vindelman3/borg/gtsam/build-release/wrap/gtsam/gtsam_wrapper.cpp:42: /Users/vindelman3/borg/gtsam/gtsam/navigation/ImuFactor.h:308: error: using ‘typename’ outside of template /opt/local/include/boost/mpl/print.hpp: In instantiation of ‘boost::mpl::print<boost::serialization::BOOST_SERIALIZATION_STATIC_WARNING_LINE<137> >’: /opt/local/include/boost/serialization/static_warning.hpp:92: instantiated from ‘boost::serialization::static_warning_test<false, 137>’ /opt/local/include/boost/serialization/export.hpp:137: instantiated from ‘const boost::archive::detail::extra_detail::guid_initializer<T>& boost::archive::detail::extra_detail::guid_initializer<T>::export_guid() const [with T = gtsam::VectorValues]’ /Users/vindelman3/borg/gtsam/build-release/wrap/gtsam/gtsam_wrapper.cpp:160: instantiated from here /opt/local/include/boost/mpl/print.hpp:55: warning: comparison between signed and unsigned integer expressions /opt/local/include/boost/mpl/print.hpp: In instantiation of ‘boost::mpl::print<boost::serialization::BOOST_SERIALIZATION_STATIC_WARNING_LINE<98> >’: /opt/local/include/boost/serialization/static_warning.hpp:92: instantiated from ‘boost::serialization::static_warning_test<false, 98>’ /opt/local/include/boost/archive/detail/check.hpp:98: instantiated from ‘void boost::archive::detail::check_object_tracking() [with T = gtsam::LieVector]’ /opt/local/include/boost/archive/detail/oserializer.hpp:313: instantiated from ‘static void boost::archive::detail::save_non_pointer_type<Archive>::invoke(Archive&, T&) [with T = gtsam::LieVector, Archive = boost::archive::text_oarchive]’ /opt/local/include/boost/archive/detail/oserializer.hpp:525: instantiated from ‘void boost::archive::save(Archive&, T&) [with Archive = boost::archive::text_oarchive, T = gtsam::LieVector]’ /opt/local/include/boost/archive/detail/common_oarchive.hpp:69: instantiated from ‘void boost::archive::detail::common_oarchive<Archive>::save_override(T&, int) [with T = gtsam::LieVector, Archive = boost::archive::text_oarchive]’ /opt/local/include/boost/archive/basic_text_oarchive.hpp:80: instantiated from ‘void boost::archive::basic_text_oarchive<Archive>::save_override(T&, int) [with T = gtsam::LieVector, Archive = boost::archive::text_oarchive]’ /opt/local/include/boost/archive/detail/interface_oarchive.hpp:63: instantiated from ‘Archive& boost::archive::detail::interface_oarchive<Archive>::operator<<(T&) [with T = gtsam::LieVector, Archive = boost::archive::text_oarchive]’ /Users/vindelman3/borg/gtsam/build-release/wrap/gtsam/gtsam_wrapper.cpp:1945: instantiated from here /op

  4. Frank Dellaert

    Seems due to

    #ifndef _MSC_VER
        typedef typename boost::shared_ptr<CombinedImuFactor> shared_ptr;
    #else
          typedef boost::shared_ptr<CombinedImuFactor> shared_ptr;
    #endif
    

    Can you just remove typename? @lucacarlone , @richardroberts what's up with above snippet? typename in non-template?

    Still bizarre you have all those errors we don't...

  5. Richard Roberts

    I think this particular thing was added by the sri guys, looks like trying to resolve the problem we're having. Vadim, you can try removing the typename and check that in. We'll see if that causes compile errors on anyone else's machine. Thanks.

  6. Richard Roberts

    it does look strange tho, I don't understand why typename would be needed here on any compiler.

  7. Vadim Indelman reporter

    OK, removing typename resolves this; checked in. @fdellaert - after changing Sphere2(Point3) to Sphere2::FromPoint3 in appropriate places it compiles on my system.

  8. Richard Roberts

    Hi Frank and Vadim, FYI, another option for resolving this type of error if you prefer is making the constructor 'explicit' - e.g.

    explicit Sphere2(const Point3& point);
    

    This makes it so that implicit conversion is not possible, e.g.

    void myFunction(const Sphere2& sphere);
    
    Point3 point;
    myFunction(point); // This will not compile
    myFunction(Sphere2(point)); // This is ok
    
  9. Frank Dellaert

    @richardroberts that's great !!! OK, @indelman, can you see whether that also resolves it and then check that in? You could just create a local branch with your current changes and then delete the branch if it works, as this is a much cleaner solution.

  10. Vadim Indelman reporter

    OK, it works on my local brunch. Not sure - should I commit changes from this brunch or do something else?

  11. Frank Dellaert

    brunch = breakfast + lunch :-) I would say, push your branch (which should be called feature/something) to BB and then do a pull request.

  12. Log in to comment