Example #1
0
    def test_rosnode_ping(self):
        import rosnode
        cmd = 'rosnode'
        
        self.failIf(rosnode.rosnode_ping('/fake_node', max_count=1))
        self.assert_(rosnode.rosnode_ping('/rosout', max_count=1))
        self.assert_(rosnode.rosnode_ping('/rosout', max_count=2))        

        with fakestdout() as b:
            self.assert_(rosnode.rosnode_ping('/rosout', max_count=2, verbose=True))
            s = b.getvalue()
            self.assert_('xmlrpc reply' in s, s)
            self.assert_('ping average:' in s, s)
            
        # test via command-line API
        rosnode._rosnode_cmd_ping([cmd, 'ping', '-c', '1', '/fake_node'])
        with fakestdout() as b:
            rosnode._rosnode_cmd_ping([cmd, 'ping', '-c', '1', '/rosout'])
            s = b.getvalue()
            self.assert_('xmlrpc reply' in s, s)
        with fakestdout() as b:
            rosnode._rosnode_cmd_ping([cmd, 'ping', '-c', '1', 'rosout'])
            s = b.getvalue()
            self.assert_('xmlrpc reply' in s, s)
        with fakestdout() as b:
            rosnode._rosnode_cmd_ping([cmd, 'ping', '-c', '2', 'rosout'])
            s = b.getvalue()
            self.assertEquals(2, s.count('xmlrpc reply'))
Example #2
0
 def test_rosnode_kill(self):
     import rosnode
     cmd = 'rosnode'
     for n in ['to_kill/kill1', '/to_kill/kill2']:
         self.assert_(rosnode.rosnode_ping(n, max_count=1))
         rosnode._rosnode_cmd_kill([cmd, 'kill', n])
         self.failIf(rosnode.rosnode_ping(n, max_count=1))
def initialize():
    print("########### ROCKIE EXECUTIVE NODE ###########")
    print("Rockie executive node running...")

    # Test if nodes are alive
    print("Making sure nodes are alive...")
    # Add more node names to this string array
    dependent_nodes = ["cam_capture", "cam_display"]  
    for node in dependent_nodes:
        print("Checking"), 
        print(node), 
        print("..."),
        ping_count = 0
        while ping_count < 25:
            camera_capture_node_ALIVE = rosnode.rosnode_ping(node_name=node,max_count=1,verbose=False)
            if camera_capture_node_ALIVE:
                print("ALIVE")
                break
            else:
                if pint_count == 24:
                    print("DEAD")
Example #4
0
#!/usr/bin/env python 
import roslib
roslib.load_manifest('rosnode')
roslib.load_manifest('rospy')
import rospy
#from rospy import ROSException
from rosnode import rosnode_ping
from rospy import logerr

if __name__ == '__main__':

    if rosnode_ping("morse", 5, 0) == 1:
        pass
    else: 
        logerr("Could not find MORSE-rosnode. Please make sure it is running.")

    if rosnode_ping("morse_tf_broadcaster_navstack", 5, 0) == 1:
        pass
    else: 
        logerr("Could not find MORSE-TF-BROADCASTER. Please make sure it is running.")

    if rosnode_ping("robot_state_publisher", 5, 0) == 1:
        pass
    else: 
        logerr("Could not find ROBOT_STATE_PUBLISHER. Please make sure it is running and the JointStates are published on the correct topic!")
 def test_node(self):
     """ Verify that we can ping the node. """
     result = rosnode_ping('test_spacenav_inverter', max_count=1)
     self.assertTrue(result)
Example #6
0
 def __call__(self):
     """
     Ping the node.
     """
     return rosnode.rosnode_ping(self._name, max_count=1, verbose=False)
 def pingNode(self):
    res = rosnode.rosnode_ping(self.name,2,1)
    return res
Example #8
0
    def _monitor_nodes(self):
        for nodename in self._nodes_monitored:
            is_node_running = rosnode_ping(nodename, 1)

            #TODO: segfault occurs here most of every time the plugin shut down
            self._signal.emit(is_node_running, nodename)
Example #9
0
import rospy
import rosnode
from std_msgs.msg import String

def robotalker():
    robotalker = rospy.Publisher('woz/robotcontrol', String)
    
    # valid commands
    valid = rospy.get_param('robot/validcommands', [])
    command_help = rospy.get_param('robot/commandhelp', 'Help is not available.')
    print command_help
    
    while not rospy.is_shutdown():
        try:
            cmd = sys.stdin.readline().strip()
            if not cmd in valid:
                print command_help
            robotalker.publish(String(cmd))
        except IOError, e:
            pass

if __name__ == '__main__':
    rospy.init_node('robotcontrol',anonymous=True)
    while not rosnode.rosnode_ping('charlie_robot', max_count=1, verbose=True):
        rospy.sleep(1)
    try:
        robotalker()
    except rospy.ROSInterruptException: pass