Python geometry_msgs.msg 模块,Twist() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用geometry_msgs.msg.Twist()

项目:ros_myo    作者:uts-magic-lab    | 项目源码 | 文件源码
def drive(gest):

        if gest.data == 1: #FIST
        turtlesimPub.publish("go back")
        tsPub.publish(Twist(Vector3(-1.0, 0, 0), Vector3(0, 0, 0)))
        elif gest.data == 2 and armState == 1: #WAVE_IN, RIGHT arm
        turtlesimPub.publish("go left")
        tsPub.publish(Twist(Vector3(0, 0, 0), Vector3(0, 0, 1.0)))
        elif gest.data == 2 and armState == 2: #WAVE_IN, LEFT arm
        turtlesimPub.publish("go right")
        tsPub.publish(Twist(Vector3(0, 0, 0), Vector3(0, 0, -1.0)))
        elif gest.data == 3 and armState == 1: #WAVE_OUT, RIGHT arm
        turtlesimPub.publish("go right")
        tsPub.publish(Twist(Vector3(0, 0, 0), Vector3(0, 0, -1.0)))
        elif gest.data == 3 and armState == 2: #WAVE_OUT, LEFT arm
        turtlesimPub.publish("go left")
        tsPub.publish(Twist(Vector3(0, 0, 0), Vector3(0, 0, 1.0)))
        elif gest.data == 4: #FINGERS_SPREAD
        turtlesimPub.publish("go forward")
        tsPub.publish(Twist(Vector3(1.0, 0, 0), Vector3(0, 0, 0)))
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def init(self):
        pygame.init()
        clock = pygame.time.Clock()
        screen = pygame.display.set_mode((250, 250))

        rospy.init_node('highway_teleop')
        self.rate = rospy.Rate(rospy.get_param('~hz', 10)) 
        self.acc = rospy.get_param('~acc', 5)
        self.yaw = rospy.get_param('~yaw', 0)

        self.robot_pub = rospy.Publisher('robot_0/cmd_vel', Twist, queue_size=1)

        print "Usage: \n \
                up arrow: accelerate \n \
                down arrow: decelerate \n \
                left arrow: turn left \n \
                right arrow: turn right"
项目:trajectory_tracking    作者:lmiguelvargasf    | 项目源码 | 文件源码
def compute_control_actions():
    global i
    controller.compute_control_actions(current_pose, current_twist, i)
    data_container['t'].append(i * DELTA_T)
    data_container['x'].append(current_pose.position.x)
    data_container['x_ref'].append(controller.x_ref_n)
    data_container['y'].append(current_pose.position.y)
    data_container['y_ref'].append(controller.y_ref_n)
    data_container['theta'].append(controller.theta_n)
    data_container['theta_ref'].append(controller.theta_ref_n)
    data_container['v_c'].append(controller.v_c_n)
    data_container['w_c'].append(controller.w_c_n)
    data_container['zeros'].append(0)

    twist = Twist()
    twist.linear.x = controller.v_c_n
    twist.angular.z = controller.w_c_n
    twist_publisher.publish(twist)

    i += 1
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def start():
    global left_motor_pub,right_motor_pub
    # publishing to "turtle1/cmd_vel" to control turtle1
    global pub
    pub = rospy.Publisher('turtle1/cmd_vel', Twist)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    # subscribed to joystick inputs on topic "joy"
    rospy.Subscriber("joy", Joy, callback)
    # starts the node
    rospy.init_node('Joy2Turtle')
    rospy.spin()
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def start():
    global left_motor_pub,right_motor_pub
    # publishing to "turtle1/cmd_vel" to control turtle1
    global pub
    pub = rospy.Publisher('turtle1/cmd_vel', Twist)
    left_motor_pub = rospy.Publisher('/left_motor', std_msgs.msg.Int32, queue_size=10)
    right_motor_pub = rospy.Publisher('/right_motor', std_msgs.msg.Int32, queue_size=10)
    # subscribed to joystick inputs on topic "joy"
    rospy.Subscriber("joy", Joy, callback)
    # starts the node
    rospy.init_node('Joy2Turtle')
    rospy.spin()
