本文整理匯總了Python中std_msgs.msg.Int32方法的典型用法代碼示例。如果您正苦於以下問題:Python msg.Int32方法的具體用法?Python msg.Int32怎麽用?Python msg.Int32使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類std_msgs.msg
的用法示例。
在下文中一共展示了msg.Int32方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: listener
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def listener():
global obj
global pub
rospy.loginfo("Starting prediction node")
rospy.init_node('listener', anonymous = True)
rospy.Subscriber("sensor_read", Int32, read_sensor_data)
pub = rospy.Publisher('predict', Int32, queue_size=1)
obj = Classify_Data()
obj.read_file('pos_readings.csv')
obj.train()
rospy.spin()
示例2: start_ros_subscribers
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def start_ros_subscribers(self):
self.joint_state_sub = rospy.Subscriber('/joint_states', JointState, self.sub_joint_states)
self.robot_state_sub = rospy.Subscriber('/niryo_one/robot_state', RobotState, self.sub_robot_state)
self.selected_tool_id_sub = rospy.Subscriber('/niryo_one/current_tool_id', Int32, self.sub_selected_tool_id)
self.learning_mode_sub = rospy.Subscriber('/niryo_one/learning_mode', Bool, self.sub_learning_mode)
self.joystick_enabled_sub = rospy.Subscriber('/niryo_one/joystick_interface/is_enabled', Bool,
self.sub_joystick_enabled)
self.hardware_status_sub = rospy.Subscriber('/niryo_one/hardware_status', HardwareStatus,
self.sub_hardware_status)
self.ros_log_status_sub = rospy.Subscriber('/niryo_one/rpi/ros_log_status', LogStatus, self.sub_ros_log_status)
self.software_version_sub = rospy.Subscriber('/niryo_one/software_version', SoftwareVersion,
self.sub_software_version)
rospy.Subscriber('/niryo_one/kits/conveyor_1_feedback', ConveyorFeedback,
self.sub_conveyor_1_feedback)
rospy.Subscriber('/niryo_one/kits/conveyor_2_feedback', ConveyorFeedback,
self.sub_conveyor_2_feedback)
示例3: __init__
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def __init__(self, ros_command_interface):
self.ros_command_interface = ros_command_interface
self.server = actionlib.SimpleActionServer(
'niryo_one/tool_action', ToolAction, self.tool_on_goal, False)
self.change_tool_server = rospy.Service(
'niryo_one/change_tool', SetInt, self.callback_change_tool)
self.current_tool_id_publisher = rospy.Publisher(
'/niryo_one/current_tool_id', Int32, queue_size=1)
rospy.Timer(rospy.Duration(1 / 1.0), self.publish_current_tool_id)
self.current_tool = None
self.available_tools = None
self.command_list = None
self.create_tools()
示例4: send_data
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def send_data():
rospy.init_node('virtual_sensor', anonymous=True)
rospy.loginfo("Sending virtual sensor data")
pub = rospy.Publisher('sensor_read', Int32, queue_size=1)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
sensor_reading = random.randint(0,30000)
pub.publish(sensor_reading)
rate.sleep()
示例5: publish_arm_max_velocity_scaling_factor
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def publish_arm_max_velocity_scaling_factor(self, event):
msg = Int32()
msg.data = self.max_velocity_scaling_factor
self.max_velocity_scaling_factor_pub.publish(msg)
示例6: __init__
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def __init__(self, sequence_manager):
self.server = actionlib.ActionServer('niryo_one/sequences/execute',
SequenceAction, self.on_goal, self.on_cancel, auto_start=False)
self.seq_code_executor = SequenceCodeExecutor()
self.current_goal_handle = None
self.seq_manager = sequence_manager
self.break_point_subscriber = rospy.Subscriber("/niryo_one/blockly/break_point", Int32,
self.callback_break_point)
示例7: break_point
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def break_point(self):
msg = Int32()
msg.data = 1
self.break_point_publisher.publish(msg)
# This delay makes sure the program has time
# to stop, before executing next command
rospy.sleep(0.5)
示例8: publish_current_tool_id
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def publish_current_tool_id(self, event):
msg = Int32()
if self.current_tool:
msg.data = self.current_tool.id
else:
msg.data = 0
self.current_tool_id_publisher.publish(msg)
示例9: __init__
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def __init__(self):
self.pin = BUTTON_GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
rospy.loginfo("GPIO setup : " + str(self.pin) + " as input")
rospy.sleep(0.1)
self.last_state = self.read_value()
self.consecutive_pressed = 0
self.activated = True
self.timer_frequency = 20.0
self.shutdown_action = False
self.hotspot_action = False
self.button_mode = ButtonMode.TRIGGER_SEQUENCE_AUTORUN
self.change_button_mode_server = rospy.Service(
"/niryo_one/rpi/change_button_mode", SetInt, self.callback_change_button_mode)
self.monitor_button_mode_timer = rospy.Timer(rospy.Duration(3.0), self.monitor_button_mode)
self.last_time_button_mode_changed = rospy.Time.now()
# Publisher used to send info to Niryo One Studio, so the user can add a move block
# by pressing the button
self.save_point_publisher = rospy.Publisher(
"/niryo_one/blockly/save_current_point", Int32, queue_size=10)
self.button_state_publisher = rospy.Publisher(
"/niryo_one/rpi/is_button_pressed", Bool, queue_size=10)
self.button_timer = rospy.Timer(rospy.Duration(1.0 / self.timer_frequency), self.check_button)
rospy.on_shutdown(self.shutdown)
rospy.loginfo("Niryo One Button started")
示例10: __init__
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def __init__(self):
'''
Constructor
'''
self._sm = None
smach.set_loggers (
rospy.logdebug, # hide SMACH transition log spamming
rospy.logwarn,
rospy.logdebug,
rospy.logerr
)
# set up proxys for sm <--> GUI communication
# publish topics
self._pub = ProxyPublisher({'flexbe/behavior_update': String,
'flexbe/request_mirror_structure': Int32})
self._running = False
self._stopping = False
self._active_id = 0
self._starting_path = None
self._current_struct = None
self._sync_lock = threading.Lock()
self._outcome_topic = 'flexbe/mirror/outcome'
self._struct_buffer = list()
# listen for mirror message
self._sub = ProxySubscriberCached()
self._sub.subscribe(self._outcome_topic, UInt8)
self._sub.enable_buffer(self._outcome_topic)
self._sub.subscribe('flexbe/mirror/structure', ContainerStructure, self._mirror_callback)
self._sub.subscribe('flexbe/status', BEStatus, self._status_callback)
self._sub.subscribe('flexbe/mirror/sync', BehaviorSync, self._sync_callback)
self._sub.subscribe('flexbe/mirror/preempt', Empty, self._preempt_callback)
示例11: _start_mirror
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def _start_mirror(self, msg):
with self._sync_lock:
rate = rospy.Rate(10)
while self._stopping:
rate.sleep()
if self._running:
rospy.logwarn('Tried to start mirror while it is already running, will ignore.')
return
if len(msg.args) > 0:
self._starting_path = "/" + msg.args[0][1:].replace("/", "_mirror/") + "_mirror"
self._active_id = msg.behavior_id
while self._sm is None and len(self._struct_buffer) > 0:
struct = self._struct_buffer[0]
self._struct_buffer = self._struct_buffer[1:]
if struct.behavior_id == self._active_id:
self._mirror_state_machine(struct)
rospy.loginfo('Mirror built.')
else:
rospy.logwarn('Discarded mismatching buffered structure for checksum %s' % str(struct.behavior_id))
if self._sm is None:
rospy.logwarn('Missing correct mirror structure, requesting...')
rospy.sleep(0.2) # no clean wayacquire to wait for publisher to be ready...
self._pub.publish('flexbe/request_mirror_structure', Int32(msg.behavior_id))
self._active_id = msg.behavior_id
return
self._execute_mirror()
示例12: confirm
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def confirm(self, name, id):
"""
Confirms the state machine and triggers the creation of the structural message.
It is mandatory to call this function at the top-level state machine
between building it and starting its execution.
@type name: string
@param name: The name of this state machine to identify it.
"""
self.name = name
self.id = id
self._pub.createPublisher('flexbe/mirror/sync', BehaviorSync, _latch = True) # Update mirror with currently active state (high bandwidth mode)
self._pub.createPublisher('flexbe/mirror/preempt', Empty, _latch = True) # Preempts the mirror
self._pub.createPublisher('flexbe/mirror/structure', ContainerStructure) # Sends the current structure to the mirror
self._pub.createPublisher('flexbe/log', BehaviorLog) # Topic for logs to the GUI
self._pub.createPublisher('flexbe/command_feedback', CommandFeedback) # Gives feedback about executed commands to the GUI
self._sub.subscribe('flexbe/command/autonomy', UInt8, self._set_autonomy_level)
self._sub.subscribe('flexbe/command/sync', Empty, self._sync_callback)
self._sub.subscribe('flexbe/command/attach', UInt8, self._attach_callback)
self._sub.subscribe('flexbe/request_mirror_structure', Int32, self._mirror_structure_callback)
StateLogger.initialize(name)
StateLogger.log('flexbe.initialize', None, behavior=name, autonomy=OperatableStateMachine.autonomy_level)
if OperatableStateMachine.autonomy_level != 255:
self._enable_ros_control()
rospy.sleep(0.5) # no clean way to wait for publisher to be ready...
self._notify_start()
示例13: callback
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def callback(msg):
doubled = Int32()
doubled.data = msg.data * 2
pub.publish(doubled)
示例14: __init__
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def __init__(self):
rospy.on_shutdown(self.on_shutdown)
self.update_rate = rospy.get_param("~update_rate", 10.0)
self.sensor_frame_id = rospy.get_param("~sensor_frame_id", "respeaker_base")
self.doa_xy_offset = rospy.get_param("~doa_xy_offset", 0.0)
self.doa_yaw_offset = rospy.get_param("~doa_yaw_offset", 90.0)
self.speech_prefetch = rospy.get_param("~speech_prefetch", 0.5)
self.speech_continuation = rospy.get_param("~speech_continuation", 0.5)
self.speech_max_duration = rospy.get_param("~speech_max_duration", 7.0)
self.speech_min_duration = rospy.get_param("~speech_min_duration", 0.1)
self.main_channel = rospy.get_param('~main_channel', 0)
suppress_pyaudio_error = rospy.get_param("~suppress_pyaudio_error", True)
#
self.respeaker = RespeakerInterface()
self.respeaker_audio = RespeakerAudio(self.on_audio, suppress_error=suppress_pyaudio_error)
self.speech_audio_buffer = str()
self.is_speeching = False
self.speech_stopped = rospy.Time(0)
self.prev_is_voice = None
self.prev_doa = None
# advertise
self.pub_vad = rospy.Publisher("is_speeching", Bool, queue_size=1, latch=True)
self.pub_doa_raw = rospy.Publisher("sound_direction", Int32, queue_size=1, latch=True)
self.pub_doa = rospy.Publisher("sound_localization", PoseStamped, queue_size=1, latch=True)
self.pub_audio = rospy.Publisher("audio", AudioData, queue_size=10)
self.pub_speech_audio = rospy.Publisher("speech_audio", AudioData, queue_size=10)
self.pub_audios = {c:rospy.Publisher('audio/channel%d' % c, AudioData, queue_size=10) for c in self.respeaker_audio.channels}
# init config
self.config = None
self.dyn_srv = Server(RespeakerConfig, self.on_config)
# start
self.speech_prefetch_bytes = int(
self.speech_prefetch * self.respeaker_audio.rate * self.respeaker_audio.bitdepth / 8.0)
self.speech_prefetch_buffer = str()
self.respeaker_audio.start()
self.info_timer = rospy.Timer(rospy.Duration(1.0 / self.update_rate),
self.on_timer)
self.timer_led = None
self.sub_led = rospy.Subscriber("status_led", ColorRGBA, self.on_status_led)
示例15: __init__
# 需要導入模塊: from std_msgs import msg [as 別名]
# 或者: from std_msgs.msg import Int32 [as 別名]
def __init__(self):
# The OpenCog API. This is used to send face data to OpenCog.
self.atomo = AtomicMsgs()
self.atomo.create_face_octomap()
# List of currently visible faces
self.visible_faces = []
# Subscribed pi_vision topics and events
self.TOPIC_FACE_EVENT = "/camera/face_event"
self.EVENT_NEW_FACE = "new_face"
self.EVENT_LOST_FACE = "lost_face"
self.EVENT_RECOGNIZED_FACE = "recognized_face"
# Overrides current face being tracked by WebUI
self.EVENT_TRACK_FACE = "track_face"
self.TOPIC_FACE_LOCATIONS = "/camera/face_locations"
# Face appearance/disappearance from pi_vision
rospy.Subscriber(self.TOPIC_FACE_EVENT, FaceEvent, self.face_event_cb)
# Face location information from pi_vision
rospy.Subscriber(self.TOPIC_FACE_LOCATIONS, Faces, self.face_loc_cb)
rospy.Subscriber("/behavior_control", Int32, self.behavior_control_cb)
# Control Eyes and face by default
self.control_mode = 255
# ----------------------------------------------------------
# Start tracking a face