本文整理汇总了Python中std_msgs.msg.ColorRGBA.g方法的典型用法代码示例。如果您正苦于以下问题:Python ColorRGBA.g方法的具体用法?Python ColorRGBA.g怎么用?Python ColorRGBA.g使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std_msgs.msg.ColorRGBA
的用法示例。
在下文中一共展示了ColorRGBA.g方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetColour
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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
示例2: callLedsForDancing
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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
示例3: callback
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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 g [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]
示例5: __init__
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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)
示例6: to_msg
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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
示例7: MoveToBlob
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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)
示例8: MoveToBlob
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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)
示例9: main
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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)
示例10: __init__
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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)
示例11: hex_to_color_msg
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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
示例12: callLedsForCmplxMv
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [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
示例13: static_area_makers
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [as 别名]
def static_area_makers(self):
color = ColorRGBA()
scale = Point()
scale.x = 0.05
scale.y = 0.05
color.r = 1.0
color.g = 1.0
color.b = 0.0
color.a = 1.0
self.points_marker = self.visual_test(self.static_area, Marker.POINTS, color, scale)
示例14: set_light
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [as 别名]
def set_light(self,parameter_name,blocking=False):
ah = action_handle("set", "light", parameter_name, blocking, self.parse)
if(self.parse):
return ah
else:
ah.set_active(mode="topic")
rospy.loginfo("Set light to <<%s>>",parameter_name)
# get joint values from parameter server
if type(parameter_name) is str:
if not rospy.has_param(self.ns_global_prefix + "/light/" + parameter_name):
rospy.logerr("parameter %s does not exist on ROS Parameter Server, aborting...",self.ns_global_prefix + "/light/" + parameter_name)
return 2
param = rospy.get_param(self.ns_global_prefix + "/light/" + parameter_name)
else:
param = parameter_name
# check color parameters
if not type(param) is list: # check outer list
rospy.logerr("no valid parameter for light: not a list, aborting...")
print "parameter is:",param
ah.error_code = 3
return ah
else:
if not len(param) == 3: # check dimension
rospy.logerr("no valid parameter for light: dimension should be 3 (r,g,b) and is %d, aborting...",len(param))
print "parameter is:",param
ah.error_code = 3
return ah
else:
for i in param:
#print i,"type1 = ", type(i)
if not ((type(i) is float) or (type(i) is int)): # check type
#print type(i)
rospy.logerr("no valid parameter for light: not a list of float or int, aborting...")
print "parameter is:",param
ah.error_code = 3
return ah
else:
rospy.logdebug("accepted parameter %f for light",i)
# convert to ColorRGBA message
color = ColorRGBA()
color.r = param[0]
color.g = param[1]
color.b = param[2]
color.a = 1 # Transparency
# publish color
self.pub_light.publish(color)
ah.set_succeeded()
ah.error_code = 0
return ah
示例15: create_trajectory_marker
# 需要导入模块: from std_msgs.msg import ColorRGBA [as 别名]
# 或者: from std_msgs.msg.ColorRGBA import g [as 别名]
def create_trajectory_marker(self, traj):
# create an interactive marker for our server
int_marker = InteractiveMarker()
int_marker.header.frame_id = "/map"
int_marker.name = traj.uuid
int_marker.description = traj.uuid
pose = Pose()
pose.position.x = traj.pose[0]['position']['x']
pose.position.y = traj.pose[0]['position']['y']
int_marker.pose = pose
line_marker = Marker()
line_marker.type = Marker.LINE_STRIP
line_marker.scale.x = 0.05
# random.seed(traj.uuid)
# val = random.random()
# line_marker.color.r = r_func(val)
# line_marker.color.g = g_func(val)
# line_marker.color.b = b_func(val)
# line_marker.color.a = 1.0
line_marker.points = []
MOD = 1
for i, point in enumerate(traj.pose):
if i % MOD == 0:
x = point['position']['x']
y = point['position']['y']
p = Point()
p.x = x - int_marker.pose.position.x
p.y = y - int_marker.pose.position.y
line_marker.points.append(p)
line_marker.colors = []
for i, vel in enumerate(traj.vel):
if i % MOD == 0:
color = ColorRGBA()
val = vel / traj.max_vel
color.r = r_func(val)
color.g = g_func(val)
color.b = b_func(val)
color.a = 1.0
line_marker.colors.append(color)
# create a control which will move the box
# this control does not contain any markers,
# which will cause RViz to insert two arrows
control = InteractiveMarkerControl()
control.markers.append(line_marker)
int_marker.controls.append(control)
return int_marker