项目:cnn_picture_gazebo    作者:liuyandong1988    | 项目源码 | 文件源码
def contr(keynumber):
    # turtlesim??topic
    pub = rospy.Publisher('~cmd_vel', Twist, queue_size=5)
    countnum = 0
    if keynumber == 3:
        while(1):
            twist = Twist()
            twist.linear.x = 0.2
            twist.linear.y = 0
            twist.linear.z = 0
            twist.angular.x = 0
            twist.angular.y = 0
            twist.angular.z = 0.14
            pub.publish(twist)
            countnum += 1

            if countnum > 100000:
                countnum = 0
                exit(0)
项目:AutonomousParking    作者:jovanduy    | 项目源码 | 文件源码
def __init__(self):
        """Constructor for the class
        initialize topic subscription and 
        instance variables
        """
        self.r = rospy.Rate(5)
        self.publisher = rospy.Publisher('/cmd_vel', Twist, queue_size=10)
        rospy.Subscriber('/scan', LaserScan, self.process_scan)
        # user chooses which parking mode to be performed
        self.is_parallel = rospy.get_param('~parallel', False)

        # Instance Variables
        self.timestamp1 = None
        self.timestamp2 = None
        self.dist2Neato = None
        self.dist2Wall = None
        self.widthOfSpot = None
        self.twist = None
        self.radius = None
        # Adjusment to be made before moving along the arc
        self.adjustment = 0 
        self.isAligned = False
