0
$\begingroup$

Rosanswers logo

HI everybody, I'm studying ROS, and I have a problem. I want to add my message to Arduino sketch, I successfully compiled the Arduino sketch in catkin workspace, but when I tried to add my meessage header file I obtain error: "NO such file or catalog" (massage successfully compiled in "devel/include/..."). Can anyone help me add a message ?

Error:

[ 91%] Building CXX object CMakeFiles/hello.dir/chatter.cpp.obj
/home/amrello/catkin_ws/src/arduino/firmware/chatter.cpp:4:27: fatal error: arduino/data1.h: No such file or catalog
 #include <arduino/data1.h>
                       

compilation terminated.

chatter.cpp (simplest publisher):

 #include <ros.h>
 #include <std_msgs/String.h>

 #include <arduino/data1.h>

 #include <Arduino.h>

 ros::NodeHandle nh;

 std_msgs::String str_msg;
 ros::Publisher chatter("chatter", &str_msg);

 char hello[13] = "hello world!";

 void setup()
 {
   nh.initNode();
   nh.advertise(chatter);
 }

 void loop()
 {
   str_msg.data = hello;
   chatter.publish( &str_msg );
   nh.spinOnce();
   delay(1000);
 }

CMakeLists.txt (in src ):

cmake_minimum_required(VERSION 2.8.3)

include_directories(${ROS_LIB_DIR})

# Remove this if using an Arduino without native USB (eg, other than Leonardo)
#add_definitions(-DUSB_CON)

generate_arduino_firmware(hello
   SRCS chatter.cpp ${ROS_LIB_DIR}/time.cpp ${ROS_LIB_DIR}/time.cpp
   BOARD mega2560
   PORT /dev/ttyACM0
 )

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(arduino)

find_package(catkin REQUIRED COMPONENTS
  rosserial_arduino
  rosserial_client
  roscpp
  std_msgs
  message_generation

)
add_message_files(
        FILES
        data1.msg
)
 generate_messages(
   DEPENDENCIES
   std_msgs

 )

catkin_package(
CATKIN_DEPENDS message_runtime
)

include_directories(include
  ${catkin_INCLUDE_DIRS}
)
rosserial_generate_ros_lib(
  PACKAGE rosserial_arduino
  SCRIPT make_libraries.py
)

rosserial_configure_client(
  DIRECTORY firmware
  TOOLCHAIN_FILE ${ROSSERIAL_ARDUINO_TOOLCHAIN}
)

rosserial_add_client_target(firmware hello ALL)
rosserial_add_client_target(firmware hello-upload)

Originally posted by Amrello on ROS Answers with karma: 26 on 2017-11-15

Post score: 0


Original comments

Comment by jayess on 2017-11-15:
It would be helpful if you copy and pasted the code and the terminal output here.

Comment by jayess on 2017-11-15:
Can you please post your CMakeLists.txt too?

Comment by jayess on 2017-11-15:
Why do you have two different CMakeLists.txt?

Comment by Amrello on 2017-11-16:
From this tutorial http://wiki.ros.org/rosserial_arduino/Tutorials/CMake

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi there! You have to rebuild your Arduino-ROS library in the same terminal that you source devel/setup.bash . Once you rebuild your Arduino library your messages should appear there :)


Originally posted by bpinaya with karma: 700 on 2017-11-15

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Amrello on 2017-11-15:
I mean that I can compile sketch from catkin workspace, but dont know how to add custom message, when i tried to add msg data1.h i get error.

Comment by jayess on 2017-11-15:
@Amrello: it would be helpful if you updated your question with what you've tried already (i.e., please post your source code)

$\endgroup$

Your Answer

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