New node and custom msg giving a data_class error
I have been working on a project for a few weeks everything has gone good until finished my a new node with custom messages. I am very new to ROS so I am sure that I might be missing one simple step. I have already made other nodes and msgs however this one is giving me problems. I have retraced my steps four times.
I am getting this error when rosrun my node:
Traceback (most recent call last):
File "/home/onr/catkin_ws/src/furuno_radar/src/ARPA_node.py", line 111, in <module>
main(sys.argv)
File "/home/onr/catkin_ws/src/furuno_radar/src/ARPA_node.py", line 104, in main
ARPAdata = ARPANode()
File "/home/onr/catkin_ws/src/furuno_radar/src/ARPA_node.py", line 85, in __init__
self._arpa_info_pub = rospy.Publisher("ARPA_data",RadarARPAInfo())
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py", line 803, in __init__
super(Publisher, self).__init__(name, data_class, Registration.PUB)
File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py", line 138, in __init__
raise ValueError("data_class [%s] is not a class"%data_class)
ValueError: data_class [header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: ''
Target: 0
TDistance: 0.0
TBearing: 0.0
TrueSpeed: 0.0
TrueCourse: 0.0
RelSpeed: 0.0
RelCourse: 0.0] is not a class
My message is in is own package and CMakeLists.txt and package.xml have been edited.
Header header
int32 Target
float64 TDistance #target distance from conning(.0001nm)
float64 TBearing #target bearing from own ship(.1 degree)
float64 TrueSpeed #target speed(.1kt)
float64 TrueCourse #target course(.1 degree)
float64 RelSpeed #relative speed (.01nm
float64 RelCourse #relitive course (.1 degree)
I created a node and made it executable. Here is my node.
#!/usr/bin/env python
import roslib
roslib.load_manifest('furuno_radar')
import sys
import rospy
from arpa_msgs.msg import RadarARPAInfo
from std_msgs.msg import String
import asyncore
import socket
import struct
class ARPANode(asyncore.dispatcher):
class ARPA:
radarNo = 0
target = 0
ccrpDist = 0.0
ccrpBear = 0.0
t_speed = 0.0
t_course = 0.0
r_speed = 0.0
r_course = 0.0
count = 0
def datagram2ARPA(self, data):
arpa = self.ARPA()
index = 0
length = struct.unpack_from("<I", data, index)[0]
index += 4
arpa.radarNo = struct.unpack_from("<I", data, index)[0]
index += 4
arpa.targetNo = struct.unpack_from("I", data, index)[0]
index += 4
arpa.ccrpDist = struct.unpack_from("<d", data, index)[0]
index += 8
arpa.ccrpBear = struct.unpack_from("<d", data, index)[0]
index += 8
arpa.t_speed = struct.unpack_from("<d", data, index)[0]
index += 8
arpa.t_course = struct.unpack_from("<d", data, index)[0]
index += 8
arpa.r_speed = struct.unpack_from("<d", data, index)[0]
index += 8
arpa.r_course = struct.unpack_from("<d", data, index)[0]
index += 8
arpa.count = struct.unpack_from("<I", data, index)[0]
return arpa
def ARPA2Messages(self, arpa):
arpa_info_message = RadarARPAInfo()
arpa_info_message.header.stamp = rospy.Time.now()
arpa_info_message.TDistance = arpa.ccrpDist
arpa_info_message.TBearing = arpa.ccrpBear
arpa_info_message.TrueSpeed = arpa.t_speed
arpa_info_message.TrueCourse = arpa.t_course
arpa_info_message.RelSpeed = arpa.r_speed
arpa_info_message.RelCourse = arpa.r_course
return arpa_info_message
def datagram2ARPAMessage(self, data):
arpa = self.datagram2ARPA(data)
return self.ARPA2Messages(arpa)
def __init__(self ...