项目:AutonomousParking    作者:jovanduy    | 项目源码 | 文件源码
def __init__(self):
        """ Initialize the parking spot recognizer """

        #Subscribe to topics of interest
        rospy.Subscriber("/camera/image_raw", Image, self.process_image)
        rospy.Subscriber('/cmd_vel', Twist, self.process_twist)

        # Initialize video images
        cv2.namedWindow('video_window')        
        self.cv_image = None # the latest image from the camera
        self.dst =  np.zeros(IMG_SHAPE, np.uint8)
        self.arc_image = np.zeros(IMG_SHAPE, np.uint8)
        self.transformed = np.zeros(IMG_SHAPE, np.uint8)

        # Declare instance variables
        self.bridge = CvBridge() # used to convert ROS messages to OpenCV
        self.hsv_lb = np.array([0, 70, 60]) # hsv lower bound to filter for parking lines
        self.hsv_ub = np.array([30, 255, 140]) # hsv upper bound
        self.vel = None
        self.omega = None
        self.color = (0,0,255)
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def __init__(self):
        rospy.loginfo('[robot_move_pkg]->linear_move is initial')
        #???????????????
        self.robot_state = robot_state.robot_position_state()
        self.cmd_move_pub = rospy.Publisher('/cmd_move', g_msgs.Twist, queue_size = 100)
        self.rate = rospy.Rate(150)
        #???????????
        self.stop_tolerance = config.high_speed_stop_tolerance
        self.angular_tolerance = config.high_turn_angular_stop_tolerance
        #?????????????
        self.accurate_turn_an_angular = turn_an_angular.turn_an_angular()
        self.x_speed = 0.0
        self.y_speed = 0.0
        self.w_speed = config.high_turn_angular_speed
        #???????
        self.linear_sp = spline_func.growth_curve()
        self.amend_speed = 0.12
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def __init__(self):
        #?????????? m/s
        self.move_cmd_pub = rospy.Publisher('cmd_move_robot',g_msgs.Twist,queue_size=100)

        self.move_speed = config.go_along_circle_speed
        self.get_position = robot_state.robot_position_state()
        #????????? rad
        self.stop_tolerance = config.go_along_circle_angular_tolerance
        #????????
        rospy.on_shutdown(self.brake)
        # ??sleep ??? ???????????
        self.rate = 100.0
        self.R = rospy.Rate(int(self.rate))
        self.MODE = { 1:(-1, 1),
                      2:( 1,-1),
                      3:( 1, 1),
                      4:(-1,-1)}
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def go_to(self, radius, angular, mode):
        # ??????????
        symbol_y,symbol_w = self.MODE[mode]
        ang_has_moved = 0.0
        self.reach_goal = False
        move_vel = g_msgs.Twist()
        start_yaw = self.get_position.get_robot_current_w()
        while not rospy.is_shutdown() and self.reach_goal != True:
            current_yaw = self.get_position.get_robot_current_w()
            ang_has_moved += abs(abs(current_yaw) - abs(start_yaw))
            start_yaw = current_yaw
            if abs(ang_has_moved - abs(angular)) <= self.stop_tolerance:
                self.reach_goal = True
                break
            move_vel.linear.y = self.move_speed*symbol_y
            # ???????, ???? dw*dt = dt*atan2(dv*dt/2.0, radius)
            move_vel.angular.z = self.rate*atan2(self.move_speed/self.rate,radius)*symbol_w
            print ang_has_moved
            self.move_cmd_pub.publish(move_vel)
            self.R.sleep()
        self.brake()

        print ang_has_moved
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def correct_angle(self):
        # rospy.loginfo("sadasdafasf")
        (x,theta,if_close_line) = self.close_line_cmd.find_line()
        r = rospy.Rate(50)
        move_velocity = g_msgs.Twist()
        if theta > 0:
            move_velocity.angular.z = -0.10
        else:
            move_velocity.angular.z = 0.10
        while not rospy.is_shutdown():
            (x,theta,if_close_line) = self.close_line_cmd.find_line()
            self.cmd_move_pub.publish(move_velocity)
            #????????????????

            if theta < 0.02 and theta > -0.02:
                rospy.loginfo("will Stop!!!!!!!!!!")
                self.brake()
                break
            r.sleep()


    #??3??????
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def __init__(self):
        rospy.loginfo('[robot_move_pkg]->linear_move is initial')
        #???????????????
        self.robot_state = robot_state.robot_position_state()
        self.cmd_move_pub = rospy.Publisher('/cmd_move', g_msgs.Twist, queue_size = 100)
        self.rate = rospy.Rate(150)
        #???????????
        self.stop_tolerance = config.high_speed_stop_tolerance
        self.angular_tolerance = config.high_turn_angular_stop_tolerance
        #?????????????
        self.accurate_turn_an_angular = turn_an_angular.turn_an_angular()
        self.x_speed = 0.0
        self.y_speed = 0.0
        self.w_speed = config.high_turn_angular_speed
        #???????
        self.linear_sp = spline_func.growth_curve()
        self.amend_speed = 0.18
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def turn(self, goal_angular):
        # ???????????????,??????????????
        # ????,????
        rospy.loginfo('[robot_move_pkg]->move_in_robot.turn will turn %s'%goal_angular)
        current_angular = start_angular = self.robot_state.get_robot_current_w()#??????????

        r = rospy.Rate(100)
        delta_angular = current_angular - start_angular
        move_velocity = g_msgs.Twist()
        while not rospy.is_shutdown() :
            if abs(delta_angular - abs(goal_angular)) < self.turn_move_stop_tolerance:
                break
            current_angular = self.robot_state.get_robot_current_w()
            move_velocity.angular.z = math.copysign(self.w_speed, goal_angular)
            delta_angular += abs(abs(current_angular) - abs(start_angular) )
            start_angular = current_angular
            self.cmd_move_pub.publish(move_velocity) #???????????
            r.sleep()
        self.brake()
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def turn_to(self,goal_angular):
        rospy.on_shutdown(self.brake) #???????????
        current_angular = start_angular = self.robot_state.get_robot_current_w()#??????????
        is_arrive_goal = False
        r = rospy.Rate(100)
        delta_angular = current_angular - start_angular
        delta_upper_limit = abs(goal_angular) + 0.02 #????
        delta_lower_limit = abs(goal_angular) - 0.02 #????
        move_velocity = g_msgs.Twist()
        while not rospy.is_shutdown() and not is_arrive_goal:
            if abs(delta_angular)<=delta_upper_limit and abs(delta_angular) >= delta_lower_limit: #????
                self.brake()
                is_arrive_goal = True
                break
            current_angular = self.robot_state.get_robot_current_w()
            if goal_angular > 0:
                move_velocity.angular.z = 0.1
            else:
                move_velocity.angular.z = -0.1
            delta_angular += abs(abs(current_angular) - abs(start_angular) )
            start_angular = current_angular
            self.cmd_move_pub.publish(move_velocity) #???????????
            r.sleep()
        self.brake()
项目:master_robot_strage    作者:nwpu-basketball-robot    | 项目源码 | 文件源码
def __init__(self):
        self.find_ball_client = rospy.ServiceProxy('volleyball_data',volleyballdata)
        self.cmd_vel_pub = rospy.Publisher('cmd_move_robot' , g_msgs.Twist , queue_size=100)
        self.cmd_position = get_robot_position.robot_position_state()
        self.move_speed = 0.21
        #????????
        rospy.on_shutdown(self.brake)
        #????????????
        self.MODE = { 1:(-1, 1),
                      2:( 1,-1),
                      3:( 1, 1),
                      4:(-1,-1)}
        rospy.loginfo('waiting for the find ball..')
        self.find_ball_client.wait_for_service()
        rospy.loginfo('connect to the find ball!!!')

    #??????????????????
