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

Usage of C++ API in CMake Project #216

Open
RAJKgu opened this issue Dec 4, 2022 · 8 comments
Open

Usage of C++ API in CMake Project #216

RAJKgu opened this issue Dec 4, 2022 · 8 comments

Comments

@RAJKgu
Copy link

RAJKgu commented Dec 4, 2022

Hi,
I am trying to use C++ API in a ROS project, because it's a CMake project we can directly use it in the ROS project through find_package(toppra).

After building, I tried to use it in the ROS package but CMake Could not find a package configuration file provided by "toppra" with any of the following names:

    toppraConfig.cmake
    toppra-config.cmake

Now, for that I have to append the config files path into the CMAKE_PREFIX_PATH. But when I look for the directory of config files I am unable to find it. If we looked at the following portion of CMakeLists.txt present in the cpp folder

set(CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(VERSION_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(PROJECT_CONFIG "${GENERATED_DIR}/${PROJECT_NAME}Config.cmake")
write_basic_package_version_file(
    "${VERSION_CONFIG}" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion
)

configure_package_config_file(
    "cmake/Config.cmake.in"
    "${PROJECT_CONFIG}"
    INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
)

install(FILES "${PROJECT_CONFIG}" "${VERSION_CONFIG}"
    DESTINATION "${CONFIG_INSTALL_DIR}")
install(EXPORT toppra::toppra
  NAMESPACE toppra::
  FILE toppraTargets.cmake
  DESTINATION "${CONFIG_INSTALL_DIR}")

Config files directory is set to lib/cmake/toppra what I am deducing is that project cmake files are going to install under /lib/cmake right? or its in the build directory of the project because I only found the cmake-config files under the generated folder and cmake-Target file under Export directory but these should ideally be present in one directory toppra under the following path /lib/cmake. But I am not able to find any config files under this path, no files are installed there.

@jmirabel
Copy link
Collaborator

jmirabel commented Dec 4, 2022

May I know how you installed it ?

If you use ROS, you may also use catkin. This is how I use this package personally.

@RAJKgu
Copy link
Author

RAJKgu commented Dec 5, 2022

I follow the instruction mentioned here in the Readme.

Currently, I am using ROS2 humble(Ubuntu 22.04) so I have to use colcon to build the workspace. I haven't tried building C++ API in the ROS workspace but will try to do it. But I thought that if I keep toppra separated from the workspace that should be good.

Also while building(make), the tests subdirectory failed with the multiple following errors

error: call of overloaded ‘BoundaryCond(<brace-enclosed initializer list>)’ is ambiguous

I found this on stack overflow here. This may be due to the initialization of std::vector.

@hungpham2511
Copy link
Owner

Do you have a dockerfile that reproduces the issue? It would make it easier for us to try it out.

@botoph4
Copy link

botoph4 commented Dec 8, 2022

Did you try to sudo make install in your local usr/local/lib?

@RAJKgu
Copy link
Author

RAJKgu commented Dec 8, 2022

@hungpham2511 Sorry for not getting to you earlier, I didn't have a Dockerfile for reproducing the error but it doesn't take much time to create one I guess. Currently, I have ubuntu 22.04 on my system with ROS2 Humble distro. As building(CMake) is independent of ROS distro, the reason of test subdirectory failed with the multiple overload errors can be due to the version of the C++ Compiler used.

@FehlerNotFound I missed this part. Now toppra is installed at /usr/local/lib and available to include in CMake projects. Thank you. We need to add this step in Readme for Installation. So, that no one will face any issues.

@jmirabel
Copy link
Collaborator

jmirabel commented Dec 8, 2022

In sudo make install, sudo is generally a bad idea. What you should do instead is install it an custom install directory and make your environment variable points to it.
This reason is good enough for me not to suggest people to use sudo when installing.

@RAJKgu
Copy link
Author

RAJKgu commented Dec 10, 2022

@jmirabel I agree with you
@hungpham2511 and @jmirabel I have a question to ask, So I trying to develop a trajectory optimization model which can optimize a recorded set of waypoints. In the pipeline, I am thinking to use STOMP for the optimization of an initial recorded set of waypoints, but for now, I am trying parameterizing the recorded set of waypoints using toppra with velocity(3.14,-3.14) and acceleration(-1,1) bounds. So when I try to run toppra with the recorded points I am getting a parameterized path but viewing it in the plot shows that acceleration is going out of bounds. The parametrized used is "ParametrizeConstAccel". Here is the plot

Screenshot from 2022-12-10 14-20-35

So, What am trying to ask is, Is this because of nonuniform recorded waypoints? because for parameterizing we need a smooth geometric path right? This means we can't do parameterization of a raw sequence of waypoints while satisfying the constraints properly like the recorded ones. I am currently exploring new things So don't have much in-depth experience and knowledge of it. But I love to have some guidance that gives me some in-depth insight.

@zxfever
Copy link

zxfever commented Sep 29, 2024

I follow the instruction mentioned here in the Readme.

Currently, I am using ROS2 humble(Ubuntu 22.04) so I have to use colcon to build the workspace. I haven't tried building C++ API in the ROS workspace but will try to do it. But I thought that if I keep toppra separated from the workspace that should be good.

Also while building(make), the tests subdirectory failed with the multiple following errors

error: call of overloaded ‘BoundaryCond(<brace-enclosed initializer list>)’ is ambiguous

I found this on stack overflow here. This may be due to the initialization of std::vector.

hi, I have faced the same error:

error: call of overloaded ‘BoundaryCond(<brace-enclosed initializer list>)’ is ambiguous`

I don't know if you still remember how you solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants