當前位置: 首頁>>代碼示例>>Python>>正文


Python msg.Int16方法代碼示例

本文整理匯總了Python中std_msgs.msg.Int16方法的典型用法代碼示例。如果您正苦於以下問題:Python msg.Int16方法的具體用法?Python msg.Int16怎麽用?Python msg.Int16使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在std_msgs.msg的用法示例。


在下文中一共展示了msg.Int16方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
    ###############################################
        rospy.init_node("wheel_loopback");
        self.nodename = rospy.get_name()
        rospy.loginfo("%s started" % self.nodename)
        
        self.rate = rospy.get_param("~rate", 200)
        self.timeout_secs = rospy.get_param("~timeout_secs", 0.5)
        self.ticks_meter = float(rospy.get_param('~ticks_meter', 50))
        self.velocity_scale = float(rospy.get_param('~velocity_scale', 255))
        self.latest_motor = 0
        
        self.wheel = 0
        
        rospy.Subscriber('motor', Int16, self.motor_callback)
        
        self.pub_wheel = rospy.Publisher('wheel', Int16, queue_size=10)
        
    ############################################### 
開發者ID:jfstepha,項目名稱:differential-drive,代碼行數:21,代碼來源:wheel_loopback.py

示例2: scaleWheel

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def scaleWheel():
    rospy.init_node("wheel_scaler")
    rospy.loginfo("wheel_scaler started")
    
    scale = rospy.get_param('distance_scale', 1)
    rospy.loginfo("wheel_scaler scale: %0.2f", scale)
    
    rospy.Subscriber("lwheel", Int16, lwheelCallback)
    rospy.Subscriber("rwheel", Int16, rwheelCallback)
    
    lscaled_pub = rospy.Publisher("lwheel_scaled", Int16, queue_size=10)
    rscaled_pub = rospy.Publisher("rwheel_scaled", Int16, queue_size=10) 
    
    ### testing sleep CPU usage
    r = rospy.Rate(50) 
    while not rospy.is_shutdown:
        r.sleep()
        
    rospy.spin() 
開發者ID:jfstepha,項目名稱:differential-drive,代碼行數:21,代碼來源:wheel_scaler.py

示例3: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
    ###############################################
        rospy.init_node("wheel_loopback");
        self.nodename = rospy.get_name()
        rospy.loginfo("%s started" % self.nodename)
        
        self.rate = rospy.get_param("~rate", 200)
        self.timeout_secs = rospy.get_param("~timeout_secs", 0.5)
        self.ticks_meter = float(rospy.get_param('~ticks_meter', 50))
        self.velocity_scale = float(rospy.get_param('~velocity_scale', 255))
        self.latest_motor = 0
        
        self.wheel = 0
        
        rospy.Subscriber('motor', Int16, self.motor_callback)
        
        self.pub_wheel = rospy.Publisher('wheel', Int16,queue_size=10)
        
    ############################################### 
開發者ID:PacktPublishing,項目名稱:ROS-Programming-Building-Powerful-Robots,代碼行數:21,代碼來源:wheel_loopback.py

示例4: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
        self._cv_bridge = CvBridge()

        self.x = tf.placeholder(tf.float32, [None,28,28,1], name="x")
        self.keep_prob = tf.placeholder("float")
        self.y_conv = makeCNN(self.x,self.keep_prob)

        self._saver = tf.train.Saver()
        self._session = tf.InteractiveSession()
        
        init_op = tf.global_variables_initializer()
        self._session.run(init_op)

        ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
        PATH_TO_CKPT = ROOT_PATH + '/include/mnist/model.ckpt'
        self._saver.restore(self._session, PATH_TO_CKPT)

        self._sub = rospy.Subscriber('usb_cam/image_raw', Image, self.callback, queue_size=1)
        self._pub = rospy.Publisher('/result_ripe', Int16, queue_size=1) 
開發者ID:cong,項目名稱:ros_tensorflow,代碼行數:21,代碼來源:ros_tensorflow_mnist.py

