confuse with rosrun
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