
I won't pretend to be a ROS Linux or coding expert, but I've been stuck on getting my catkin_make to compile using the MRAA library from Intel. I'm using Intel's Up Board as my robot central controller. It will be eventually be doing SLAM and taking simple orders through a ROS message from a central computer elsewhere. Pretty standard. There are a few peripherals I want to connect to the Up Board by serial communication (SPI, specifically). At compile time the system breaks down when it tries to link to the MRAA library. It doesn't understand the references. So the way I see it, it's either a problem with the way I installed the library, or my CMakeLists.txt or package.xml is setup wrong. I've been through a lot of documentation, but cannot determine how to get the proper setup to link to the library.
catkin_make output:
[100%] Built target floorbot_generate_messages
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp: In function ‘int main(int, char**)’:
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:32:2: error: ‘mraa’ has not been declared
mraa::Spi * spiCom;
^
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:32:14: error: ‘spiCom’ was not declared in this scope
mraa::Spi * spiCom;
^
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:33:2: error: ‘mraa’ has not been declared
mraa::Spi * tooth;
^
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:33:14: error: ‘tooth’ was not declared in this scope
mraa::Spi * tooth;
^
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:35:15: error: expected type-specifier before ‘mraa’
spiCom = new mraa::Spi(0); // <---- portal to arduino (CS0)
^
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:35:15: error: expected ‘;’ before ‘mraa’
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:36:14: error: expected type-specifier before ‘mraa’
tooth = new mraa::Spi(1); // <---- portal to bluetooth (CS1)
^
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:36:14: error: expected ‘;’ before ‘mraa’
/home/floorbot/catkin_ws/src/floorbot/src/sojourner.cpp:54:50: error: ‘chatterCallback’ was not declared in this scope
ros::Subscriber sub = n.subscribe("chat", 1000, chatterCallback);
^
make[2]: *** [floorbot/CMakeFiles/sojourner.dir/src/sojourner.cpp.o] Error 1
make[1]: *** [floorbot/CMakeFiles/sojourner.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
floorbot@floorbot:~/catkin_ws$
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(floorbot)
find_package(catkin REQUIRED COMPONENTS
roscpp std_msgs message_generation)
find_package(Boost REQUIRED COMPONENTS system)
#find_package(mraa REQUIRED)
add_message_files(FILES commands.msg)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(
${catkin_CURRENT_SOURCE_DIR}
INCLUDE_DIRS include
LIBRARIES floorbot mraa
CATKIN_DEPENDS roscpp mraa std_msgs
message_runtime
DEPENDS system_lib mraa)
include_directories(${catkin_INCLUDE_DIRS})
include_directories(/home/mraa)
include_directories(/usr/include/mraa)
add_subdirectory(mraa)
add_library(mraa floorbot.cpp)
add_executable(sojourner src/sojourner.cpp)
add_dependencies(sojourner floorbot_generate_message_cpp ${catkin_EXPORTED_TARGETS})
target_link_libraries(mraa)
target_link_libraries(sojourner ${catkin_LIBRARIES})
package.xml:
<?xml version="1.0"?>
<package>
<name>floorbot</name>
<version>0.0.1</version>
<description>The floorbot package</description>
<maintainer email="floorbot@todo.todo">floorbot</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>commands</build_depend>
<build_depend>mraa</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>commands</run_depend>
<run_depend>mraa</run_depend>
<run_depend>message_runtime</run_depend>
<export></export>
</package>
Important code:
#include "robot.h"
#include "ros/ros.h"
#include "floorbot/commands.h"
#include "mraa.h"
void chatterCallBack(const floorbot::commands::ConstPtr& msg, Robot & robot)
{
robot.setCommand(msg->x_cmd, msg->y_cmd, msg->orientation);
}
int main(int argc, char **argv) {
Robot robot;
// Check battery status
// setBatSat() // <--- initialize battery status
// Check to see if robot is docked
// setDocked() // <--- update docking status
// --- Stuff for SPI communicaion --- //
mraa::Spi * spiCom;
mraa::Spi * tooth;
unsigned int bufSize = 3;
spiCom = new mraa::Spi(0); // <---- portal to arduino (CS0)
tooth = new mraa::Spi(1); // <---- portal to bluetooth (CS1)
I've tried gvdhoorn's suggestions and I still can't get it past telling me that it cannot find 'mraa-config.cmake.' The file does not exist. I tried making one and it did not work either. I'm going to try Intel's formus too to make sure I have everything setup right with MRAA. One thing to note it that I have MRAA in the home directory (~/mraa). It seems that most libraries should be in ~/usr/include/. All the tutorials for MRAA show it being placed in the home folder and installing it from there.
Here's my attempt at making a mraa-config.cmake file:
# config for mraa library
# MRAA_INCLUDE_DIRS - include directory for mraa
# MRAA_LIBRARIES - libraries to link against
Compute paths
get_filename_component(MRAA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(MRAA_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
Library dependencies
if(NOT TARGET mraa AND NOT mraa_BINARY_DIR)
include("${MRAA_CMAKE_DIR}/mraaTargets.cmake")
endif()
Import targets
set(MRAA_LIBRARIES mraa)
Originally posted by titan vista on ROS Answers with karma: 18 on 2016-11-10
Post score: 0