项目:telegram_robot    作者:uts-magic-lab    | 项目源码 | 文件源码
def __init__(self):
        self.base_pub = rospy.Publisher("/base_controller/command", Twist,
                                        queue_size=1)
        token = rospy.get_param('/telegram/token', None)

        # Create the Updater and pass it your bot's token.
        updater = Updater(token)

        # Add command and error handlers
        updater.dispatcher.add_handler(CommandHandler('start', self.start))
        updater.dispatcher.add_handler(CommandHandler('help', self.help))
        updater.dispatcher.add_handler(MessageHandler(Filters.text, self.echo))
        updater.dispatcher.add_error_handler(self.error)

        # Start the Bot
        updater.start_polling()
项目:ros_myo    作者:uts-magic-lab    | 项目源码 | 文件源码
def drive(gest):
        global movingState
        global zero
        global speed
        if gest.data == 1: #FIST
            movingState -= 1
        elif gest.data == 4 or gest.data == 2: #FINGERS_SPREAD
            movingState += 1
        elif gest.data == 3 :
            zero = y

        if movingState > 0 :
            movingState = 1
            turtlesimPub.publish("go forward")
            speed = 1
#           tsPub.publish(Twist(Vector3(1.0, 0, 0), Vector3(0, 0, 0)))
        elif movingState < 0 :
            movingState = -1
            turtlesimPub.publish("go back")
            speed = -1
#           tsPub.publish(Twist(Vector3(-1.0, 0, 0), Vector3(0, 0, 0)))
        else :
            speed = 0
        print (speed)
项目:ros_myo    作者:uts-magic-lab    | 项目源码 | 文件源码
def strength(emgArr1):
        emgArr=emgArr1.data
        # Define proportional control constant:
        K = 0.005
        # Get the average muscle activation of the left, right, and all sides
        aveRight=(emgArr[0]+emgArr[1]+emgArr[2]+emgArr[3])/4
        aveLeft=(emgArr[4]+emgArr[5]+emgArr[6]+emgArr[7])/4
        ave=(aveLeft+aveRight)/2
        # If all muscles activated, drive forward exponentially
        if ave > 500:
            tsPub.publish(Twist(Vector3(0.1*math.exp(K*ave),0,0),Vector3(0,0,0)))
        # If only left muscles activated, rotate proportionally
        elif aveLeft > (aveRight + 200):
            tsPub.publish(Twist(Vector3(0,0,0),Vector3(0,0,K*ave)))
        # If only right muscles activated, rotate proportionally
        elif aveRight > (aveLeft + 200):
            tsPub.publish(Twist(Vector3(0,0,0),Vector3(0,0,-K*ave)))
        # If not very activated, don't move (high-pass filter)
        else:
            tsPub.publish(Twist(Vector3(0,0,0),Vector3(0,0,0)))
项目:ros_myo    作者:uts-magic-lab    | 项目源码 | 文件源码
def strength(emgArr1):
    emgArr=emgArr1.data
    # Define proportional control constant:
    K = 0.005
    # Get the average muscle activation of the left, right, and all sides
    aveRight=(emgArr[0]+emgArr[1]+emgArr[2]+emgArr[3])/4
    aveLeft=(emgArr[4]+emgArr[5]+emgArr[6]+emgArr[7])/4
    ave=(aveLeft+aveRight)/2
    # If all muscles activated, drive forward exponentially
    if ave > 500:
        tsPub.publish(Twist(Vector3(0.1*math.exp(K*ave),0,0),Vector3(0,0,0)))
    # If only left muscles activated, rotate proportionally
    elif aveLeft > (aveRight + 200):
        tsPub.publish(Twist(Vector3(0,0,0),Vector3(0,0,K*ave)))
    # If only right muscles activated, rotate proportionally
    elif aveRight > (aveLeft + 200):
        tsPub.publish(Twist(Vector3(0,0,0),Vector3(0,0,-K*ave)))    
    # If not very activated, don't move (high-pass filter)    
    else: 
        tsPub.publish(Twist(Vector3(0,0,0),Vector3(0,0,0)))
