0
$\begingroup$

Rosanswers logo

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)

Originally posted by justinkgoh on ROS Answers with karma: 25 on 2016-07-11

Post score: 0


Original comments

Comment by gvdhoorn on 2016-07-12:
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.

Comment by justinkgoh on 2016-07-13:
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.

Comment by senreot on 2016-07-13:
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)

Comment by justinkgoh on 2016-07-14:
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.

Comment by gvdhoorn on 2016-07-14:
off-topic, but what I find much more interesting: what are you doing with robsim, gazebo and ulapi? :)

Comment by senreot on 2016-07-14:
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 ;)

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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} )

Originally posted by cagatay with karma: 1850 on 2016-07-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by justinkgoh on 2016-07-13:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.