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

New msg for arduino

asked 2017-11-15 08:17:29 -0500

Amrello gravatar image

updated 2017-11-15 10:13:22 -0500

jayess gravatar image

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)
edit retag flag offensive close merge delete

Comments

It would be helpful if you copy and pasted the code and the terminal output here.

jayess gravatar image jayess  ( 2017-11-15 09:10:09 -0500 )edit

Can you please post your CMakeLists.txt too?

jayess gravatar image jayess  ( 2017-11-15 10:07:02 -0500 )edit

Why do you have two different CMakeLists.txt?

jayess gravatar image jayess  ( 2017-11-15 16:19:02 -0500 )edit
Amrello gravatar image Amrello  ( 2017-11-15 23:19:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-11-15 09:10:07 -0500

bpinaya gravatar image

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

edit flag offensive delete link more

Comments

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.

Amrello gravatar image Amrello  ( 2017-11-15 09:36:41 -0500 )edit

@Amrello: it would be helpful if you updated your question with what you've tried already (i.e., please post your source code)

jayess gravatar image jayess  ( 2017-11-15 09:39:08 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-11-15 08:17:29 -0500

Seen: 237 times

Last updated: Nov 15 '17