本文整理汇总了Python中std_msgs.msg.Bool.data方法的典型用法代码示例。如果您正苦于以下问题:Python Bool.data方法的具体用法?Python Bool.data怎么用?Python Bool.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std_msgs.msg.Bool
的用法示例。
在下文中一共展示了Bool.data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: errorCheck
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def errorCheck(pub):
r = rospy.Rate(10)
global count
precount = 0
thread_unloop_count = 0
while True:
error_flag = Bool()
if (count - precount) > 0:
thread_unloop_count = 0
precount = count
elif (count - precount) == 0:
thread_unloop_count += 1
precount = count
else:
thread_unloop_count = 0
precount = 0
if thread_unloop_count > 2:
error_flag.data = True
print'********++++++++++------------------AMU is rebooting now!!------------------++++++++******'
else:
error_flag.data = False
#commented out by hagiwara 0224
#print'********++++++++++------------------AMU is OK!!------------------++++++++******'
pub.publish(error_flag)
r.sleep()
示例2: publishOrderBegun
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def publishOrderBegun():
pubBegunMsg = Bool()
if(orderProcess == True):
pubBegunMsg.data = 1
else:
pubBegunMsg.data = 0
global pubOrderBegun
pubOrderBegun.publish(pubBegunMsg)
示例3: run_dryer
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def run_dryer(self, run_it=True):
cmd = Bool()
if run_it == True:
cmd.data = True
else:
cmd.data = False
"Updating dryer"
self.dryer_pub.publish(cmd)
示例4: pauseSystem
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def pauseSystem(self, pausing):
learningStatus = Bool()
controlStatus = Bool()
if not pausing:
self.expStatus = "monitor"
self.backToInit = not pausing
learningStatus.data = not pausing
self.learningMF_pub.publish(learningStatus)
self.learningMB_pub.publish(learningStatus)
self.learningMB2_pub.publish(learningStatus)
controlStatus.data = not pausing
self.control_pub.publish(controlStatus)
示例5: ft_sleeve_cb
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def ft_sleeve_cb(self, msg):
if not self.ft_sleeve_biased:
rospy.sleep(0.5)
self.time_since_last_cb = rospy.Time.now()
self.ft_sleeve_bias_x = msg.wrench.force.x
self.ft_sleeve_bias_y = msg.wrench.force.y
self.ft_sleeve_bias_z = msg.wrench.force.z
self.ft_sleeve_bias_t_x = msg.wrench.torque.x
self.ft_sleeve_bias_t_y = msg.wrench.torque.y
self.ft_sleeve_bias_t_z = msg.wrench.torque.z
self.ft_sleeve_biased = True
if rospy.Time.now().to_sec() - self.time_since_last_cb.to_sec() > 0.05:
print 'The force-torque sensor callback is too slow. That is potentially very bad. Aborting everything!!!'
self.z.estop()
self.z = None
self.time_since_last_cb = rospy.Time.now()
x_force = msg.wrench.force.x-self.ft_sleeve_bias_x
y_force = msg.wrench.force.y-self.ft_sleeve_bias_y
z_force = msg.wrench.force.z-self.ft_sleeve_bias_z
x_torque = msg.wrench.torque.x-self.ft_sleeve_bias_t_x
y_torque = msg.wrench.torque.y-self.ft_sleeve_bias_t_y
z_torque = msg.wrench.torque.z-self.ft_sleeve_bias_t_z
# pos = self.z.get_position()
if self.recording:
t = rospy.Time.now() - self.start_record_time
self.sleeve_file.write(''.join([str(t.to_sec()), ' %f %f %f %f %f %f %f \n' %
(self.zenither_pose,
x_force,
y_force,
z_force,
x_torque,
y_torque,
z_torque)]))
self.array_to_save[self.array_line] = [t.to_sec(), self.zenither_pose, x_force, y_force, z_force]
self.array_line += 1
if self.pulling:
threshold = self.pulling_force_threshold
else:
threshold = self.reset_force_threshold
# mag_force = np.linalg.norm(np.abs([x_force, y_force, z_force]))
if (np.linalg.norm(np.abs([x_force, y_force, z_force])) > threshold):
out = Bool()
out.data = True
self.force_threshold_exceeded_pub.publish(out)
else:
out = Bool()
out.data = False
self.output_stuck = 0
self.force_threshold_exceeded_pub.publish(out)
示例6: test1
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def test1(self):
msg = Bool()
msg.data = True
# wait until advertise and receive
time.sleep(0.5)
self._pub.publish(msg)
time.sleep(0.1)
self.assertTrue(self._true)
self.assertFalse(self._false)
msg.data = False
self._pub.publish(msg)
time.sleep(0.1)
self.assertTrue(self._false)
self.assertFalse(self._true)
示例7: callback_manipulator
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def callback_manipulator(self, controller):
if controller.killswitch != self.controller.killswitch:
shut_down = Bool()
shut_down.data = self.controller.killswitch == 1
self.callback_auto_shut_down(shut_down)
self.controller = controller
self.send_manipulator = True
示例8: receive_1_cb
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def receive_1_cb(self, msg):
#print 'message received'
#print msg
im = self.br.imgmsg_to_cv2(msg, desired_encoding='passthrough')
for i in range(0, im.shape[0]):
for j in range(0, im.shape[1]):
#if not (im[i, j, 0] == 255 and im[i, j, 1] == 0 and im[i, j, 2] == 0):
if im[i, j, 0] == 255 and im[i, j, 1] == 0 and im[i, j, 2] == 0:
#print 'Detect an intruder!'
msg_sended = Bool()
msg_sended.data = True
send = FunctionUnit.create_send(self, self._send_topic, Bool)
send.send(msg_sended)
virtual_msg = Bool()
virtual_msg.data = False
self._virtual_send.send(virtual_msg)
示例9: model_stateCB
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def model_stateCB(self, msg):
if not self.active:
return
quaternion_msg = [msg.pose[1].orientation.x, msg.pose[1].orientation.y, msg.pose[1].orientation.z, msg.pose[1].orientation.w]
euler = tf.transformations.euler_from_quaternion(quaternion_msg)
self.robot_pose = (msg.pose[1].position.x, msg.pose[1].position.y, euler[2])
# print self.robot_pose
# print 'robot_pose:', self.robot_pose#, 'waypoints:', self.waypoints
self.destination_pose = self.circleIntersect(self.lookahead_distance)
if self.destination_pose == None:
self.active = False
print "approach destination "
self.gazebo_cmd(0,0)
msg = Bool()
msg.data = True
self.pub_finish.publish(msg)
else:
# print 'destination_pose:', self.destination_pose
# print 'waypoint_index:', self.current_waypoint_index
self.speed = self.default_speed
distance_to_destination= self.getDistance(self.robot_pose, self.destination_pose)
angle_to_destination = -self.getAngle(self.robot_pose, self.destination_pose)
# self.steering_angle = np.arctan((2 * self.robot_length * np.sin(angle_to_destination)) / distance_to_destination)
# print "robot_head",euler[2]*180/math.pi,"angle_to_destination", angle_to_destination*180/math.pi
w = (angle_to_destination + math.pi) / (2 * math.pi) - 0.5
self.gazebo_cmd(self.speed,w)
示例10: do_security
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def do_security():
global STATUS_LOCK, CAR_UPDATE_FLAG, CAMERA_UPDATE_FLAG
global CAMERA_CURRENT_TIME, CAR_CURRENT_TIME
global GLOBAL_MOVE_PUB, VEL_PUB
global NAV_FLAG_PUB, ENABLE_MOVE_FLAG, BAR_FLAG
time_now = rospy.Time.now()
STATUS_LOCK.acquire()
if CAR_UPDATE_FLAG:
time1_diff = time_now - CAR_CURRENT_TIME
if CAMERA_UPDATE_FLAG:
time2_diff = time_now - CAMERA_CURRENT_TIME
# 视觉丢失超时保险
# 里程计丢失超时保险
if (CAMERA_UPDATE_FLAG and time2_diff.to_sec() > 180 and not BAR_FLAG) or time1_diff.to_sec() > 5.:
# 发布全局禁止flag
global_move_flag = Bool()
global_move_flag.data = False
GLOBAL_MOVE_PUB.publish(global_move_flag)
car_twist = Twist()
VEL_PUB.publish(car_twist)
CAMERA_UPDATE_FLAG = False
CAR_UPDATE_FLAG = False
CAMERA_CURRENT_TIME = rospy.Time.now()
CAR_CURRENT_TIME = rospy.Time.now()
STATUS_LOCK.release()
示例11: talker
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def talker():
rospy.init_node("frobit_test_set_speed")
deadman_pub = rospy.Publisher("/fmSignals/deadman", Bool)
deadman = Bool()
cmd_vel_left_pub = rospy.Publisher("/fmSignals/cmd_vel_left", TwistStamped)
twist_left = TwistStamped()
cmd_vel_right_pub = rospy.Publisher("/fmSignals/cmd_vel_right", TwistStamped)
twist_right = TwistStamped()
r = rospy.Rate(node_upd_freq) # set talker update frequency
while not rospy.is_shutdown():
deadman.data = 1 # publish deadman topic
deadman_pub.publish(deadman)
twist_left.header.stamp = rospy.Time.now()
twist_left.twist.linear.x = spd_left
# publish cmd_vel topic for left wheel
cmd_vel_left_pub.publish(twist_left)
twist_right.header.stamp = rospy.Time.now()
twist_right.twist.linear.x = spd_right
# publish cmd_vel topic for right wheel
cmd_vel_right_pub.publish(twist_right)
r.sleep()
示例12: cbJoy
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def cbJoy(self, joy_msg):
model_state_msg = Twist()
model_state_msg.linear.x = joy_msg.axes[1] * self.v_gain
model_state_msg.linear.y = 0
model_state_msg.linear.z = 0
model_state_msg.angular.x = 0
model_state_msg.angular.y = 0
model_state_msg.angular.z = -joy_msg.axes[3] * self.w_gain
self.pub_gazebo.publish(model_state_msg)
model_state_msg.linear.x = 0
model_state_msg.angular.z = 0
if joy_msg.buttons[0] == 1:
model_state_msg.angular.z = -1
elif joy_msg.buttons[1] == 1:
model_state_msg.angular.z = 1
self.pub_gazebo_gripper.publish(model_state_msg)
if (joy_msg.buttons[7] == 1):
reset_msg = Bool()
reset_msg.data = True
self.pub_encoder_reset.publish(reset_msg)
示例13: status_updated_callback
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def status_updated_callback(self, msg): # GoalStatusArray
intermediate_statuses = [GoalStatus.PENDING, GoalStatus.ACTIVE, GoalStatus.RECALLING, GoalStatus.PREEMPTING]
for goal in msg.status_list:
# status = GoalManager.status_list[goal.status]
# rospy.logerr("Goal %s. %s" % (status, goal.text))
goal_idx = self.get_index_of(goal.goal_id.id)
if goal.status == GoalStatus.SUCCEEDED: # do a little dance to celebrate
rospy.loginfo("Goal %s reached!" % goal.goal_id.id)
last_goal_reached = Bool()
last_goal_reached.data = not self.loop_goals and goal_idx + 1 == len(self.goals)
self.done_pub.publish(last_goal_reached)
self.wait_for_goal()
if goal_idx + 1 == len(self.goals):
if self.loop_goals:
rospy.loginfo("Now looping back to first goal")
self.reset_goal_list()
self.next_goal()
else:
self.next_goal(goal_idx + 1)
elif goal.status in intermediate_statuses: # transitional state, so just wait
pass
elif goal.status == GoalStatus.PREEMPTED:
rospy.logwarn("Goal %s was preempted. %s" % (goal.goal_id.id, goal.text))
else: # the robot's dead
status = GoalManager.status_list[goal.status]
rospy.logerr("Goal %s %s. %s" % (goal.goal_id.id, status, goal.text))
示例14: newSample
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def newSample(self, msg):
newFFT = self.stft.ingestSample(msg.data)
if newFFT is not None:
self.FFT = newFFT
# Mask and average data
guard1 = np.mean(newFFT[self.G1_mask, :][:, self.channel_mask])
alpha = np.mean(newFFT[self.Al_mask, :][:, self.channel_mask])
guard2 = np.mean(newFFT[self.G2_mask, :][:, self.channel_mask])
detected = self.movavg.step(alpha > (guard1 + guard2)*1.1) > 0.5
if detected and not self.ignore.test():
self.movavg.reset()
self.ignore.reset(4)
else:
detected = False
# Publish messages
msg = Float32()
msg.data = guard1
self.pub_guard1.publish(msg)
msg = Float32()
msg.data = alpha
self.pub_alpha.publish(msg)
msg = Float32()
msg.data = guard2
self.pub_guard2.publish(msg)
msg = Bool()
msg.data = detected
self.pub_eyes.publish(msg)
示例15: model_stateCB
# 需要导入模块: from std_msgs.msg import Bool [as 别名]
# 或者: from std_msgs.msg.Bool import data [as 别名]
def model_stateCB(self, msg):
if not self.active:
return
quaternion_msg = [msg.pose[1].orientation.x, msg.pose[1].orientation.y, msg.pose[1].orientation.z, msg.pose[1].orientation.w]
euler = tf.transformations.euler_from_quaternion(quaternion_msg)
self.robot_pose = (msg.pose[1].position.x, msg.pose[1].position.y, euler[2])
distance_to_destination= self.getDistance(self.robot_pose, self.destination_pose)
angle_to_destination = -self.getAngle(self.robot_pose, self.destination_pose)
if angle_to_destination < 3 * (math.pi/180):
print "correct straight line"
if distance_to_destination<= self.threshold_proximity:
print "ready to grab"
self.gazebo_cmd(0,0)
self.active = False
self.gripper_cmd(0,0.5)
msg = Bool()
msg.data = True
self.pub_grab_object.publish(msg)
else:
self.gazebo_cmd(self.speed,0)
else:
print "correct orientation"
w = (angle_to_destination + math.pi) / (2 * math.pi) - 0.5
self.gazebo_cmd(0,w)