项目:cozmo_driver    作者:OTL    | 项目源码 | 文件源码
def __init__(self):
        # setup
        CozmoTeleop.settings = termios.tcgetattr(sys.stdin)
        atexit.register(self.reset_terminal)

        # vars
        self.head_angle = STD_HEAD_ANGLE
        self.lift_height = STD_LIFT_HEIGHT

        # params
        self.lin_vel = rospy.get_param('~lin_vel', 0.2)
        self.ang_vel = rospy.get_param('~ang_vel', 1.5757)

        # pubs
        self._head_pub = rospy.Publisher('head_angle', Float64, queue_size=1)
        self._lift_pub = rospy.Publisher('lift_height', Float64, queue_size=1)
        self._cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1)
项目:xm_strategy    作者:xm-project    | 项目源码 | 文件源码
def run(self):
        if self.finished:
            return TaskStatus.SUCCESS
        else:
            rospy.loginfo('Vacuuming the floor in the ' + str(self.room))

            while self.counter > 0:
                self.cmd_vel_pub.publish(self.cmd_vel_msg)
                self.cmd_vel_msg.linear.x *= -1
                rospy.loginfo(self.counter)
                self.counter -= 1
                rospy.sleep(1)
                return TaskStatus.RUNNING

            self.finished = True
            self.cmd_vel_pub.publish(Twist())
            message = "Finished vacuuming the " + str(self.room) + "!"
            rospy.loginfo(message)
项目:diy_driverless_car_ROS    作者:wilselby    | 项目源码 | 文件源码
def __init__(self):

      """ROS Subscriptions """
      self.image_sub = rospy.Subscriber("/raspicam_node/image/image_raw",Image,self.cvt_image) 
      self.image_pub = rospy.Publisher("/image_converter/output_video",Image, queue_size=10)
      self.cmdVel_pub = rospy.Publisher("/platform_control/cmd_vel", Twist, queue_size=10)
      self.cmdVelStamped_pub = rospy.Publisher('/platform_control/cmd_vel_stamped', TwistStamped, queue_size=10)

      """ Variables """
      self.model_path = 'home/wil/ros/catkin_ws/src/diy_driverless_car_ROS/rover_ml/behavior_cloning/src/behavior_cloning/model.h5'
      self.cmdvel = Twist()
      self.baseVelocity = TwistStamped()
      self.bridge = CvBridge()
      self.latestImage = None
      self.outputImage = None
      self.resized_image = None
      self.imgRcvd = False
项目:diy_driverless_car_ROS    作者:wilselby    | 项目源码 | 文件源码
def cmdVel_publish(self, cmdVelocity):

         # Publish Twist
         self.cmdVel_pub.publish(cmdVelocity)

         # Publish TwistStamped 
         self.baseVelocity.twist = cmdVelocity

         baseVelocity = TwistStamped()

         baseVelocity.twist = cmdVelocity

         now = rospy.get_rostime()
         baseVelocity.header.stamp.secs = now.secs
         baseVelocity.header.stamp.nsecs = now.nsecs
         self.cmdVelStamped_pub.publish(baseVelocity)
项目:speaker_recognizer_robot    作者:shrutiyer    | 项目源码 | 文件源码
def __init__(self):
        rospy.init_node('localizer')
        rospy.Subscriber('/odom', Odometry, self.process_odom)

        self.sound_speed = 340.29*100 # cm/s
        self.mic_dist = 30 # cm
        self.buffer = 200
        self.angles = []

        # angle odometry
        self.angle_curr = 0.0
        self.angle_k = 1
        self.angle_error = None
        self.at_speaker = False
        self.angle_pred = 0.0

        self.pub = rospy.Publisher('/cmd_vel', Twist, queue_size=10)
项目:curly-fortnight    作者:sManohar201    | 项目源码 | 文件源码
def __init__(self):
        self.bridge = cv_bridge.CvBridge()
        cv2.namedWindow("input", 1)
        cv2.createTrackbar('param1', 'input', 10, 300, nothing)
        cv2.createTrackbar('param2', 'input', 15, 300, nothing)
        cv2.namedWindow("processed", 1)
        self.image_sb = rospy.Subscriber('/usb_cam/image_raw', Image, self.image_callback)

        self.motion = Twist()

        rate = rospy.Rate(20)

        # publish to cmd_vel of the jackal
        pub = rospy.Publisher("/jackal_velocity_controller/cmd_vel", Twist, queue_size=10)

        while not rospy.is_shutdown():
            # publish Twist
            pub.publish(self.motion)
            rate.sleep()
