Git Product home page Git Product logo

arc_utilities's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arc_utilities's Issues

Typedef / Partial Specialization Problems with Eigen

So I ran into an irritating problem using arc_utilities/eigen_helpers.hpp in conjunction with sdf_tools/sdf_builder.hpp

One of the files included by sdf_tools/sdf_builder.hpp includes <Eigen/StdVector>. Depending on the include order, this causes problems.

The following code does not compile.

#include <arc_utilities/eigen_helpers.hpp>
#include <Eigen/StdVector>

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;
    return 0;
}

If I switch the include order so that <Eigen/StdVector> is the first include, everything compiles with no problem.

So I've currently tweaked my include order to put sdf_tools/sdf_builder.hpp' before the files that includearc_utilities/eigen_helpers.hpp` (I don't include it directly) as a work around, however this is not ideal.

The internet tells me this is probably a known issue already, but we may want to address it directly in arc_utlities anyway, as the last comment in the linked Eigen bugzilla seems to indicate that while Eigen has addressed this in some fashion in the devel branch, who knows how long till that makes it out to us.

strands-project/v4r#39

That and the instructions for using Eigen types with STL containers does say to include <Eigen/StdVector>

http://eigen.tuxfamily.org/dox-devel/group__TopicStlContainers.html#vector_spec

Timing segfault on PROFILE_RECORD_DOUBLE

PROFILE_RECORD_DOUBLE("name", val) segfault if called before the timer has been started.
This is unintuitive, since often we dont even care about the timer value

simple_rrt_planner_vanilla.hpp should include simple_rrt_planner.hpp or be removed

@orthez
We don't want to duplicate code for the planner, since this means that bugs and changes will have to be made to two similar, but separate files. If a simpler interface to simple_rrt_planner.hpp is desired, then it should be built on top of the existing code - for example, a simpler interface that simply includes simple_rrt_planner.hpp and provides wrapper functions, rather than copying the planner directly.

Duplicated functions in arc_helpers.hpp and eigen_helpers.hpp

arc_helpers.hpp:

inline Eigen::MatrixXd BuildDistanceMatrix(const std::vector<Datatype, Allocator>& data, const std::function<double(const Datatype&, const Datatype&)>& distance_fn)

eigen_helpers.hpp

template<typename ScalarType, int VectorLength, int NumVectors>
inline Eigen::Matrix<double, NumVectors, NumVectors> CalculateSquaredDistanceMatrix(const Eigen::Matrix<ScalarType, VectorLength, NumVectors>& set)

Add "assert with stacktrace" macro

An "assert with stacktrace" macro could be useful for times when debugging with GDB just isn't practical.

Here is one such possibility (may need tweaking) adapted from https://stackoverflow.com/questions/37473/how-can-i-assert-without-using-abort

#include <execinfo.h>

void print_stack_trace(int fd)
{
    void *array[256];
    size_t size;

    size = backtrace (array, 256);
    backtrace_symbols_fd(array, size, fd);
}

#define ASSERT_STACKTRACE(expr)      do {                           \
 if (!(expr))                                                       \
 {                                                                  \
         fprintf(stderr,                                            \
                "file %s: line %d (%s): precondition `%s' failed.", \
                __FILE__,                                           \
                __LINE__,                                           \
                __PRETTY_FUNCTION__,                                \
                #expr);                                             \
         print_stack_trace(2);                                      \
         assert(expr);                                              \
 };               } while(0)

Does not compile under Clang 3.7

Switching to clang briefly generates the following error:

catkin_ws/src/arc_utilities/include/arc_utilities/arc_helpers.hpp:17:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^
1 error generated.

Presumably this is due to missing compile flags:
https://stackoverflow.com/questions/33400462/omp-h-file-not-found-when-compiling-using-clang
https://cmake.org/cmake/help/v3.0/module/FindOpenMP.html

We also likely do not want to set these flags across the whole library, instead leaving them to be set by each end user library. We ought to find a way to let these headers be used under clang with or without OpenMP.

Duplicate DistanceMatrix code in eigen_helpers.hpp and arc_helpers.hpp

eigen_helpers.hpp

template<typename ScalarType, int VectorLength, int NumVectors>              
inline Eigen::Matrix<double, NumVectors, NumVectors> CalculateSquaredDistanceMatrix(const Eigen::Matrix<ScalarType, VectorLength, NumVectors>& set)

arc_helpers.hpp:

template<typename Datatype, typename Allocator = std::allocator<Datatype>>   
inline Eigen::MatrixXd BuildDistanceMatrix(const std::vector<Datatype, Allocator>& data, const std::function<double(const Datatype&, const Datatype&)>& distance_fn)
template<typename FirstDatatype, typename SecondDatatype, typename FirstAllocator = std::allocator<FirstDatatype>, typename SecondAllocator = std::allocator<SecondDatatype>>
inline Eigen::MatrixXd BuildDistanceMatrix(const std::vector<FirstDatatype, FirstAllocator>& data1, const std::vector<SecondDatatype, SecondAllocator>& data2, const std::function<double(const                 FirstDatatype&, const SecondDatatype&)>& distance_fn)

