本文整理汇总了Python中rospy.init_node方法的典型用法代码示例。如果您正苦于以下问题:Python rospy.init_node方法的具体用法?Python rospy.init_node怎么用?Python rospy.init_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rospy
的用法示例。
在下文中一共展示了rospy.init_node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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: __init__
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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
#############################################################
示例3: main
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [as 别名]
def main():
##########################################################################
##########################################################################
rospy.init_node('virtual_joystick')
rospy.loginfo('virtual_joystick started')
global x_min
global x_max
global r_min
global r_max
x_min = rospy.get_param("~x_min", -0.20)
x_max = rospy.get_param("~x_max", 0.20)
r_min = rospy.get_param("~r_min", -1.0)
r_max = rospy.get_param("~r_max", 1.0)
app = QtGui.QApplication(sys.argv)
ex = MainWindow()
sys.exit(app.exec_())
示例4: __init__
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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)
###############################################
示例5: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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 init_node [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: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [as 别名]
def talker_ctrl():
global rate_value
global result
# publishes to thruster and rudder topics
pub_motor = rospy.Publisher('thruster_command', JointState, queue_size=10)
pub_result = rospy.Publisher('move_usv/result', Float64, 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("move_usv/goal", Odometry, get_target) # get target position
while not rospy.is_shutdown():
try:
pub_motor.publish(thruster_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!")
示例8: start
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [as 别名]
def start(self, node_name='polly_node', service_name='polly'):
"""The entry point of a ROS service node.
Details of the service API can be found in Polly.srv.
:param node_name: name of ROS node
:param service_name: name of ROS service
:return: it doesn't return
"""
rospy.init_node(node_name)
service = rospy.Service(service_name, Polly, self._node_request_handler)
rospy.loginfo('polly running: {}'.format(service.uri))
rospy.spin()
示例9: __init__
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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()
示例10: __init__
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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
#############################################################
示例11: listener
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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()
示例12: __init__
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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)
###############################################
示例13: listener
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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()
示例14: talker
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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()
示例15: talker_ctrl
# 需要导入模块: import rospy [as 别名]
# 或者: from rospy import init_node [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!")