项目:PyByrobotPetrone    作者:ildoonet    | 项目源码 | 文件源码
def __init__(self):
        self.petrone = Petrone()

        # subscriber
        self.sub_flight = rospy.Subscriber('cmd_fly', Int8, self.cb_fly, queue_size=1)
        self.sub_cmd = rospy.Subscriber('cmd_vel_raw', Twist, self.cb_cmd, queue_size=1)
        self.sub_color = rospy.Subscriber('led_color', String, self.cb_color, queue_size=1)

        # publisher
        self.pub_battery = rospy.Publisher('battery', Float32, queue_size=1)
        self.pub_status_flight = rospy.Publisher('status/flight', Int8, queue_size=1)
        self.pub_status_system = rospy.Publisher('status/system', Int8, queue_size=1)
        self.pub_imu = rospy.Publisher('imu', Imu, queue_size=1)

        # cache
        self.is_disconnected = True
        self.last_values = defaultdict(lambda: 0)

        # flight parameters
        self.twist = Twist()
        self.twist_at = 0
项目:autonomous_bicycle    作者:SiChiTong    | 项目源码 | 文件源码
def __init__(self):
        self.pub_vel_wheel = rospy.Publisher('/bycycle_interaction/vel_wheel', Twist, queue_size=1)

        self.twist = Twist()
        self.vel_wheel = 0
        self.angle_wheel = 0

        self.rate = rospy.get_param('~rate', 3.0)
        self.wheel_radius = rospy.get_param('~wheel_radius', 0.30)

        self.srv = Server(bicycle_interactionConfig, self.reconfig_callback) # define dynamic_reconfigure callback

        rate = rospy.Rate(self.rate)

        while not rospy.is_shutdown():
            self.publish_vel_wheel()
            rate.sleep()
项目: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)
项目:ROS-Robotics-By-Example    作者:PacktPublishing    | 项目源码 | 文件源码
def move_circle():

    # Create a publisher which can "talk" to Turtlesim and tell it to move
    pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=1)

    # Create a Twist message and add linear x and angular z values
    move_cmd = Twist()
    move_cmd.linear.x = 1.0
    move_cmd.angular.z = 1.0

    # Save current time and set publish rate at 10 Hz
    now = rospy.Time.now()
    rate = rospy.Rate(10)

    # For the next 6 seconds publish cmd_vel move commands to Turtlesim
    while rospy.Time.now() < now + rospy.Duration.from_sec(6):
        pub.publish(move_cmd)
        rate.sleep()
项目:occ_grid_map    作者:ku-ya    | 项目源码 | 文件源码
def keyboard():
    pub = rospy.Publisher('/mobile_base/commands/velocity',Twist, queue_size=10)
    rospy.init_node('teleop_py',anonymous=True)
    rate = rospy.Rate(10)
    k = 1
    while not rospy.is_shutdown() and k < 250:
      twist.linear.x = 1.0
      twist.angular.z = 0.01
      twist.linear.y = 0.0
      pub.publish(twist)
      rate.sleep()
      k +=1
    k = 1
    # while not rospy.is_shutdown() and k < 400:
    #   twist.linear.x = 0.0
    #   twist.angular.z = 0.1
    #   twist.linear.y = 0.0
    #   pub.publish(twist)
    #   rate.sleep()
    #   k +=1
项目:TurtleBot_IMU_Integration    作者:therrma2    | 项目源码 | 文件源码
def callback(data,pub):
    t = Twist()

    if data.data == 1:
        t.linear.x = .25
        print t
    if data.data == 2:
        t.angular.z = 2
    if data.data == 3:
        t.linear.x = .25
        t.angular.z = 1

    time = rospy.get_time()
    while rospy.get_time()-time < 6:
        pub.publish (t)
        rospy.sleep(.005)
