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

FindogJr's profile - activity

2016-05-04 09:28:33 -0500 received badge  Student (source)
2016-01-11 18:11:34 -0500 received badge  Famous Question (source)
2016-01-11 18:11:34 -0500 received badge  Popular Question (source)
2016-01-11 18:11:34 -0500 received badge  Notable Question (source)
2015-07-29 08:53:38 -0500 received badge  Scholar (source)
2015-07-29 08:53:30 -0500 received badge  Supporter (source)
2015-07-28 10:29:33 -0500 commented answer New node and custom msg giving a data_class error

Thanks so much! I knew it was something small I was overlooking. This project has been very humbling. Thanks again!

2015-07-27 18:17:45 -0500 asked a question 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 ...
(more)