示例5: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
        self._cv_bridge = CvBridge()

        self.x = tf.placeholder(tf.float32, [None,28,28,1], name="x")
        self.keep_prob = tf.placeholder("float")
        self.y_conv = makeCNN(self.x,self.keep_prob)

        self._saver = tf.train.Saver()
        self._session = tf.InteractiveSession()
        
        init_op = tf.global_variables_initializer()
        self._session.run(init_op)

        self._saver.restore(self._session, "model/model.ckpt")

        self._sub = rospy.Subscriber('image', Image, self.callback, queue_size=1)
        self._pub = rospy.Publisher('result', Int16, queue_size=1) 
開發者ID:shunchan0677,項目名稱:Tensorflow_in_ROS,代碼行數:19,代碼來源:tensorflow_in_ros_mnist.py

示例6: listener

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def listener():
    rospy.init_node('serial_adapter', anonymous=True)
    # Declare the Subscriber to motors orders
    rospy.Subscriber("arduino/servo", Int16, servoCallback, queue_size=2)
    rospy.Subscriber("arduino/motor", Int8, motorCallback, queue_size=2)
    rospy.spin() 
開發者ID:sergionr2,項目名稱:RacingRobot,代碼行數:8,代碼來源:serial_adapter.py

示例7: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
        self._cv_bridge = CvBridge()
        self._sub = rospy.Subscriber('usb_cam/image_raw', Image, self.callback, queue_size=1, buff_size=2**24)
        print('Image converter constructor ')
        self._pub = rospy.Publisher("/result_ripe", Image, queue_size=0)
        #self._pub = rospy.Publisher('result', Int16, queue_size=1) 
開發者ID:cong,項目名稱:ros_tensorflow,代碼行數:8,代碼來源:ros_tensorflow_detect.py

示例8: __weight_increase_check

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __weight_increase_check(self):
        try:
            w = rospy.wait_for_message('/scales/weight', Int16, timeout=2).data
            increased = w > self.last_weight
            self.last_weight = w
            return increased
        except:
            return raw_input('No weight. Success? [1/0]') == '1' 
開發者ID:dougsm,項目名稱:mvp_grasp,代碼行數:10,代碼來源:panda_base_grasping_controller.py

示例9: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
    #############################################################################
        rospy.init_node("diff_tf")
        self.nodename = rospy.get_name()
        rospy.loginfo("-I- %s started" % self.nodename)
        
        #### parameters #######
        self.rate = rospy.get_param('~rate',10.0)  # the rate at which to publish the transform
        self.ticks_meter = float(rospy.get_param('ticks_meter', 50))  # The number of wheel encoder ticks per meter of travel
        self.base_width = float(rospy.get_param('~base_width', 0.245)) # The wheel base width in meters
        
        self.base_frame_id = rospy.get_param('~base_frame_id','base_link') # the name of the base frame of the robot
        self.odom_frame_id = rospy.get_param('~odom_frame_id', 'odom') # the name of the odometry reference frame
        
        self.encoder_min = rospy.get_param('encoder_min', -32768)
        self.encoder_max = rospy.get_param('encoder_max', 32768)
        self.encoder_low_wrap = rospy.get_param('wheel_low_wrap', (self.encoder_max - self.encoder_min) * 0.3 + self.encoder_min )
        self.encoder_high_wrap = rospy.get_param('wheel_high_wrap', (self.encoder_max - self.encoder_min) * 0.7 + self.encoder_min )
 
        self.t_delta = rospy.Duration(1.0/self.rate)
        self.t_next = rospy.Time.now() + self.t_delta
        
        # internal data
        self.enc_left = None        # wheel encoder readings
        self.enc_right = None
        self.left = 0               # actual values coming back from robot
        self.right = 0
        self.lmult = 0
        self.rmult = 0
        self.prev_lencoder = 0
        self.prev_rencoder = 0
        self.x = 0                  # position in xy plane 
        self.y = 0
        self.th = 0
        self.dx = 0                 # speeds in x/rotation
        self.dr = 0
        self.then = rospy.Time.now()
        
        # subscriptions
        rospy.Subscriber("lwheel", Int16, self.lwheelCallback)
        rospy.Subscriber("rwheel", Int16, self.rwheelCallback)
        self.odomPub = rospy.Publisher("odom", Odometry, queue_size=10)
        self.odomBroadcaster = TransformBroadcaster()
        
    ############################################################################# 
