本文整理汇总了Python中std_msgs.msg.Float32方法的典型用法代码示例。如果您正苦于以下问题:Python msg.Float32方法的具体用法?Python msg.Float32怎么用?Python msg.Float32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std_msgs.msg
的用法示例。
在下文中一共展示了msg.Float32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self):
#############################################################
rospy.init_node("twist_to_motors")
nodename = rospy.get_name()
rospy.loginfo("%s started" % nodename)
self.w = rospy.get_param("~base_width", 0.2)
self.pub_lmotor = rospy.Publisher('lwheel_vtarget', Float32, queue_size=10)
self.pub_rmotor = rospy.Publisher('rwheel_vtarget', Float32, queue_size=10)
rospy.Subscriber('twist', Twist, self.twistCallback)
self.rate = rospy.get_param("~rate", 50)
self.timeout_ticks = rospy.get_param("~timeout_ticks", 2)
self.left = 0
self.right = 0
#############################################################
示例2: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self):
#############################################################
rospy.init_node("twist_to_motors")
nodename = rospy.get_name()
rospy.loginfo("%s started" % nodename)
self.w = rospy.get_param("~base_width", 0.2)
self.pub_lmotor = rospy.Publisher('lwheel_vtarget', Float32,queue_size=10)
self.pub_rmotor = rospy.Publisher('rwheel_vtarget', Float32,queue_size=10)
rospy.Subscriber('cmd_vel_mux/input/teleop', Twist, self.twistCallback)
self.rate = rospy.get_param("~rate", 50)
self.timeout_ticks = rospy.get_param("~timeout_ticks", 2)
self.left = 0
self.right = 0
#############################################################
示例3: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self):
#############################################################
rospy.init_node("twist_to_motors")
nodename = rospy.get_name()
rospy.loginfo("%s started" % nodename)
self.w = rospy.get_param("~base_width", 0.2)
self.pub_lmotor = rospy.Publisher('lwheel_vtarget', Float32,queue_size=10)
self.pub_rmotor = rospy.Publisher('rwheel_vtarget', Float32,queue_size=10)
rospy.Subscriber('cmd_vel', Twist, self.twistCallback)
self.rate = rospy.get_param("~rate", 50)
self.timeout_ticks = rospy.get_param("~timeout_ticks", 2)
self.left = 0
self.right = 0
#############################################################
开发者ID:PacktPublishing,项目名称:Learning-Robotics-using-Python-Second-Edition,代码行数:21,代码来源:twist_to_motors.py
示例4: start_mpc_node
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def start_mpc_node():
rospy.init_node("dbw_mpc_pf")
acc_pub = rospy.Publisher("/control/accel", Float32Msg, queue_size=2)
steer_pub = rospy.Publisher("/control/steer_angle", Float32Msg, queue_size=2)
acc_enable_pub = rospy.Publisher("/control/enable_accel", UInt8Msg, queue_size=2, latch=True)
steer_enable_pub = rospy.Publisher("/control/enable_spas", UInt8Msg, queue_size=2, latch=True)
mpc_path_pub = rospy.Publisher("mpc_path", mpc_path, queue_size=2)
sub_state = rospy.Subscriber("state_est", state_est, state_est_callback, queue_size=2)
# Start up Ipopt/Solver.
for i in range(3):
kmpc.solve_model()
acc_enable_pub.publish(UInt8Msg(2))
steer_enable_pub.publish(UInt8Msg(1))
pub_loop(acc_pub, steer_pub, mpc_path_pub)
示例5: run
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def run(self):
rospy.init_node(self.config.name, anonymous=True, disable_signals=True)
rospy.Subscriber(self._topic_name, PoseStamped, self.on_pose_update)
rospy.Subscriber('/estimated_vel_mps', Float32,
self.on_velocity_update)
rospy.spin()
示例6: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self, name, objective_function, init_state, objectives, weight_funcs, weight_priors, constraints=(), bounds=(), unconstrained=False):
self.name = name
self.objective_function = objective_function
self.init_state = init_state
self.objectives = objectives
self.weight_funcs = weight_funcs
self.weight_priors = weight_priors
self.constraints = constraints
self.bounds = bounds
self.vel_objectives_on = True
self.objective_publishers = []
self.constraint_publishers = []
self.weight_func_publishers = []
self.f_obj_publisher = rospy.Publisher(self.name + '_f_obj', Float32, queue_size=5)
self.__populate_publishers()
self.xopt = init_state
self.prev_state = init_state
self.prev_state2 = init_state
self.prev_state3 = init_state
self.f_obj = 0.0
self.unconstrained = unconstrained
self.all_states = []
示例7: __populate_publishers
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __populate_publishers(self):
for o in self.objectives:
self.objective_publishers.append(rospy.Publisher('/objective/' + o.name(), Float32, queue_size=5))
for c in self.constraints:
self.constraint_publishers.append(rospy.Publisher('/constraint/' + c.name(), Float32, queue_size=5))
for wf in self.weight_funcs:
self.weight_func_publishers.append(rospy.Publisher('/weight_function/' + wf.name(), Float32, queue_size=5))
示例8: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self, name, pid):
self.name = name
self.proc = psutil.Process(pid)
self.cpu_publisher = rospy.Publisher(ns_join("cpu_monitor", name[1:], "cpu"), Float32, queue_size=20)
self.mem_publisher = rospy.Publisher(ns_join("cpu_monitor", name[1:], "mem"), UInt64, queue_size=20)
示例9: publish
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def publish(self):
self.cpu_publisher.publish(Float32(self.proc.cpu_percent()))
self.mem_publisher.publish(UInt64(self.proc.memory_info().rss))
示例10: move_head
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def move_head(ctx: rs.ContextWrapper):
for axis, lower, upper in [(prop_head_axis0, ctx.conf(key=AXIS0_LOWER_LIMIT_KEY), ctx.conf(key=AXIS0_UPPER_LIMIT_KEY)),
(prop_head_axis1, ctx.conf(key=AXIS1_LOWER_LIMIT_KEY), ctx.conf(key=AXIS1_UPPER_LIMIT_KEY)),
(prop_head_axis2, ctx.conf(key=AXIS2_LOWER_LIMIT_KEY), ctx.conf(key=AXIS2_UPPER_LIMIT_KEY))]:
data = random.uniform(lower, upper)
if random.random() < ctx.conf(key=HEAD_MOVEMENT_PROBABILITY_KEY): # move or don't move axis with probability
logger.info(f"Publishing {data} to {axis.topic}")
ctx[axis] = Float32(data=data)
示例11: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self):
rospy.init_node('vehicle_simulator', anonymous=True)
rospy.Subscriber('/control/accel', float_msg, self._acc_cmd_callback, queue_size=1)
rospy.Subscriber('/control/steer_angle', float_msg, self._df_cmd_callback, queue_size=1)
self.state_pub = rospy.Publisher('state_est', state_est, queue_size=1)
self.tcmd_a = None # rostime (s) of received acc command
self.tcmd_d = None # rostime (s) of received df command
self.acc = 0.0 # actual acceleration (m/s^2)
self.df = 0.0 # actual steering angle (rad)
self.acc_des = 0.0 # desired acceleration (m/s^2)
self.df_des = 0.0 # desired steering_angle (rad)
self.dt_model = 0.01 # vehicle model update period (s) and frequency (Hz)
self.hz = int(1.0/self.dt_model)
self.r = rospy.Rate(self.hz)
# Simulated Vehicle State.
self.X = rospy.get_param('X0', -300.0) # X position (m)
self.Y = rospy.get_param('Y0', -450.0) # Y position (m)
self.psi = rospy.get_param('Psi0', 1.0) # yaw angle (rad)
self.vx = rospy.get_param('V0', 0.0) # longitudinal velocity (m/s)
self.vy = 0.0 # lateral velocity (m/s)
self.wz = 0.0 # yaw rate (rad/s)
self.acc_time_constant = 0.4 # s
self.df_time_constant = 0.1 # s
self.pub_loop()
示例12: speed_converter
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
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()
示例13: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [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)
#####################################################
示例14: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self,speed,turn,resolution,reset_distance, rate, dvs_queue, resize_factor, crop):
self.dvs_sub = rospy.Subscriber('dvsData', Int8MultiArray, self.dvs_callback)
self.left_pub = rospy.Publisher('leftMotorSpeed', Float32, queue_size=1)
self.right_pub = rospy.Publisher('rightMotorSpeed', Float32, queue_size=1)
self.reset_pub = rospy.Publisher('resetRobot', Bool, queue_size=None)
self.v_forward = speed
self.v_turn = turn
self.resolution = resolution
self.reset_distance = reset_distance
self.dvs_queue = dvs_queue
self.fifo = deque(np.zeros((dvs_queue, resolution[0]*resolution[1])))
self.resize_factor = resize_factor
self.crop = crop
self.outer = False
rospy.init_node('dvs_controller')
self.rate = rospy.Rate(rate)
#Some values for calculating distance to center of lane
self.v1 = 2.5
self.v2 = 7.5
self.scale = 1.0
self.c1 = np.array([self.scale*self.v1,self.scale*self.v1])
self.c2 = np.array([self.scale*self.v2,self.scale*self.v2])
self.c3 = np.array([self.scale*self.v2,self.scale*self.v1])
self.c4 = np.array([self.scale*self.v1,self.scale*self.v2])
self.r1_outer = self.scale*(self.v1-0.25)
self.r2_outer = self.scale*(self.v1+0.25)
self.l1_outer = self.scale*(self.v1+self.v2-0.25)
self.l2_outer = self.scale*(0.25)
self.r1_inner = self.scale*(self.v1-0.75)
self.r2_inner = self.scale*(self.v1+0.75)
self.l1_inner = self.scale*(self.v1+self.v2-0.75)
self.l2_inner = self.scale*(0.75)
self.d1_outer = 5.0
self.d2_outer = 2*math.pi*self.r1_outer*0.25
self.d3_outer = 5.0
self.d4_outer = 2*math.pi*self.r1_outer*0.5
self.d5_outer = 2*math.pi*self.r2_outer*0.25
self.d6_outer = 2*math.pi*self.r1_outer*0.5
self.d1_inner = 5.0
self.d2_inner = 2*math.pi*self.r1_inner*0.25
self.d3_inner = 5.0
self.d4_inner = 2*math.pi*self.r1_inner*0.5
self.d5_inner = 2*math.pi*self.r2_inner*0.25
self.d6_inner = 2*math.pi*self.r1_inner*0.5
self.d_outer = self.d1_outer + self.d2_outer + self.d3_outer + self.d4_outer + self.d5_outer + self.d6_outer
self.d_inner = self.d1_inner + self.d2_inner + self.d3_inner + self.d4_inner + self.d5_inner + self.d6_inner
开发者ID:clamesc,项目名称:Training-Neural-Networks-for-Event-Based-End-to-End-Robot-Control,代码行数:49,代码来源:environment.py
示例15: __init__
# 需要导入模块: from std_msgs import msg [as 别名]
# 或者: from std_msgs.msg import Float32 [as 别名]
def __init__(self):
self.dvs_sub = rospy.Subscriber('dvsData', Int8MultiArray, self.dvs_callback)
self.pos_sub = rospy.Subscriber('transformData', Transform, self.pos_callback)
self.left_pub = rospy.Publisher('leftMotorSpeed', Float32, queue_size=1)
self.right_pub = rospy.Publisher('rightMotorSpeed', Float32, queue_size=1)
self.reset_pub = rospy.Publisher('resetRobot', Bool, queue_size=None)
self.dvs_data = np.array([0,0])
self.pos_data = []
self.distance = 0
self.steps = 0
self.v_pre = v_pre
self.turn_pre = turn_pre
self.resize_factor = [dvs_resolution[0]//resolution[0], (dvs_resolution[1]-crop_bottom-crop_top)//resolution[1]]
self.outer = False
rospy.init_node('dvs_controller')
self.rate = rospy.Rate(rate)
#Some values for calculating distance to center of lane
self.v1 = 2.5
self.v2 = 7.5
self.scale = 1.0
self.c1 = np.array([self.scale*self.v1,self.scale*self.v1])
self.c2 = np.array([self.scale*self.v2,self.scale*self.v2])
self.c3 = np.array([self.scale*self.v2,self.scale*self.v1])
self.c4 = np.array([self.scale*self.v1,self.scale*self.v2])
self.r1_outer = self.scale*(self.v1-0.25)
self.r2_outer = self.scale*(self.v1+0.25)
self.l1_outer = self.scale*(self.v1+self.v2-0.25)
self.l2_outer = self.scale*(0.25)
self.r1_inner = self.scale*(self.v1-0.75)
self.r2_inner = self.scale*(self.v1+0.75)
self.l1_inner = self.scale*(self.v1+self.v2-0.75)
self.l2_inner = self.scale*(0.75)
self.d1_outer = 5.0
self.d2_outer = 2*math.pi*self.r1_outer*0.25
self.d3_outer = 5.0
self.d4_outer = 2*math.pi*self.r1_outer*0.5
self.d5_outer = 2*math.pi*self.r2_outer*0.25
self.d6_outer = 2*math.pi*self.r1_outer*0.5
self.d1_inner = 5.0
self.d2_inner = 2*math.pi*self.r1_inner*0.25
self.d3_inner = 5.0
self.d4_inner = 2*math.pi*self.r1_inner*0.5
self.d5_inner = 2*math.pi*self.r2_inner*0.25
self.d6_inner = 2*math.pi*self.r1_inner*0.5
self.d_outer = self.d1_outer + self.d2_outer + self.d3_outer + self.d4_outer + self.d5_outer + self.d6_outer
self.d_inner = self.d1_inner + self.d2_inner + self.d3_inner + self.d4_inner + self.d5_inner + self.d6_inner
开发者ID:clamesc,项目名称:Training-Neural-Networks-for-Event-Based-End-to-End-Robot-Control,代码行数:49,代码来源:environment.py