ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Install library in ros

asked 2016-07-11 14:51:52 -0500

justinkgoh gravatar image

updated 2016-07-13 08:05:43 -0500

I am wondering how I would incorporate a library in ROS. The library I am trying to install is called ulapi to communicate with the kuka robot we have in the lab.

Thanks

Update (7.13.16): Here is part of my code that I am trying to add the ulapi library. Might be useful.

#include <ros/ros.h>

//library for type of message sent to gazebo topics
#include <std_msgs/Float64.h>

//libraries to control model in gazebo
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/Twist.h>
#include <gazebo_msgs/ModelState.h>
#include <gazebo_msgs/SetModelState.h>

#include <cstdlib>
#include <robsim_gazebo/ulapi.h>

int main (int argc, char** argv)
{
    //initialize node
    ros::init(argc, argv, "publisher_node");

    //create node handle
    ros::NodeHandle rob_pose;

    ros::NodeHandle a1a2;
    ros::NodeHandle a2e1;
    ros::NodeHandle e1a3;
    ros::NodeHandle a3a4;
    ros::NodeHandle a4a5;
    ros::NodeHandle a5a6;
    ros::NodeHandle a6tp;

Here is the part of my CMakeLists.txt file

add_library(unix_ulapi src/unix_ulapi.c)
#target_link_libraries(publisher_node unix_ulapi)

add_library(ulapi_getopt src/ulapi_getopt.c)
#target_link_libraries(publisher_node ulapi_getopt)
edit retag flag offensive close merge delete

Comments

Are you just asking how to install the library (.so file) in some specific location, or do you want to integrate the library into a ROS node? The fist is a file copy action, the second requires you program a node (a C++ program fi) and call into the libraries functions.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-12 01:18:34 -0500 )edit

The files I have are C and H. I am use to installing libraries for Arduino and was wondering how to do it for ROS.

justinkgoh gravatar image justinkgoh  ( 2016-07-13 07:48:53 -0500 )edit

After adding the libraries you need to link them to the executable. Try to uncomment the target_link_libraries() lines or add the next line at the bottom of the CMakeList:

target_link_libraries(publisher_node ulapi_getotp unix_ulapi)

senreot gravatar image senreot  ( 2016-07-13 17:18:09 -0500 )edit

When I do that I get an error that says this:

CMake Error at robsim/robsim_gazebo/CMakeLists.txt:214 (target_link_libraries):
        Cannot specify link libraries for target "publisher_node" which is not
        built by this project.
justinkgoh gravatar image justinkgoh  ( 2016-07-14 08:53:51 -0500 )edit

off-topic, but what I find much more interesting: what are you doing with robsim, gazebo and ulapi? :)

gvdhoorn gravatar image gvdhoorn  ( 2016-07-14 09:09:43 -0500 )edit

This is because the executable has another name. Try replacing publisher_node with the name of the executable.

If you can show us the complete CMakeList we can help you better ;)

senreot gravatar image senreot  ( 2016-07-14 09:37:47 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-07-12 06:30:33 -0500

cagatay gravatar image

updated 2016-07-12 06:41:56 -0500

Can you be more specific about "install" ?

Check the library with cmake then compile your code and link it

This is just a sample, modify regarding to your needs

find_package( PkgConfig REQUIRED)
pkg_check_modules( ulapi REQUIRED ulapi )

add_executable( my_exec src/my_source.cpp )
target_link_libraries( my_exec ${ulapi_LIBRARIES} )
edit flag offensive delete link more

Comments

What I mean by install is that I want to use the .c and .h files from ulapi (which is what we use to talk to the robot arms we have in the lab) in my c++ code I have written. I am familiar with the way you install libraries for arduino if that is of any help.

justinkgoh gravatar image justinkgoh  ( 2016-07-13 07:50:26 -0500 )edit
0

answered 2016-07-12 04:47:24 -0500

senreot gravatar image

If you have the library source files you can add a library to your workspace adding the following lines to the CMakeLists.txt of the node you want to use the library.

#Declare a cpp library  
add_library(my_library directory/of/source/my_library.cpp)

#This line has to be after the add_executable()  
target_link_libraries(my_node my_library)

Since the library is loaded in the workspace, you only need to add_library() once. For next nodes only use target_link_linbraries()

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-11 14:51:52 -0500

Seen: 753 times

Last updated: Jul 13 '16