项目:ROS-Robotics-by-Example    作者:FairchildC    | 项目源码 | 文件源码
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)
项目:ROS-Robotics-by-Example    作者:FairchildC    | 项目源码 | 文件源码
def move_circle():

    # Create a publisher which can "talk" to Turtlesim and tell it to move
    pub = rospy.Publisher('turtle1/cmd_vel', Twist, queue_size=1)

    # Create a Twist message and add linear x and angular z values
    move_cmd = Twist()
    move_cmd.linear.x = 1.0
    move_cmd.angular.z = 1.0

    # Save current time and set publish rate at 10 Hz
    now = rospy.Time.now()
    rate = rospy.Rate(10)

    # For the next 6 seconds publish cmd_vel move commands to Turtlesim
    while rospy.Time.now() < now + rospy.Duration.from_sec(6):
        pub.publish(move_cmd)
        rate.sleep()
项目:formulapi_ROS_simulator    作者:wilselby    | 项目源码 | 文件源码
def __init__(self):
      self.imgprocess = ImageProcessor.ImageProcessor()
      self.bridge = CvBridge()
      self.latestimage = None
      self.process = False

      """ROS Subscriptions """
      self.image_pub = rospy.Publisher("/image_converter/output_video",Image, queue_size=10)
      self.image_sub = rospy.Subscriber("/cam/camera_/image_raw",Image,self.cvt_image)
      self.cmdVelocityPub = rospy.Publisher('/platform_control/cmd_vel', Twist, queue_size=10)

      self.targetlane = 0
      self.cmdvel = Twist()
      self.last_time = rospy.Time()
      self.sim_time = rospy.Time()
      self.dt = 0
      self.position_er = 0
      self.position_er_last = 0;
      self.cp = 0
      self.vel_er = 0
      self.cd = 0
      self.Kp = 3
      self.Kd = 3.5
项目:plantbot    作者:marooncn    | 项目源码 | 文件源码
def speed_converter():
  rospy.init_node('wheel_speed', anonymous=True)
  pub1 = rospy.Publisher('lwheel_vtarget', Float32, queue_size=10)
  pub2 = rospy.Publisher('rwheel_vtarget', Float32, queue_size=10)
  rate = rospy.Rate(10)
  while not rospy.is_shutdown():
    rospy.Subscriber('cmd_vel', Twist, callback)
    s1 = "The left wheel's target speed is %f m/s." % lv
    s2 = "The right wheel's target speed is %f m/s." % rv
    rospy.loginfo(s1)
    rospy.loginfo(s2)
    pub1.publish(lv)
    pub2.publish(rv) 
    rate.sleep()
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def initPubs(self):
        self.robot_pubs = {}
        count = 1
        for i in range(self.num_lanes):
            num_car_lane = self.num_cars_per_lane[i]
            for j in range(num_car_lane):
                self.robot_pubs[count] = {}
                self.robot_pubs[count]['laneid'] = i
                self.robot_pubs[count]['pub'] = rospy.Publisher('robot_' + str(count) + '/cmd_vel', Twist, queue_size=1)
                count += 1
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def send_control(self, robot_pub, vel, yaw):
        msg = Twist()
        msg.linear.x = vel
        msg.angular.z = 0
        robot_pub.publish(msg)
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def send_control(self, vel, yaw):
        msg = Twist()
        msg.linear.x = vel
        msg.angular.z = yaw
        self.robot_pub.publish(msg)
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def init(self):
        self.hz = 500
        self.rate = rospy.Rate(self.hz)

        self.robot_pub = rospy.Publisher('robot_0/cmd_vel', Twist, queue_size=1)

        self.start_game = False
        # self.start_game = True
        # self.initTime = time() 
        # self.index = 0
        self.initUpdateVel = True
        self.TIME_PER_STEP = 0.1

        self.LoadControls()
        self.lenControls = len(self.controls)
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def init(self):

        self.hz = rospy.get_param('~hz', 10)
        self.max_speed = rospy.get_param('~max_speed', 5)
        self.min_speed = rospy.get_param('~min_speed', -5)
        self.rate = rospy.Rate(self.hz) 

        self.robot_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1)

        self.acc = 0
        self.yaw = 0
        self.vel = 0
项目:cs6244_motionplanning    作者:chenmin1107    | 项目源码 | 文件源码
def send_control(self, vel, yaw):
        msg = Twist()
        msg.linear.x = vel
        msg.angular.z = yaw
        self.robot_pub.publish(msg)
