Python源码示例:rospy.get_param()
示例1
def __init__(self):
"""
Create HeadLiftJoy object.
"""
# params
self._head_axes = rospy.get_param('~head_axes', 3)
self._lift_axes = rospy.get_param('~lift_axes', 3)
self._head_button = rospy.get_param('~head_button', 4)
self._lift_button = rospy.get_param('~lift_button', 5)
# pubs
self._head_pub = rospy.Publisher('head_angle', Float64, queue_size=1)
self._lift_pub = rospy.Publisher('lift_height', Float64, queue_size=1)
# subs
self._joy_sub = rospy.Subscriber('joy', Joy, self._joy_cb, queue_size=1)
示例2
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
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
def scaleWheel():
rospy.init_node("wheel_scaler")
rospy.loginfo("wheel_scaler started")
scale = rospy.get_param('distance_scale', 1)
rospy.loginfo("wheel_scaler scale: %0.2f", scale)
rospy.Subscriber("lwheel", Int16, lwheelCallback)
rospy.Subscriber("rwheel", Int16, rwheelCallback)
lscaled_pub = rospy.Publisher("lwheel_scaled", Int16, queue_size=10)
rscaled_pub = rospy.Publisher("rwheel_scaled", Int16, queue_size=10)
### testing sleep CPU usage
r = rospy.Rate(50)
while not rospy.is_shutdown:
r.sleep()
rospy.spin()
示例5
def __init__(self):
# setup
CozmoTeleop.settings = termios.tcgetattr(sys.stdin)
atexit.register(self.reset_terminal)
# vars
self.head_angle = STD_HEAD_ANGLE
self.lift_height = STD_LIFT_HEIGHT
# params
self.lin_vel = rospy.get_param('~lin_vel', 0.2)
self.ang_vel = rospy.get_param('~ang_vel', 1.5757)
# pubs
self._head_pub = rospy.Publisher('head_angle', Float64, queue_size=1)
self._lift_pub = rospy.Publisher('lift_height', Float64, queue_size=1)
self._cmd_vel_pub = rospy.Publisher('cmd_vel', Twist, queue_size=1)
示例6
def __init__(self):
rospy.loginfo("Tianbot Racecar JoyTeleop Initializing...")
self._twist = Twist()
self._twist.linear.x = 1500
self._twist.angular.z = 90
self._deadman_pressed = False
self._zero_twist_published = False
self._cmd_vel_pub = rospy.Publisher('~/car/cmd_vel', Twist, queue_size=5)
self._joy_sub = rospy.Subscriber('/joy', Joy, self.joy_callback)
self._timer = rospy.Timer(rospy.Duration(0.05), self.joystick_controller)
self._axis_throttle = 1
_joy_mode = rospy.get_param("~joy_mode", "D").lower()
if _joy_mode == "d":
self._axis_servo = 2
if _joy_mode == "x":
self._axis_servo = 3
self._throttle_scale = rospy.get_param("~throttle_scale", 0.5)
self._servo_scale = rospy.get_param("~servo_scale", 1)
示例7
def get_parameters(self):
"""
Gets the necessary parameters from parameter server
Args:
Returns:
(tuple) (camera_topic, output_topic, recognition_interval,
buffer_size)
"""
camera_topic = rospy.get_param("~camera_topic")
output_topic = rospy.get_param("~output_topic")
recognition_interval = rospy.get_param("~recognition_interval")
buffer_size = rospy.get_param("~buffer_size")
return (camera_topic, output_topic,
recognition_interval, buffer_size)
示例8
def get_parameters(self):
"""
Gets the necessary parameters from parameter server
Args:
Returns:
(tuple) (model name, num_of_classes, label_file)
"""
model_name = rospy.get_param("~model_name")
num_of_classes = rospy.get_param("~num_of_classes")
label_file = rospy.get_param("~label_file")
camera_namespace = rospy.get_param("~camera_namespace")
video_name = rospy.get_param("~video_name")
num_workers = rospy.get_param("~num_workers")
return (model_name, num_of_classes, label_file, \
camera_namespace, video_name, num_workers)
示例9
def get_parameters(self):
"""
Gets the necessary parameters from parameter server
Args:
Returns:
(tuple) (camera_topic, detection_topic, output_topic)
"""
camera_topic = rospy.get_param("~camera_topic")
detection_topic = rospy.get_param("~detection_topic")
output_topic = rospy.get_param("~output_topic")
output_topic_rgb = rospy.get_param("~output_topic_rgb")
return (camera_topic, detection_topic, output_topic, output_topic_rgb)
示例10
def get_parameters(self):
"""
Gets the necessary parameters from parameter server
Args:
Returns:
(tuple) (camera_topic, detection_topic, tracker_topic, cost_threhold)
"""
detection_topic = rospy.get_param("~detection_topic")
tracker_topic = rospy.get_param('~tracker_topic')
cost_threhold = rospy.get_param('~cost_threhold')
min_hits = rospy.get_param('~min_hits')
max_age = rospy.get_param('~max_age')
return (detection_topic, tracker_topic, cost_threhold, \
max_age, min_hits)
示例11
def get_parameters(self):
"""
Gets the necessary parameters from parameter server
Returns:
(tuple) :
depth_topic (String): Incoming depth topic name
face_topic (String): Incoming face bounding box topic name
output_topic (String): Outgoing depth topic name
f (Float): Focal Length
cx (Int): Principle Point Horizontal
cy (Int): Principle Point Vertical
"""
depth_topic = rospy.get_param("~depth_topic")
face_topic = rospy.get_param('~face_topic')
output_topic = rospy.get_param('~output_topic')
f = rospy.get_param('~focal_length')
cx = rospy.get_param('~cx')
cy = rospy.get_param('~cy')
return (depth_topic, face_topic, output_topic, f, cx, cy)
示例12
def __init__(self):
# Audio stream input setup
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
self.CHUNK = 4096
self.audio = pyaudio.PyAudio()
self.stream = self.audio.open(format=FORMAT, channels=CHANNELS,
rate=RATE, input=True,
frames_per_buffer=self.CHUNK,
stream_callback=self._get_data)
self._buff = Queue.Queue() # Buffer to hold audio data
self.closed = False
# ROS Text Publisher
text_topic = rospy.get_param('/text_topic', '/dialogflow_text')
self.text_pub = rospy.Publisher(text_topic, String, queue_size=10)
示例13
def __init__(self):
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
CHUNK = 4096
self.audio = pyaudio.PyAudio()
self.stream = self.audio.open(format=FORMAT, channels=CHANNELS, rate=RATE,
input=True, frames_per_buffer=CHUNK,
stream_callback=self._callback)
self.serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.read_list = [self.serversocket]
self._server_name = rospy.get_param('/dialogflow_client/server_name',
'127.0.0.1')
self._port = rospy.get_param('/dialogflow_client/port', 4444)
rospy.loginfo("DF_CLIENT: Audio Server Started!")
示例14
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
#############################################################
示例15
def _InitializeDriveGeometry(self):
wheelDiameter = rospy.get_param("~driveGeometry/wheelDiameter", "0.9")
trackWidth = rospy.get_param("~driveGeometry/trackWidth", "0.1")
countsPerRevolution = rospy.get_param("~driveGeometry/countsPerRevolution", "2000")
wheelDiameter= wheelDiameter * 1000
trackWidth=trackWidth * 1000
#countsPerRevolution=countsperRevolution*1000;
#wheelDiameterParts = self._GetBaseAndExponent(wheelDiameter)
#trackWidthParts = self._GetBaseAndExponent(trackWidth)
message = 'dg %d %d %d\r' % (int(wheelDiameter), int(trackWidth), int(countsPerRevolution))
rospy.logdebug("Sending drive geometry params message: " + message)
self._WriteSerial(message)
示例16
def _InitializeSpeedController(self):
velocityPParam = rospy.get_param("~speedController/velocityPParam", "0")
velocityIParam = rospy.get_param("~speedController/velocityIParam", "0")
turnPParam = rospy.get_param("~speedController/turnPParam", "0")
turnIParam = rospy.get_param("~speedController/turnIParam", "0")
commandTimeout = self._GetCommandTimeoutForSpeedController()
message = 'sc %.2f %.2f %.2f %.2f %.2f\r' % (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#message = 'sc %f %f %f\r' % (velocityPParam, velocityIParam, turnPParam)
rospy.logdebug("Sending differential drive gains message: " + message)
self._WriteSerial(message)
#speedControllerParams = (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#rospy.loginfo(str(speedControllerParams))
#self._WriteSpeedControllerParams(speedControllerParams)
示例17
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_())
示例18
def _InitializeSpeedController(self):
velocityPParam = rospy.get_param("~speedController/velocityPParam", "1")
velocityIParam = rospy.get_param("~speedController/velocityIParam", "1")
turnPParam = rospy.get_param("~speedController/turnPParam", "1")
turnIParam = rospy.get_param("~speedController/turnIParam", "1")
commandTimeout = self._GetCommandTimeoutForSpeedController()
velocityPParam=velocityPParam * 1000
velocityIParam= velocityIParam * 1000
turnPParam = turnPParam * 1000
turnIParam=turnIParam * 1000
message = 'sc %d %d %d %d %d\r' % (int(velocityPParam), int(velocityIParam), int(turnPParam), int(turnIParam), int(commandTimeout))
#message = 'sc %f %f %f\r' % (velocityPParam, velocityIParam, turnPParam)
rospy.logdebug("Sending differential drive gains message: " + message)
self._WriteSerial(message)
#speedControllerParams = (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#rospy.loginfo(str(speedControllerParams))
#self._WriteSpeedControllerParams(speedControllerParams)
示例19
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)
###############################################
示例20
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
#############################################################
示例21
def _InitializeSpeedController(self):
velocityPParam = rospy.get_param("~speedController/velocityPParam", "1")
velocityIParam = rospy.get_param("~speedController/velocityIParam", "1")
turnPParam = rospy.get_param("~speedController/turnPParam", "1")
turnIParam = rospy.get_param("~speedController/turnIParam", "1")
commandTimeout = self._GetCommandTimeoutForSpeedController()
velocityPParam=velocityPParam * 1000
velocityIParam= velocityIParam * 1000
turnPParam = turnPParam * 1000
turnIParam=turnIParam * 1000
message = 'sc %d %d %d %d %d\r' % (int(velocityPParam), int(velocityIParam), int(turnPParam), int(turnIParam), int(commandTimeout))
#message = 'sc %f %f %f\r' % (velocityPParam, velocityIParam, turnPParam)
rospy.logdebug("Sending differential drive gains message: " + message)
self._WriteSerial(message)
#speedControllerParams = (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#rospy.loginfo(str(speedControllerParams))
#self._WriteSpeedControllerParams(speedControllerParams)
示例22
def _InitializeSpeedController(self):
velocityPParam = rospy.get_param("~speedController/velocityPParam", "0")
velocityIParam = rospy.get_param("~speedController/velocityIParam", "0")
turnPParam = rospy.get_param("~speedController/turnPParam", "0")
turnIParam = rospy.get_param("~speedController/turnIParam", "0")
commandTimeout = self._GetCommandTimeoutForSpeedController()
message = 'sc %.2f %.2f %.2f %.2f %.2f\r' % (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#message = 'sc %f %f %f\r' % (velocityPParam, velocityIParam, turnPParam)
rospy.logdebug("Sending differential drive gains message: " + message)
self._WriteSerial(message)
#speedControllerParams = (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#rospy.loginfo(str(speedControllerParams))
#self._WriteSpeedControllerParams(speedControllerParams)
示例23
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_())
示例24
def _InitializeDriveGeometry(self):
wheelDiameter = rospy.get_param("~driveGeometry/wheelDiameter", "0.9")
trackWidth = rospy.get_param("~driveGeometry/trackWidth", "0.1")
countsPerRevolution = rospy.get_param("~driveGeometry/countsPerRevolution", "2000")
wheelDiameter= wheelDiameter * 1000
trackWidth=trackWidth * 1000
#countsPerRevolution=countsperRevolution*1000;
#wheelDiameterParts = self._GetBaseAndExponent(wheelDiameter)
#trackWidthParts = self._GetBaseAndExponent(trackWidth)
message = 'dg %d %d %d\r' % (int(wheelDiameter), int(trackWidth), int(countsPerRevolution))
rospy.logdebug("Sending drive geometry params message: " + message)
self._WriteSerial(message)
示例25
def _InitializeSpeedController(self):
velocityPParam = rospy.get_param("~speedController/velocityPParam", "1")
velocityIParam = rospy.get_param("~speedController/velocityIParam", "1")
turnPParam = rospy.get_param("~speedController/turnPParam", "1")
turnIParam = rospy.get_param("~speedController/turnIParam", "1")
commandTimeout = self._GetCommandTimeoutForSpeedController()
velocityPParam=velocityPParam * 1000
velocityIParam= velocityIParam * 1000
turnPParam = turnPParam * 1000
turnIParam=turnIParam * 1000
message = 'sc %d %d %d %d %d\r' % (int(velocityPParam), int(velocityIParam), int(turnPParam), int(turnIParam), int(commandTimeout))
#message = 'sc %f %f %f\r' % (velocityPParam, velocityIParam, turnPParam)
rospy.logdebug("Sending differential drive gains message: " + message)
self._WriteSerial(message)
#speedControllerParams = (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#rospy.loginfo(str(speedControllerParams))
#self._WriteSpeedControllerParams(speedControllerParams)
示例26
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)
###############################################
示例27
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
#############################################################
示例28
def _InitializeDriveGeometry(self):
wheelDiameter = rospy.get_param("~driveGeometry/wheelDiameter", "0.9")
trackWidth = rospy.get_param("~driveGeometry/trackWidth", "0.1")
countsPerRevolution = rospy.get_param("~driveGeometry/countsPerRevolution", "2000")
wheelDiameter= wheelDiameter * 1000
trackWidth=trackWidth * 1000
#countsPerRevolution=countsperRevolution*1000;
#wheelDiameterParts = self._GetBaseAndExponent(wheelDiameter)
#trackWidthParts = self._GetBaseAndExponent(trackWidth)
message = 'dg %d %d %d\r' % (int(wheelDiameter), int(trackWidth), int(countsPerRevolution))
rospy.logdebug("Sending drive geometry params message: " + message)
self._WriteSerial(message)
示例29
def _InitializeSpeedController(self):
velocityPParam = rospy.get_param("~speedController/velocityPParam", "0")
velocityIParam = rospy.get_param("~speedController/velocityIParam", "0")
turnPParam = rospy.get_param("~speedController/turnPParam", "0")
turnIParam = rospy.get_param("~speedController/turnIParam", "0")
commandTimeout = self._GetCommandTimeoutForSpeedController()
message = 'sc %.2f %.2f %.2f %.2f %.2f\r' % (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#message = 'sc %f %f %f\r' % (velocityPParam, velocityIParam, turnPParam)
rospy.logdebug("Sending differential drive gains message: " + message)
self._WriteSerial(message)
#speedControllerParams = (velocityPParam, velocityIParam, turnPParam, turnIParam, commandTimeout)
#rospy.loginfo(str(speedControllerParams))
#self._WriteSpeedControllerParams(speedControllerParams)
示例30
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_())