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

siddian93's profile - activity

2017-01-26 14:36:32 -0500 received badge  Famous Question (source)
2016-12-19 10:31:38 -0500 received badge  Student (source)
2016-12-19 10:21:52 -0500 received badge  Popular Question (source)
2016-12-19 10:21:52 -0500 received badge  Notable Question (source)
2016-09-09 04:41:15 -0500 asked a question How to change from Python to PyPy to compile ROS Node ?

I have a package where the nodes are written in python using rospy and other python modules. But lately i realized that PyPy is a better alternative than the default python interpreter.

Basically, i want to change the interpreter such that when I run "rosrun pkg_name node_name", it will run using the PyPy interpreter instead of the Python Interpreter. I am guessing that this might be possible if I make some changes in the CMakeLists.txt file. Any help ?

2016-09-07 01:53:10 -0500 answered a question run a subscriber callback once using rospy.spin()

2 Steps : Flag set to 0 in the class __init__ method. Step 1 : I believe a better alternate is to define the call back method in a class along with the subscriber. And then setting a flag which will be set to one once the callback method has been called for the first time.

Step 2 : Once the Flag has been set 1, in the subscriber declaration block, return to the called block.

An Example is given below : (Tested Works)

class frontCam : def __init__(self): self.flag = 0 rospy.init_node("DFC") self.getVideo()

def getVideo(self) :
    rospy.Rate(1)
    self.image_sub = rospy.Subscriber('Subscribed TOPIC', Message_Type, self.callback )
    print 'Getting Video Feed . . . ' 
    if (self.flag == 1)
        return
    try :
        rospy.spin()
    except KeyboardInterrupt :
        print "Shutting Down"

def callback(self, data) :
    self.flag = 1

However if you guys want, can close the callback method after a certain period using the ropy.sleep() and the return statement as well.