项目:ab2016-ros-gazebo    作者:akademikbilisim    | 项目源码 | 文件源码
def __init__(self, name):
        self.name = name

        # Publisher
        self.cmd_vel = rospy.Publisher("/%s/cmd_vel" % self.name,
                                       Twist, queue_size=1)

        # Subscriber
        self.odom = rospy.Subscriber("/%s/odom" % self.name,
                                     Odometry, self.odom_callback,
                                     queue_size=1)

        self.laser = rospy.Subscriber("/%s/front_laser/scan" % self.name,
                                      LaserScan, self.laser_callback,
                                      queue_size=1)

        self.camera = rospy.Subscriber("/%s/front_camera/image_raw" % self.name,
                                       Image, self.camera_callback,
                                       queue_size=1)

        self.pose_data = None
        self.laser_data = None
        self.camera_data = None

        self.cv_bridge = cv_bridge.CvBridge()

        self.rate = rospy.Rate(10)
        self.rate.sleep()
项目:ab2016-ros-gazebo    作者:akademikbilisim    | 项目源码 | 文件源码
def set_speed(self, linear, angular):
        movecmd = Twist()
        movecmd.linear.x = linear
        movecmd.angular.z = angular
        self.cmd_vel.publish(movecmd)
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def __init__(self):
        rospy.init_node('nav_asr', anonymous = True)
        rospy.Subscriber("/recognizer/output", String, self.SpeechUpdateGoal)
        rospy.Subscriber("/WPsOK", String, self.GetWayPoints)

        self.waypoint_list     = dict()
        self.marker_list       = list()
        self.makerArray        = MarkerArray()

        self.makerArray_pub    = rospy.Publisher("Waypoint_Array",MarkerArray,queue_size=5)

        rospy.on_shutdown(self.shutdown) # @@@@
        # How long in seconds should the robot pause at each location?
        self.rest_time = rospy.get_param("~rest_time", 2)
        # Are we running in the fake simulator?
        self.fake_test = rospy.get_param("~fake_test", True)
        # Publisher to manually control the robot (e.g. to stop it, queue_size=5)
        self.cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=5)
        # Subscribe to the move_base action server
        self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction)
        rospy.loginfo("Waiting for move_base action server...")
        # Wait 60 seconds for the action server to become available
        self.move_base.wait_for_server(rospy.Duration(60))
        rospy.loginfo("Connected to move base server")

    # Create the waypoints list from txt
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def shutdown(self):
        rospy.loginfo("Stopping the robot...")
        self.move_base.cancel_goal()
        rospy.sleep(2)
        self.cmd_vel_pub.publish(Twist())
        rospy.sleep(1)
项目:nao_slam_amcl    作者:hu7241    | 项目源码 | 文件源码
def shutdown(self):
        rospy.loginfo("Stopping the robot...")
        self.move_base.cancel_goal()
        rospy.sleep(2)
        self.cmd_vel_pub.publish(Twist())
        rospy.sleep(1)
项目:ai-bs-summer17    作者:uchibe    | 项目源码 | 文件源码
def __init__(self):

        self.force_reset = True
        self.vel_pub = rospy.Publisher('/mobile_base/commands/velocity', Twist, queue_size=5)
        self.unpause = rospy.ServiceProxy('/gazebo/unpause_physics', Empty)
        self.pause = rospy.ServiceProxy('/gazebo/pause_physics', Empty)
        self.reset_proxy = rospy.ServiceProxy('/gazebo/reset_simulation', Empty)

        self.img_rows = 32
        self.img_cols = 32
        self.img_channels = 1
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def myround(x):
    return int(round(x) - .5) + (x > 0)

# Author: Andrew Dai
# This ROS Node converts Joystick inputs from the joy node
# into commands for turtlesim

# Receives joystick messages (subscribed to Joy topic)
# then converts the joysick inputs into Twist commands
# axis 1 aka left stick vertical controls linear speed
# axis 0 aka left stick horizonal controls angular speed
项目:amosero    作者:PaulPetring    | 项目源码 | 文件源码
def myround(x):
    return int(round(x) - .5) + (x > 0)

# Author: Andrew Dai
# This ROS Node converts Joystick inputs from the joy node
# into commands for turtlesim

# Receives joystick messages (subscribed to Joy topic)
# then converts the joysick inputs into Twist commands
# axis 1 aka left stick vertical controls linear speed
# axis 0 aka left stick horizonal controls angular speed