本文整理汇总了Python中std_msgs.msg.ColorRGBA.r方法的典型用法代码示例。如果您正苦于以下问题:Python ColorRGBA.r方法的具体用法?Python ColorRGBA.r怎么用?Python ColorRGBA.r使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std_msgs.msg.ColorRGBA
的用法示例。
在下文中一共展示了ColorRGBA.r方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callLedsForDancing
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def callLedsForDancing(self, blinking_freq):
"""
fColor : the first Color
sColor : the second Color
By defining LedGroup, we will have RGBA of color of each
set of colours.
I suppose that the last parameter of LEDS_BLINK is the frequency,
although its not on the server definition that I have.
"""
fColor = ColorRGBA()
sColor = ColorRGBA()
fColor.r = 0.5
fColor.g = 1.0
fColor.b = 0.5
sColor.r = 0.0
sColor.g = 0.0
sColor.b = 0.0
ledGroup = LedGroup()
first_color_duration = rospy.Duration(FIRST_COLOR_DURATION)
second_color_duration = rospy.Duration(SECOND_COLOR_DURATION)
try:
self.LEDS_BLINK(ledGroup, fColor, sColor, first_color_duration, second_color_duration, BLINK_EFECT_DURATION_DANCING, blinking_freq)
except rospy.ServiceException, e:
print "Service call To Blinking LEDs failed: %s" % e
示例2: SetColour
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def SetColour(colour):
rgb_colour = ColorRGBA()
rgb_colour.a = 1.0
if colour == "RED":
rgb_colour.r = 1.0
rgb_colour.g = 0.0
rgb_colour.b = 0.0
return rgb_colour
if colour == "GREEN":
rgb_colour.r = 0.0
rgb_colour.g = 1.0
rgb_colour.b = 0.0
return rgb_colour
if colour == "BLUE":
rgb_colour.r = 0.0
rgb_colour.g = 0.0
rgb_colour.b = 1.0
return rgb_colour
if colour == "RANDOM":
rgb_colour.r = random.random()
rgb_colour.g = random.random()
rgb_colour.b = random.random()
return rgb_colour
assert (), "COLOUR not supported, changed to default RED type"
rgb_colour.r = 1.0
rgb_colour.g = 0.0
rgb_colour.b = 0.0
return rgb_colour
示例3: callback
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def callback(joy):
motor = ColorRGBA()
color = ColorRGBA()
if joy.buttons[0]>0:
color.r = 0
color.g = 0
color.b = 150
if joy.buttons[1]>0:
color.r = 0
color.g = 150
color.b = 0
if joy.buttons[2]>0:
color.r = 150
color.g = 0
color.b = 0
if joy.buttons[3]>0:
color.r = 150
color.g = 80
color.b = 0
y=joy.axes[3]*100.0
x=joy.axes[2]*-100.0
##Ouputs throttle from -100 to 100
f = math.fabs(y/100.0)
left = y*f+(1-f)*x
right = y*f -(1-f)*x
#Change to 0..127..255
motor.b = left*254.0/200.0 +127.0
motor.a = left*254.0/200.0 +127.0
motor.r = right*254.0/200.0 +127.0
motor.g = right*254.0/200.0 +127.0
pub_motor.publish(motor)
pub_color.publish(color)
示例4: __init__
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def __init__(self):
self.marker_pub = rospy.Publisher('occupancy_marker', Marker)
self.color_free = ColorRGBA()
cf = ColorRGBA()
cf.r, cf.g, cf.b, cf.a = 0.0, 0.6, 0.2, 1.0
self.color_free = cf
co = ColorRGBA()
co.r, co.g, co.b, co.a = 0.8, 0.0, 0.2, 1.0
self.color_occupied = co
self.point_srv = rospy.ServiceProxy('/occupancy_query_server/'
'is_point_free',
IsPointFree)
self.line_srv = rospy.ServiceProxy('/occupancy_query_server/'
'is_line_segment_free',
IsLineSegmentFree)
示例5: to_msg
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def to_msg(self):
msg = ColorRGBA()
msg.r = self.r / 255.0
msg.g = self.g / 255.0
msg.b = self.b / 255.0
msg.a = 1.0
return msg
示例6: MoveToBlob
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def MoveToBlob(self,msg): #Moves to the largest blob
drivemsg = AckermannDriveStamped() #Sets the drive messaged to the AckermannDriveStamped message type
drivemsg.drive.speed = 2 #Sets a field of the drivemsg message.
#Gets the position of the largest green blob. The first green blob will be the largest green blob because the blobs are sorted by size. (index 0 is biggest size)
ele = ColorRGBA()
ele.r = 0
ele.g = 255
largest_green_blob_index = self.blob_detect.colors.index(ele)
blob_pos = self.blob_detec.locations[largest_green_bloc_index] #Get's the position of the largest green block
blob_x_pos = blob_pos[0]
blob_y_pos = blob_pos[1]
biggest_blob_area = blob_detec.sizes[0] #The blob with index one is the biggest blob
if (biggest_blob_area < 1000): #Keep moving
if (blob_x_pos > self.img_width/2): #If Blob is On the right side
drivemsg.drive.steering_angle = .33 #Turn left
if (blob_x_pos < self.img_width/2): #If Blob is on the left side.
drivemsg.drive.steering_angle = -0.33 #Turn right
self.pub_mov_func.publish(drivemsg)
else: # if the contour is really big, we are close to the sign, so we do an emergency stop. We can delete this if we were to use the lidar.
drivemsg.drive.speed = 0
self.pub_mov_func.publish(drivemsg)
示例7: __init__
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def __init__(self):
super(CCA, self).__init__()
#UIの初期化
self.initUI()
#ROSのパブリッシャなどの初期化
rospy.init_node('roscca', anonymous=True)
self.mpub = rospy.Publisher('visualization_marker_array', MarkerArray, queue_size=10)
self.ppub = rospy.Publisher('joint_diff', PointStamped, queue_size=10)
#rvizのカラー設定(未)
self.carray = []
clist = [[1,1,0,1],[0,1,0,1],[1,0,0,1]]
for c in clist:
color = ColorRGBA()
color.r = c[0]
color.g = c[1]
color.b = c[2]
color.a = c[3]
self.carray.append(color)
self.fnames=["20151222_a1.json","20151222_a2.json","20151222_a3.json","20151222_b1.json","20151222_b2.json","20151222_b3.json"]
#self.fnames=["20151222_a1.json"]
self.winSizes = [90]
示例8: __init__
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def __init__(self):
super(CCA, self).__init__()
#UIの初期化
self.initUI()
#クラス間のデータ渡しテスト
self.test = 100
#ROSのパブリッシャなどの初期化
rospy.init_node('roscca', anonymous=True)
self.mpub = rospy.Publisher('visualization_marker_array', MarkerArray, queue_size=10)
self.ppub = rospy.Publisher('joint_diff', PointStamped, queue_size=10)
#rvizのカラー設定(未)
self.carray = []
clist = [[1,1,0,1],[0,1,0,1],[1,0,0,1]]
for c in clist:
color = ColorRGBA()
color.r = c[0]
color.g = c[1]
color.b = c[2]
color.a = c[3]
self.carray.append(color)
示例9: MoveToBlob
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def MoveToBlob(self): #Moves to the largest [choose a color] blob
self.drive_msg.drive.speed = 2 #Sets a field of the drivemsg message.
#Gets the position of the largest green blob. The first green blob will be the largest green blob because the blobs are sorted by size. (index 0 is biggest size). The next three lines
#define a specific color that we want to find/move to
ele = ColorRGBA()
ele.r = 0
ele.g = 255
largest_green_blob_index = self.blob_detect.colors.index(ele)
blob_pos = self.blob_detect.locations[largest_green_blob_index]
blob_x_pos = blob_pos[0] #This will be in between 0 and 1 (inclusive) (0 is the left and 1 is the right (?))
blob_y_pos = blob_pos[1] #Same thing here
blob_area = blob_detect.size[largest_green_blob_index] #Get the area of the largest block of the set of the blocks with the color we specified
if (blob_area < 1000): #Keep moving unless the blob_area becomes too big (meaning that we must be very close to the blob, ie it is taking up more of our field of vision.
#If the blob_area is "small, we want to keep moving toward the blob while continually centering our field of vision with the blob.
if (blob_x_pos > 0.55): #If Blob is On the right side
drive_msg.drive.steering_angle = .33 #Turn left
elif (blob_x_pos < 0.45): #If Blob is on the left side.
drive_msg.drive.steering_angle = -0.33 #Turn right
else: #If blob_x_pos (the x component of the blob's centroid) is in the middle 200 pixels, just move forward
drive_msg.drive.steering_angle = 0
self.pub_mov_func.publish(drive_msg)
else: # if the contour is really big, we are close to the sign, so we do an emergency stop. This is a bit redundant with our emergency stop function that comes from the lidar scan.
self.drive_msg.drive.speed = 0
self.pub_mov_func.publish(drive_msg)
示例10: find_color
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def find_color(self, im, label_color, mask):
contours = cv2.findContours(mask, cv2.cv.CV_RETR_TREE, cv2.cv.CV_CHAIN_APPROX_SIMPLE)[0]
#cv2.drawContours(im, contours, -1, (255, 255, 255), 2)
approx_contours = []
for c in contours:
area = cv2.contourArea(c)
if area < 100: continue
perim = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, .05*perim, True)
#if len(approx) == 4 and len(cv2.convexityDefects(c, cv2.convexHull(c))) <= 1:
if len(approx) == 4:
approx_contours.append(approx)
moments = cv2.moments(c)
center = (int(moments['m10']/moments['m00']), int(moments['m01']/moments['m00']))
cv2.circle(im, center, 3, (255, 100, 100), 4)
print "Moment: ({}, {})".format(center[0], center[1])
msg_color = ColorRGBA()
msg_color.r, msg_color.g, msg_color.b = label_color
self.msg.colors.append(msg_color)
print "Label color: {}".format(label_color)
msg_size = Float64()
#msg_size.data = max(math.sqrt((approx[1][0][0]-approx[0][0][0])**2+(approx[1][0][1]-approx[0][0][1])**2), math.sqrt((approx[2][0][0]-approx[1][0][0])**2+(approx[2][0][1]-approx[2][0][0])**2))
msg_size.data = float((max(approx, key=lambda x: x[0][0])[0][0] - min(approx, key=lambda x: x[0][0])[0][0])) / len(im[0])
print "Width: {}".format(msg_size.data)
self.msg.sizes.append(msg_size)
msg_loc = Point()
msg_loc.x, msg_loc.y = float(center[0]) / len(im[0]), float(center[1]) / len(im)
self.msg.locations.append(msg_loc)
示例11: __init__
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def __init__(self):
super(CCA, self).__init__()
#UIの初期化
self.initUI()
#ファイル入力
#self.jsonInput()
#ROSのパブリッシャなどの初期化
rospy.init_node('ros_cca_table', anonymous=True)
self.mpub = rospy.Publisher('visualization_marker_array', MarkerArray, queue_size=10)
self.ppub = rospy.Publisher('joint_diff', PointStamped, queue_size=10)
self.carray = []
clist = [[1,1,0,1],[0,1,0,1],[1,0,0,1]]
for c in clist:
color = ColorRGBA()
color.r = c[0]
color.g = c[1]
color.b = c[2]
color.a = c[3]
self.carray.append(color)
示例12: main
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def main():
display_pub = rospy.Publisher('leds/display', Keyframe, queue_size=10)
anim_pub = rospy.Publisher('leds/animation', Animation, queue_size=10)
set_pub = rospy.Publisher('leds/set', Command, queue_size=10)
rospy.init_node('led_anim_clear', anonymous = True)
time.sleep(0.5)
keyframe_msg = Keyframe()
command_msg = Command()
color_msg = ColorRGBA()
anim_msg = Animation()
rospy.loginfo("Single frame test ...")
keyframe_msg.color_pattern = []
color_msg.r = 0.0
color_msg.g = 0.0
color_msg.b = 0.0
keyframe_msg.color_pattern.append(copy.deepcopy(color_msg))
display_pub.publish(keyframe_msg)
time.sleep(0.5)
rospy.loginfo("Clearing the animation...")
anim_msg.iteration_count = 1
anim_pub.publish(anim_msg)
time.sleep(1)
示例13: hex_to_color_msg
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def hex_to_color_msg(hex_str):
rgb = struct.unpack('BBB', hex_str.decode('hex'))
msg = ColorRGBA()
msg.r = rgb[0]
msg.g = rgb[1]
msg.b = rgb[2]
msg.a = 1
return msg
示例14: callLedsForCmplxMv
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def callLedsForCmplxMv(self):
fColor = ColorRGBA()
sColor = ColorRGBA()
fColor.r = 1.0
fColor.g = 1.0
fColor.b = 1.0
sColor.r = 0.0
sColor.g = 0.0
sColor.b = 0.0
ledGroup = LedGroup()
ledGroup.ledMask = 3 # binary mask to decide which leds are active
try:
self.LEDS_BLINK(ledGroup, fColor, sColor, rospy.Duration(0.75), rospy.Duration(0.25), rospy.Duration(5), 50)
except rospy.ServiceException, e:
print "Service call failed: %s" % e
示例15: robot_position_marker
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import r [as 别名]
def robot_position_marker(self):
color = ColorRGBA()
scale = Point()
scale.x = 0.1
scale.y = 0.1
scale.z = 0.1
color.r = 1.0
color.a = 1.0
self.robot_position = self.visual_test(self.pose, Marker.CUBE, color, scale)