本文整理汇总了Python中rospy.is_shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python rospy.is_shutdown方法的具体用法?Python rospy.is_shutdown怎么用?Python rospy.is_shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rospy
的用法示例。
在下文中一共展示了rospy.is_shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def talker_ctrl():
global rate_value
# publishes to thruster and rudder topics
pub_motor = rospy.Publisher('thruster_command', JointState, queue_size=10)
pub_rudder = rospy.Publisher('joint_setpoint', JointState, queue_size=10)
rospy.init_node('usv_simple_ctrl', anonymous=True)
rate = rospy.Rate(rate_value) # 10h
# subscribe to state and targer point topics
rospy.Subscriber("state", Odometry, get_pose) # get usv position (add 'gps' position latter)
rospy.Subscriber("usv_position_setpoint", Odometry, get_target) # get target position
while not rospy.is_shutdown():
pub_motor.publish(thruster_ctrl_msg())
pub_rudder.publish(rudder_ctrl_msg())
rate.sleep()
示例2: spin
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def spin(self):
#############################################################
r = rospy.Rate(self.rate)
idle = rospy.Rate(10)
then = rospy.Time.now()
self.ticks_since_target = self.timeout_ticks
###### main loop ######
while not rospy.is_shutdown():
while not rospy.is_shutdown() and self.ticks_since_target < self.timeout_ticks:
self.spinOnce()
r.sleep()
idle.sleep()
#############################################################
示例3: spinOnce
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def spinOnce(self):
#####################################################
self.previous_error = 0.0
self.prev_vel = [0.0] * self.rolling_pts
self.integral = 0.0
self.error = 0.0
self.derivative = 0.0
self.vel = 0.0
# only do the loop if we've recently recieved a target velocity message
while not rospy.is_shutdown() and self.ticks_since_target < self.timeout_ticks:
self.calcVelocity()
self.doPid()
self.pub_motor.publish(self.motor)
self.r.sleep()
self.ticks_since_target += 1
if self.ticks_since_target == self.timeout_ticks:
self.pub_motor.publish(0)
#####################################################
示例4: spin
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def spin(self):
###############################################
r = rospy.Rate
self.secs_since_target = self.timeout_secs
self.then = rospy.Time.now()
self.latest_msg_time = rospy.Time.now()
rospy.loginfo("-D- spinning")
###### main loop #########
while not rospy.is_shutdown():
while not rospy.is_shutdown() and self.secs_since_target < self.timeout_secs:
self.spinOnce()
r.sleep
self.secs_since_target = rospy.Time.now() - self.latest_msg_time
self.secs_since_target = self.secs_since_target.to_sec()
#rospy.loginfo(" inside: secs_since_target: %0.3f" % self.secs_since_target)
# it's been more than timeout_ticks since we recieved a message
self.secs_since_target = rospy.Time.now() - self.latest_msg_time
self.secs_since_target = self.secs_since_target.to_sec()
# rospy.loginfo(" outside: secs_since_target: %0.3f" % self.secs_since_target)
self.velocity = 0
r.sleep
###############################################
示例5: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def talker_ctrl():
global rate_value
rospy.init_node('usv_simple_ctrl', anonymous=True)
rate = rospy.Rate(rate_value) # 10h
# publishes to thruster and rudder topics
pub_motor = rospy.Publisher('thruster_command', JointState, queue_size=10)
pub_rudder = rospy.Publisher('joint_setpoint', JointState, queue_size=10)
pub_result = rospy.Publisher('move_usv/result', Float64, queue_size=10)
# subscribe to state and targer point topics
rospy.Subscriber("state", Odometry, get_pose) # get usv position (add 'gps' position latter)
rospy.Subscriber("move_usv/goal", Odometry, get_target) # get target position
while not rospy.is_shutdown():
try:
pub_motor.publish(thruster_ctrl_msg())
pub_rudder.publish(rudder_ctrl_msg())
pub_result.publish(verify_result())
rate.sleep()
except rospy.ROSInterruptException:
rospy.logerr("ROS Interrupt Exception! Just ignore the exception!")
except rospy.ROSTimeMovedBackwardsException:
rospy.logerr("ROS Time Backwards! Just ignore the exception!")
示例6: navigation
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def navigation():
pub = rospy.Publisher('usv_position_setpoint', Odometry, queue_size=10) # only create a rostopic, navigation system TODO
rospy.init_node('navigation_publisher')
rate = rospy.Rate(60) # 10h
x = -20.0
y = -20.0
msg = Odometry()
# msg.header = Header()
msg.header.stamp = rospy.Time.now()
msg.header.frame_id = "navigation"
msg.pose.pose.position = Point(x, y, 0.)
while not rospy.is_shutdown():
pub.publish(msg)
rate.sleep()
示例7: __init__
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def __init__(self, args):
self.index = 0
if len(sys.argv) > 1:
self.index = int(sys.argv[1])
rospy.init_node('save_img')
self.bridge = CvBridge()
while not rospy.is_shutdown():
raw_input()
data = rospy.wait_for_message('/camera1/usb_cam/image_raw', Image)
try:
cv_image = self.bridge.imgmsg_to_cv2(data, "passthrough")
except CvBridgeError as e:
print(e)
print "Saved to: ", base_path+str(self.index)+".jpg"
cv2.cvtColor(cv_image, cv2.COLOR_BGR2RGB, cv_image)
cv2.imwrite(join(base_path, "frame{:06d}.jpg".format(self.index)), cv_image)#*255)
self.index += 1
rospy.spin()
示例8: main
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--lr", default="r")
args = parser.parse_args()
rospy.init_node("pr2_target_policy")
with open('config/environment/pr2.yaml') as yaml_string:
pr2_env = utils.from_yaml(yaml_string)
tool_link_name = "%s_gripper_tool_frame" % args.lr
pol = policies.Pr2TargetPolicy(pr2_env, tool_link_name, np.zeros(3))
rate = rospy.Rate(30.0)
while not rospy.is_shutdown():
state = pr2_env.get_state()
target_state = pol.get_target_state()
action = (target_state - state) / pr2_env.dt
pr2_env.step(action)
# pr2_env.reset(pol.get_target_state())
rate.sleep()
示例9: revalidate
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def revalidate(self, timeout, invalidate_state=True, invalidate_config=True):
"""
invalidate the state and config topics, then wait up to timeout
seconds for them to become valid again.
return true if both the state and config topic data are valid
"""
if invalidate_state:
self.invalidate_state()
if invalidate_config:
self.invalidate_config()
timeout_time = rospy.Time.now() + rospy.Duration(timeout)
while not self.is_state_valid() and not rospy.is_shutdown():
rospy.sleep(0.1)
if timeout_time < rospy.Time.now():
rospy.logwarn("Timed out waiting for node interface valid...")
return False
return True
示例10: spin
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def spin(self):
#############################################################################
r = rospy.Rate(self.rate)
while not rospy.is_shutdown():
self.update()
r.sleep()
#############################################################################
示例11: spin
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def spin(self):
#####################################################
self.r = rospy.Rate(self.rate)
self.then = rospy.Time.now()
self.ticks_since_target = self.timeout_ticks
self.wheel_prev = self.wheel_latest
self.then = rospy.Time.now()
while not rospy.is_shutdown():
self.spinOnce()
self.r.sleep()
#####################################################
示例12: run
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def run(self, update_rate=10):
"""
Publish data continuously with given rate.
:type update_rate: int
:param update_rate: The update rate.
"""
r = rospy.Rate(update_rate)
while not rospy.is_shutdown():
self._publish_tf(update_rate)
self._publish_image()
self._publish_objects()
self._publish_joint_state()
self._publish_imu()
self._publish_battery()
self._publish_odometry()
self._publish_diagnostics()
# send message repeatedly to avoid idle mode.
# This might cause low battery soon
# TODO improve this!
self._cozmo.drive_wheels(*self._wheel_vel)
# sleep
r.sleep()
# stop events on cozmo
self._cozmo.stop_all_motors()
示例13: talker
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def talker():
pub = rospy.Publisher('/barco_auv/thruster_command', JointState, queue_size=10)
rospy.init_node('ctrl_jointState_publisher', anonymous=True)
rate = rospy.Rate(10) # 10hz
hello_str = JointState()
hello_str.header = Header()
hello_str.name = ['fwd_left']
hello_str.position = [10]
hello_str.velocity = []
hello_str.effort = []
while not rospy.is_shutdown():
rospy.loginfo(hello_str)
pub.publish(hello_str)
rate.sleep()
示例14: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def talker_ctrl():
global rate_value
global currentHeading
global windDir
global isTacking
global heeling
global spHeading
rospy.init_node('usv_simple_ctrl', anonymous=True)
rate = rospy.Rate(rate_value) # 10h
# publishes to thruster and rudder topics
#pub_sail = rospy.Publisher('angleLimits', Float64, queue_size=10)
pub_rudder = rospy.Publisher('joint_setpoint', JointState, queue_size=10)
pub_result = rospy.Publisher('move_usv/result', Float64, queue_size=10)
pub_heading = rospy.Publisher('currentHeading', Float64, queue_size=10)
pub_windDir = rospy.Publisher('windDirection', Float64, queue_size=10)
pub_heeling = rospy.Publisher('heeling', Float64, queue_size=10)
pub_spHeading = rospy.Publisher('spHeading', Float64, queue_size=10)
# subscribe to state and targer point topics
rospy.Subscriber("state", Odometry, get_pose) # get usv position (add 'gps' position latter)
rospy.Subscriber("move_usv/goal", Odometry, get_target) # get target position
while not rospy.is_shutdown():
try:
pub_rudder.publish(rudder_ctrl_msg())
#pub_sail.publish(sail_ctrl())
pub_result.publish(verify_result())
pub_heading.publish(currentHeading)
pub_windDir.publish(windDir)
pub_heeling.publish(heeling)
pub_spHeading.publish(spHeading)
rate.sleep()
except rospy.ROSInterruptException:
rospy.logerr("ROS Interrupt Exception! Just ignore the exception!")
except rospy.ROSTimeMovedBackwardsException:
rospy.logerr("ROS Time Backwards! Just ignore the exception!")
示例15: navigation
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import is_shutdown [as 别名]
def navigation():
rospy.Publisher('usv_position_setpoint', Odometry) # only create a rostopic, navigation system TODO
rospy.spin()
# while not rospy.is_shutdown():
# rospy.loginfo(hello_str)
# pub.publish(hello_str)
# rate.sleep()