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

confuse with rosrun

asked 2013-04-01 08:30:24 -0500

Rizqa gravatar image

updated 2013-04-05 02:52:24 -0500

I try to rosrun a node in terminal.. nothing error.. but the node does not work..

rizqa@ubuntu:~/ROS_Workspace/robocop/bin$ rosrun robocop robocop_code2.py

[INFO] [WallTime: 1364840883.883536] Init..

[INFO] [WallTime: 1364840883.919665] Shutting down Tracker Node.

How that problem solved ????? -___-

This is the source code :

#!/usr/bin/env python

import roslib; roslib.load_manifest('robocop')

import rospy

from sensor_msgs.msg import JointState

from robocop.msg import Skeleton

import PyKDL

import xml.dom.minidom


class tracksendi():

    def __init__(self):
        rospy.init_node('track_sendi')
        rospy.on_shutdown(self.shutdown)
        rospy.loginfo("Init..")

        rate = rospy.Rate(10)
        rospy.Subscriber('skeleton', Skeleton, self.update_skeleton)

        self.send_ke_servo_pub = rospy.Publisher('/servo_joints',JointState)


        self.send_ke_servo =self.get_joints()
        self.save_send_ke_servo = self.get_joints()

    def get_joints(self):
        """ This function is taken from the joint_state_publisher package written by David Lu!!
            http://www.ros.org/wiki/joint_state_publisher
        """
        description = rospy.get_param("robot_description")
        robot = xml.dom.minidom.parseString(description).getElementsByTagName('robot')[0]
        self.free_joints = {}
        self.joint_list = [] # for maintaining the original order of the joints
        self.dependent_joints = rospy.get_param("dependent_joints", {})

        # Find all non-fixed joints.

        for child in robot.childNodes:
                if child.nodeType is child.TEXT_NODE:
                   continue
                if child.localName == 'joint':
                    jtype = child.getAttribute('type')
                    if jtype == 'fixed':
                        continue
                    name = child.getAttribute('name')
                    if jtype == 'continuous':
                        minval = -pi
                        maxval = pi
                    else:
                        limit = child.getElementsByTagName('limit')[0]
                        minval = float(limit.getAttribute('lower'))
                        maxval = float(limit.getAttribute('upper'))

                    if name in self.dependent_joints:
                        continue
                    if minval > 0 or maxval < 0:
                        zeroval = (maxval + minval)/2
                    else:
                         zeroval = 0

                    joint = {'min':minval, 'max':maxval, 'zero':zeroval, 'value':zeroval }
                    self.free_joints[name] = joint
                    self.joint_list.append(name)

        joint_state = JointState()
        joint_state.header.stamp = rospy.Time.now()

            # Add Free Joints.
            for (name, joint) in self.free_joints.items():
                joint_state.name.append(str(name))
                joint_state.position.append(joint['value'])
                joint_state.velocity.append(0)

            return joint_state

        while not rospy.is_shutdown():

              self.get_joints()
              self.send_ke_servo_pub.publish(self.kirim_ke_servo)
              self.send_ke_servo.header.stamp = rospy.Time.now()
              self.save_send_ke_servo = self.kirim_ke_servo

    def joint_state_handler(self, msg):
            for joint in msg.name:  
                self.kirim_ke_urdf = msg

    def shutdown(self):
            rospy.loginfo('Shutting down Tracker Node.')



if __name__ == '__main__':

    try:

        tracksendi()

    except rospy.ROSInterruptException:

        pass
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2013-04-01 09:20:40 -0500

Elizabeth C gravatar image

updated 2013-04-04 13:18:56 -0500

The problem is most likely in your code and has nothing to do with rosrun. It appears that your node did start, but it didn't keep running for very long. For the node to continue running, it has to either continuously be doing things (for example: while not rospy.is_shutdown(): #do stuff), or include rospy.spin() somewhere to keep it running after initialization is done. (You can see examples of both of those in this tutorial.)

If that wasn't the problem, you'll need to post your code before anyone will be able to help you.

EDIT: The actual problem appears to have been that a return statement was placed too early a method. Fixing this revealed another problem with infinite recursive method calls.

edit flag offensive delete link more

Comments

hi @Elizabeth C

Thanks for your time.. but that wasn't the problem.. I Have posted my code above... I hope anyone will be able to help me..

Rizqa gravatar image Rizqa  ( 2013-04-01 16:59:43 -0500 )edit
1

It looks like your indentation got a bit messed up in the copy; can you fix it?

If I'm reading it correctly, you have a return statement before you ever get to your 'while not rospy.is_shutdown():' loop, so that loop never has a chance to run.

ahendrix gravatar image ahendrix  ( 2013-04-01 19:34:10 -0500 )edit

hi.. @ahendrix Your suggestion works fine, and my ROS node run for a while.. after that, my ROS node get trouble again..

Rizqa gravatar image Rizqa  ( 2013-04-02 04:49:57 -0500 )edit

This is the error. How can I fix the problem ? I hope anyone will be able to help me

RuntimeError: maximum recursion depth exceeded in cmp [INFO] [WallTime: 1364913348.373804] Shutting down Tracker_Sendi Node.

Unhandled exception in thread started by

sys.excepthook is missing

lost sys.stderr

Rizqa gravatar image Rizqa  ( 2013-04-02 04:51:18 -0500 )edit

The message is telling you that you have too many recursive method calls. From looking at the code, this appears to be because you're calling get_joint() from within get_joint() (under while not rospy.is_shutdown() ).

Elizabeth C gravatar image Elizabeth C  ( 2013-04-03 12:28:40 -0500 )edit

Thanks for @Elizabeth C and @ahendrix.. My node works fine,, :)

Rizqa gravatar image Rizqa  ( 2013-04-04 18:15:34 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-04-01 08:30:24 -0500

Seen: 569 times

Last updated: Apr 05 '13