本文整理匯總了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)
###############################################
示例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()
示例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)
###############################################
示例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)
示例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)
示例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()
示例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)
示例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'
示例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()
#############################################################################
示例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)
#####################################################
示例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)
#####################################################
示例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)
#####################################################