開發者ID:jfstepha,項目名稱:differential-drive,代碼行數:47,代碼來源:diff_tf.py

示例10: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
    #####################################################
        rospy.init_node("pid_velocity")
        self.nodename = rospy.get_name()
        rospy.loginfo("%s started" % self.nodename)
        
        ### initialize variables
        self.target = 0
        self.motor = 0
        self.vel = 0
        self.integral = 0
        self.error = 0
        self.derivative = 0
        self.previous_error = 0
        self.wheel_prev = 0
        self.wheel_latest = 0
        self.then = rospy.Time.now()
        self.wheel_mult = 0
        self.prev_encoder = 0
        
        ### get parameters #### 
        self.Kp = rospy.get_param('~Kp',10)
        self.Ki = rospy.get_param('~Ki',10)
        self.Kd = rospy.get_param('~Kd',0.001)
        self.out_min = rospy.get_param('~out_min',-255)
        self.out_max = rospy.get_param('~out_max',255)
        self.rate = rospy.get_param('~rate',30)
        self.rolling_pts = rospy.get_param('~rolling_pts',2)
        self.timeout_ticks = rospy.get_param('~timeout_ticks',4)
        self.ticks_per_meter = rospy.get_param('ticks_meter', 20)
        self.vel_threshold = rospy.get_param('~vel_threshold', 0.001)
        self.encoder_min = rospy.get_param('encoder_min', -32768)
        self.encoder_max = rospy.get_param('encoder_max', 32768)
        self.encoder_low_wrap = rospy.get_param('wheel_low_wrap', (self.encoder_max - self.encoder_min) * 0.3 + self.encoder_min )
        self.encoder_high_wrap = rospy.get_param('wheel_high_wrap', (self.encoder_max - self.encoder_min) * 0.7 + self.encoder_min )
        self.prev_vel = [0.0] * self.rolling_pts
        self.wheel_latest = 0.0
        self.prev_pid_time = rospy.Time.now()
        rospy.logdebug("%s got Kp:%0.3f Ki:%0.3f Kd:%0.3f tpm:%0.3f" % (self.nodename, self.Kp, self.Ki, self.Kd, self.ticks_per_meter))
        
        #### subscribers/publishers 
        rospy.Subscriber("wheel", Int16, self.wheelCallback) 
        rospy.Subscriber("wheel_vtarget", Float32, self.targetCallback) 
        self.pub_motor = rospy.Publisher('motor_cmd',Float32, queue_size=10) 
        self.pub_vel = rospy.Publisher('wheel_vel', Float32, queue_size=10)
   
        
    ##################################################### 
開發者ID:jfstepha,項目名稱:differential-drive,代碼行數:50,代碼來源:pid_velocity.py

示例11: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
    #####################################################
        rospy.init_node("lpid_velocity")
        self.nodename = rospy.get_name()
        rospy.loginfo("%s started" % self.nodename)
        
        ### initialize variables
        self.target = 0
        self.motor = 0
        self.vel = 0
        self.integral = 0
        self.error = 0
        self.derivative = 0
        self.previous_error = 0
        self.wheel_prev = 0
        self.wheel_latest = 0
        self.then = rospy.Time.now()
        self.wheel_mult = 0
        self.prev_encoder = 0
        
        ### get parameters #### 
        self.Kp = rospy.get_param('~Kp',10)
        self.Ki = rospy.get_param('~Ki',10)
        self.Kd = rospy.get_param('~Kd',0.001)
        self.out_min = rospy.get_param('~out_min',-255)
        self.out_max = rospy.get_param('~out_max',255)
        self.rate = rospy.get_param('~rate',30)
        self.rolling_pts = rospy.get_param('~rolling_pts',2)
        self.timeout_ticks = rospy.get_param('~timeout_ticks',4)
        self.ticks_per_meter = rospy.get_param('ticks_meter', 20)
        self.vel_threshold = rospy.get_param('~vel_threshold', 0.001)
        self.encoder_min = rospy.get_param('encoder_min', -32768)
        self.encoder_max = rospy.get_param('encoder_max', 32768)
        self.encoder_low_wrap = rospy.get_param('wheel_low_wrap', (self.encoder_max - self.encoder_min) * 0.3 + self.encoder_min )
        self.encoder_high_wrap = rospy.get_param('wheel_high_wrap', (self.encoder_max - self.encoder_min) * 0.7 + self.encoder_min )
        self.prev_vel = [0.0] * self.rolling_pts
        self.wheel_latest = 0.0
        self.prev_pid_time = rospy.Time.now()
        rospy.logdebug("%s got Kp:%0.3f Ki:%0.3f Kd:%0.3f tpm:%0.3f" % (self.nodename, self.Kp, self.Ki, self.Kd, self.ticks_per_meter))
        
        #### subscribers/publishers 
        rospy.Subscriber("wheel", Int16, self.wheelCallback) 
        rospy.Subscriber("wheel_vtarget", Float32, self.targetCallback) 
        self.pub_motor = rospy.Publisher('motor_cmd',Float32,queue_size=10) 
        self.pub_vel = rospy.Publisher('wheel_vel', Float32,queue_size=10)
   
        
    ##################################################### 
