Ask Your Question
0

rostopic publish/subscribe over serial port

asked 2019-06-03 13:13:01 -0500

jamesislost gravatar image

Hi, I'm trying to receive IMU data from simulink on a STM32 Nucleo board over port "ttyACM0" to a topic "/raw_imu" and also publish navigation plan coordinates from rostopic "/local_plan".

I'm confused about the general method of doing this. Do I make a script to run on the host computer or the STM board? I've tried the tutorials on the the wiki and this is the best I can come up with but I'm not sure where to put it. This part is only for the board publisher. (I know it's very not right but any tips would be super helpful)

#!/usr/bin/env python import roslib

import rospy from nav_msgs.msg

import Path

import serial

ros::NodeHandle nh;

ser = serial.Serial('/dev/ttyACM0', 9600)

def talker():

while not rospy.is_shutdown():

data= ser.read(2)

rospy.loginfo(IMU)

pub.publish(String(IMU))

rospy.sleep(1.0)

if __name__ == '__main__':

try: pub = rospy.Publisher('IMU', String)

rospy.init_node('talker')

talker()

except rospy.ROSInterruptException:

pass

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-06-03 15:06:01 -0500

This depends on the IMU board your using, what protocol it uses and if you can update its firmware or not. For example the Razor IMU ROS package uses a custom firmware on the board and a ROS node on the host computer together to publish the IMU data to ROS. Another option would be to use ROSSerial on the board so it publishes the IMU messages directly.

It looks like you're using an arduino derivative so the ROSSerial option would probably be the simplest method to use. There are somegood tutorials(http://wiki.ros.org/rosserial/Tutorials) you can use to get started. Is the IMU data you're receiving already calibrated or will the node need to do that as well?

Hope this gives you some pointers.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-06-03 13:13:01 -0500

Seen: 44 times

Last updated: Jun 03