turtlesim_joy.py 文件源码

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

项目:ROS-Robotics-By-Example 作者: PacktPublishing 项目源码 文件源码
def tj_callback(data):

    # start publisher of cmd_vel to control Turtlesim
    pub = rospy.Publisher("turtle1/cmd_vel", Twist, queue_size=1)

    # Create Twist message & add linear x and angular z from left joystick
    twist = Twist()
    twist.linear.x = data.axes[1]
    twist.angular.z = data.axes[0]

    # record values to log file and screen
    rospy.loginfo("twist.linear: %f ; angular %f", twist.linear.x, twist.angular.z)

    # process joystick buttons
    if data.buttons[0] == 1:        # green button on xbox controller
        move_circle()

    # publish cmd_vel move command to Turtlesim
    pub.publish(twist)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号