We might want to consider cleaning this up at some point.

Create templated versions of EigenHelpersConversions helpers

For example, right now we would need 4 different functions for the following:

inline geometry_msgs::Pose EigenIsometry3fToGeometryPose(const Eigen::Isometry3f& transform);
inline geometry_msgs::Pose EigenIsometry3dToGeometryPose(const Eigen::Isometry3d& transform);
inline geometry_msgs::Pose EigenAffine3fToGeometryPose(const Eigen::Affine3f& transform);
inline geometry_msgs::Pose EigenAffine3dToGeometryPose(const Eigen::Affine3d& transform);

There are many such functions that would need to be duplicated. I think templates is by far the better way to go for this.

Write wrapper for serialize and write to file, as well as load from file and deserialize

The serialize wrapper would presumably take an object, a filename, and a function pointer to an object serialization function. It would serialize, compress, and then save. Something along these lines:

template<typename T, typename SerializationFn>
void WriteToFile(const std::string& filename, const T& obj, const SerializationFn& serializer)
{
    std::vector<uint8_t> buffer;
    serializer(obj, buffer);
    ...
}

serialization_ros.hpp is redundant

This functionality exists already in ros, we should probably remove this file and replace any usage of it with the ros versions. For example from SDF tools:

ros::serialization::IStream deser_stream(deser_buffer.get(), serialized_size);
sdf_tools::SDF new_message;
ros::serialization::deserialize(deser_stream, new_message);

Getting vs Setting

Why is the function named GetParams (and it does 'get' params from the server), but the logging says "Setting"?

inline T GetParam(ros::NodeHandle& nh, const std::string& param_name, const T& default_val)
{
T param_val;
if (nh.getParam(param_name, param_val))
{
ROS_INFO_STREAM("Setting " << param_name << " to " << param_val);

Does not build in CMake Release mode

When using -Werror=unused-variable and -DCMAKE_BUILD_TYPE=Release, assert statements do not count as a variable usage. Code snippets like the following will fail:

const size_t bytes_used = arc_utilities::SerializeEigen(vec, buffer);
const auto deserialized = arc_utilities::DeserializeEigen<EigenType>(buffer, 0);
assert(deserialized.second == bytes_used);

Change `GridIndexToLocation` and `LocationToGridIndex` return types

Functions GridIndexToLocation and LocationToGridIndex should change their return types to improve consistency.

GridIndexToLocation should change from std::vector<double> to Eigen::Vector4d

LocationToGridIndex should change from std::vector<int64_t> to GRID_INDEX

All uses in arc_utilities and sdf_tools should already check that these values are inside the grid boundaries already, so having these functions no longer perform bounds checking is not an issue.

Duplicate copies of GraphEdge stored within a graph

A graph node currently stores in_edges and out_edges.
This duplicates each edge.
More importantly, it is possible to make inconsistent graphs where edges have different weights (and other properties) depending if looking from the "in_edges" or "out_edges" perspective.

ZlibHelpers::CompressAndWriteToFile can fail silently

Entire contents of the function are here:

void CompressAndWriteToFile(const std::vector<uint8_t>& uncompressed, const std::string& path)
{
    const auto compressed = CompressBytes(uncompressed);
    std::ofstream output_file(path, std::ios::out | std::ios::binary);
    output_file.write(reinterpret_cast<const char*>(compressed.data()), (std::streamsize)compressed.size());
    output_file.close();
}

The return values on the open and write functions are not checked. We should do something here, probably throw an exception.

Clean up tests (gtest?)

Currently, tests exist in src and test. All tests should be moved to tests.

Additionally, we should consider migrating to the gtest framework for this package

List Dependencies

What are arc_utilities dependencies? How do you install it?
Running into a few issues when installing on a fresh docker image:

cannot find Eigen3.cmake

zlib.h: No such file or directory

Orthognal vector code may be redundant

eigen_helpers.hpp has the following functions:

template <typename DerivedV>
inline Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> GetArbitraryOrthogonalVector(
            const Eigen::MatrixBase<DerivedV>& vector);

template <typename DerivedV>
inline Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> GetArbitraryOrthogonalVectorToPlane(
            const Eigen::MatrixBase<DerivedV>& plane_vector1,
            const Eigen::MatrixBase<DerivedV>& plane_vector2,
            const Eigen::MatrixBase<DerivedV>& vector);

Eigen already has some functionality that may do this already, we should check that the functionality is not duplicated.

https://eigen.tuxfamily.org/dox/group__Geometry__Module.html#title53

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.