開發者ID:PacktPublishing,項目名稱:ROS-Programming-Building-Powerful-Robots,代碼行數:50,代碼來源:lpid_velocity.py

示例12: __init__

# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int16 [as 別名]
def __init__(self):
    #####################################################
        rospy.init_node("rpid_velocity")
        self.nodename = rospy.get_name()
        rospy.loginfo("%s started" % self.nodename)
        
        ### initialize variables
        self.target = 0
        self.motor = 0
        self.vel = 0
        self.integral = 0
        self.error = 0
        self.derivative = 0
        self.previous_error = 0
        self.wheel_prev = 0
        self.wheel_latest = 0
        self.then = rospy.Time.now()
        self.wheel_mult = 0
        self.prev_encoder = 0
        
        ### get parameters #### 
        self.Kp = rospy.get_param('~Kp',10)
        self.Ki = rospy.get_param('~Ki',10)
        self.Kd = rospy.get_param('~Kd',0.001)
        self.out_min = rospy.get_param('~out_min',-255)
        self.out_max = rospy.get_param('~out_max',255)
        self.rate = rospy.get_param('~rate',30)
        self.rolling_pts = rospy.get_param('~rolling_pts',2)
        self.timeout_ticks = rospy.get_param('~timeout_ticks',4)
        self.ticks_per_meter = rospy.get_param('ticks_meter', 20)
        self.vel_threshold = rospy.get_param('~vel_threshold', 0.001)
        self.encoder_min = rospy.get_param('encoder_min', -32768)
        self.encoder_max = rospy.get_param('encoder_max', 32768)
        self.encoder_low_wrap = rospy.get_param('wheel_low_wrap', (self.encoder_max - self.encoder_min) * 0.3 + self.encoder_min )
        self.encoder_high_wrap = rospy.get_param('wheel_high_wrap', (self.encoder_max - self.encoder_min) * 0.7 + self.encoder_min )
        self.prev_vel = [0.0] * self.rolling_pts
        self.wheel_latest = 0.0
        self.prev_pid_time = rospy.Time.now()
        rospy.logdebug("%s got Kp:%0.3f Ki:%0.3f Kd:%0.3f tpm:%0.3f" % (self.nodename, self.Kp, self.Ki, self.Kd, self.ticks_per_meter))
        
        #### subscribers/publishers 
        rospy.Subscriber("wheel", Int16, self.wheelCallback) 
        rospy.Subscriber("wheel_vtarget", Float32, self.targetCallback) 
        self.pub_motor = rospy.Publisher('motor_cmd',Float32,queue_size=10) 
        self.pub_vel = rospy.Publisher('wheel_vel', Float32,queue_size=10)
   
        
    ##################################################### 
開發者ID:PacktPublishing,項目名稱:ROS-Programming-Building-Powerful-Robots,代碼行數:50,代碼來源:rpid_velocity.py


注:本文中的std_msgs.msg.Int16方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。