joystick_controlstart.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:curly-fortnight 作者: sManohar201 项目源码 文件源码
def __init__(self):

        rate = rospy.Rate(5)
        rospy.Subscriber("/bluetooth_teleop/joy", Joy, self.joy_callback)
        # Initialize button variables for button input
        self.x = 0
        self.circ = 0
        self.sq = self.tri = self.L1 = self.R1 = self.share = self.options = self.p4 = self.L3 = self.R3 = self.DL = self.DR = self.DU = self.DD = 0
        # Boolean variable used for tracking the status of object tracking process
        self.active = False
        objtrack_process = None

        rospy.loginfo("In start")

        while not rospy.is_shutdown():

            # If object tracking process is not currenlty active
            if self.active == False:

                # Start Object Tracking if circle button pressed
                if (self.circ == 1):
                    rospy.loginfo("Joystick code received, commencing object tracking protocol...")
                    self.active = True

                    package = 'obj_track'
                    executable = 'track.py'
                    node = roslaunch.core.Node(package, executable)
                    launch = roslaunch.scriptapi.ROSLaunch()
                    launch.start()
                    objtrack_process = launch.launch(node)
            # If object tracking process is active
            else:
                # Stop Object Tracking if x button pressed
                if (self.x == 1):
                    rospy.loginfo("Joystick code recieved, terminating object tracking protocol")
                    self.active = False
                    objtrack_process.stop()
            # Reset button variables for next pass
            self.x = 0
            self.circ = 0

    # callback function maps button data observed from joystick topic
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号