def switch_lights_parser(self, lights_dict):
        """
        Parse and use action to switch lights

        Parameters
        ----------
        lights_dict: dictionary of light switching parameters
        """
        light_name = lights_dict["target_light"]
        diffuse = ColorRGBA()
        if lights_dict["on"] == True:
            diffuse.r = 0.5
            diffuse.g = 0.5
            diffuse.b = 0.5
            diffuse.a = 1.0
            attenuation_linear = 0.01
            attenuation_quadratic = 0.001

        elif lights_dict["on"] == False:
            diffuse.r = 0.0
            diffuse.g = 0.0
            diffuse.b = 0.0
            diffuse.a = 0.0
            attenuation_linear = 0.00
            attenuation_quadratic = 0.0000

        else:
            rospy.logwarn("invalid light on state parsed")
            return

        self.set_light_properties(light_name, diffuse, 0.0, attenuation_linear,
                                  attenuation_quadratic)
        return
Пример #2
0
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)
Пример #3
0
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
0
    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
Пример #5
0
def get_traj_msg(paths, opt_ind):
    ma = MarkerArray()
    for id, path in enumerate(paths):
        m = Marker()
        m.header.frame_id = "/map"
        m.header.stamp = rospy.Time.now()
        m.id = (id + 1) * 10
        m.type = m.POINTS
        m.lifetime.secs = 1
        c = ColorRGBA()
        if opt_ind == id:
            m.scale.x = 0.5
            m.scale.y = 0.5
            m.scale.z = 0.5
            c.r = 0 / 255.0
            c.g = 0 / 255.0
            c.b = 255 / 255.0
            c.a = 1
        else:
            m.scale.x = 0.2
            m.scale.y = 0.2
            m.scale.z = 0.2
            c.r = 255 / 255.0
            c.g = 0 / 255.0
            c.b = 0 / 255.0
            c.a = 0.2
        for x, y in zip(path.x, path.y):
            p = Point()
            p.x, p.y = x, y
            m.points.append(p)
            m.colors.append(c)
        ma.markers.append(m)
    return ma
Пример #6
0
def compute_rgb(data):
    # print(data)
    color = ColorRGBA()
    if data < 1.0 / 3:
        color.r = 1.0
        color.g = 3.0 * data
        color.b = 0.0
    if data >= 1.0 / 3 and data < 1.0 / 2:
        color.r = 3 - 6.0 * data
        color.g = 1.0
        color.b = 0.0
    if data >= 1.0 / 2 and data < 2.0 / 3:
        color.r = 0.0
        color.g = 1.0
        color.b = 6.0 * data - 3
    if data >= 2.0 / 3 and data < 5.0 / 6:
        color.r = 0.0
        color.g = 5 - 6.0 * data
        color.b = 1.0
    if data >= 5.0 / 6 and data <= 1.0:
        color.r = (900.0 * data - 750) / 255.0
        color.g = 0.0
        color.b = 1.0
    color.a = 1.0
    return color
Пример #7
0
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
Пример #8
0
 def Colormap(self, ii, jj):
     p = self._visualMap[ii, jj]
     c = ColorRGBA()
     if p == 2:
         c.r = 0.1
         c.g = 1.0
         c.b = 0.1
         c.a = 0.75
     elif p == 3:
         c.r = 1.0
         c.g = 1.0
         c.b = 0.1
         c.a = 0.75
     elif p == 4:
         c.r = 1.0
         c.g = 1.0
         c.b = 1.0
         c.a = 0.75
     elif p == 5:
         c.r = 1.0
         c.g = 0.1
         c.b = 1.0
         c.a = 0.75
     else:
         c.r = p
         c.g = 0.1
         c.b = 1.0 - p
         c.a = 0.3
     return c
Пример #9
0
def onBumper(data):
    rgb = ColorRGBA()
    byte = int(data.data)
    if byte & 1: rgb.r = 255
    if byte & 2: rgb.g = 255
    if byte & 4: rgb.b = 255
    if byte & 8:
        rgb.r = 255
        rgb.g = 255
        rgb.b = 255

    rgbPub.publish(rgb)
Пример #10
0
    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) 
Пример #11
0
 def pub_color(self, r, g, b, a):
     color_msg = ColorRGBA()
     color_msg.r = r
     color_msg.g = g
     color_msg.b = b
     color_msg.a = a
     self.color_pub.publish(color_msg)
Пример #12
0
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
0
    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]
def NewColor(r, g, b, a=1.0):
    col = ColorRGBA()
    col.r = r
    col.g = g
    col.b = b
    col.a = a
    return col
Пример #15
0
def color(r,g,b,a=1):
	out = ColorRGBAMsg()
	out.r = r
	out.g = g
	out.b = b
	out.a = a
	return out
Пример #16
0
def gen_color(r, g, b):
    c = ColorRGBA()
    c.r = float(r)
    c.g = float(g)
    c.b = float(b)
    c.a = 1.0
    return c
Пример #17
0
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)
Пример #18
0
def pixel_to_color(x, y, image):
	color = ColorRGBA()
	color.r = image[x][y][0]
	color.g = image[x][y][1]
	color.b = image[x][y][2]
	color.a = 1.0
	return color
Пример #19
0
    def findNextGoalPt(self, speed, angle=0.0):
        """
    Finds the point on the subsampled trajectory that is closest to the desired
    lookahead distance (lookahead is proportional to speed), and returns that as a local goal.
    """
        lookahead = self.getLookaheadDist(speed)

        rospy.loginfo('Lookahead Distance: %f' % lookahead)

        self.curr_traj_goal_pt = self.findPtAtDist(lookahead)
        self.goal_pose = self.traj_pts[self.curr_traj_goal_pt]

        if (self.curr_traj_goal_pt >= len(self.traj_pts) - 5):
            self.seeking_end_pt = True
            if self.end_time == 0.0:
                self.end_time = rospy.get_time()

                for p in self.robot_path:
                    pt = Point32()
                    pt.x = p[0]
                    pt.y = p[1]
                    pt.z = 0.0
                    color = ColorRGBA()
                    color.r = 1.0 - p[2]
                    color.g = p[2]
                    color.b = 0.0
                    color.a = 0.75
                    self.robot_path_marker.points.append(pt)
                    self.robot_path_marker.colors.append(color)

                self.robot_path_pub.publish(self.robot_path_marker)
        return
    def PubcmdCB(self, event):
        robot_orien_pub = rospy.Publisher("/robot_orientation",
                                          Marker,
                                          queue_size=1)
        color = ColorRGBA()
        scale = Point()
        scale.x = 0.05
        scale.y = 0.05
        scale.z = 0.05
        color.r = 2.0
        color.g = 0.0
        color.b = 0.0
        color.a = 1.0
        point_marker = Marker()
        point_marker.header.frame_id = '/map'
        point_marker.header.stamp = rospy.Time.now()
        point_marker.ns = 'robot_uni_marker'
        point_marker.action = Marker.ADD

        point_marker.id = 0
        point_marker.type = Marker.ARROW
        point_marker.scale.x = scale.x * 5
        point_marker.scale.y = scale.y / 2
        point_marker.scale.z = scale.z / 2
        point_marker.pose = self.marker.pose
        point_marker.pose.position.z = self.height + 0.1
        point_marker.color = color
        point_marker.lifetime = rospy.Duration(0.1)
        robot_orien_pub.publish(point_marker)
 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
Пример #22
0
 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
Пример #23
0
 def changeColor(self):
     command = ColorRGBA()
     command.r = int(self.redBox.checkState())
     command.g = int(self.greenBox.checkState())
     command.b = int(self.blueBox.checkState())
     command.a = 0
     self.pub2.publish(command)
Пример #24
0
    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) 
Пример #25
0
 def getLineColor(self):
     result = ColorRGBA()
     result.a = 1
     result.r = 0.8
     result.g = 0.1
     result.b = 0.1
     return result
Пример #26
0
def createMarkerVolume(name,
                       points=[],
                       color=[1.0, 1.0, 1.0],
                       map_resolution=0.01,
                       base_frame='world'):
    marker = Marker()
    marker.header.frame_id = base_frame
    marker.type = Marker.CUBE_LIST
    marker.id = 0
    marker.action = marker.ADD
    marker.ns = name

    marker.scale.x = map_resolution
    marker.scale.y = map_resolution
    marker.scale.z = map_resolution
    for p in points:
        pp = Point()
        pp.x = p[0]
        pp.y = p[1]
        pp.z = p[2]
        marker.points.append(pp)

        cc = ColorRGBA()
        cc.r = color[0]
        cc.g = color[1]
        cc.b = color[2]
        cc.a = 1.0
        marker.colors.append(cc)
    return marker
Пример #27
0
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
Пример #28
0
    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
 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)
	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
Пример #31
0
    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
Пример #32
0
 def visual_markers(self):
  color=ColorRGBA()
  scale=Point()
  scale.x=0.05
  scale.y=0.05
  color.r=0.0
  color.g=1.0
  color.b=0.0
  color.a=0.5
  self.line_marker=self.visual_test(self.cut_points, Marker.LINE_LIST, color, scale)#标记出区域划分(testing)
  
  color=ColorRGBA()
  scale=Point()
  scale.x=0.1
  scale.y=0.1
  color.r=0.0
  color.g=0.0
  color.b=1.0
  color.a=1.0
  self.centre_points_marker=self.visual_test(self.centre_points,Marker.POINTS, color, scale)
Пример #33
0
 def LaserDataMarker(self,LaserData): ####################visual_test
  color=ColorRGBA()
  scale=Point()
  scale.x=0.04
  scale.y=0.04
  color.r=0.0
  color.g=2.0
  color.b=0.0
  color.a=1.0
  
  self.laser_points_marker=self.visual_test(LaserData, Marker.POINTS, color, scale)
 def clear_area_makers(self):
  color = ColorRGBA()
  scale = Point()
  scale.x = 0.05
  scale.y = 0.05
  color.r = 0.0
  color.g = 1.0
  color.b = 0.0
  color.a = 1.0
  self.ClearPoints_marker = self.visual_test(self.clear_area, Marker.POINTS, color, scale)
  print 'finish build markers', len(self.ClearPoints_marker.points)
Пример #35
0
def changeColor():
	pub = rospy.Publisher('light_controller/command', ColorRGBA)
	rospy.init_node('light_test')
	
	rospy.sleep(1)
	
	#color in rgb color space ranging from 0 to 1
	red = ColorRGBA()
	red.r = 1
	red.g = 0
	red.b = 0
	red.a = 1
	
	yellow = ColorRGBA()
	yellow.r = 0.4
	yellow.g = 1
	yellow.b = 0
	yellow.a = 1
	
	green = ColorRGBA()
	green.r = 0
	green.g = 1
	green.b = 0
	green.a = 1
	
	blue = ColorRGBA()
	blue.r = 0
	blue.g = 0
	blue.b = 1
	blue.a = 1
	
	white = ColorRGBA()
	white.r = 0.3
	white.g = 1
	white.b = 0.3
	white.a = 1
	
	for color in [red,yellow,green,white,blue,green]:
		rospy.loginfo("Setting rgb to [%lf, %lf, %lf] with a [%lf]",color.r,color.g,color.b,color.a)
		pub.publish(color)
		time.sleep(3)
Пример #36
0
def changeColor():
	pub = rospy.Publisher('light_controller/command_mode', LightMode, queue_size=1)
	rospy.init_node('light_test')
	light_mode = LightMode()
	#color in rgb color space ranging from 0 to 1
	red = ColorRGBA()
	red.r = 1
	red.g = 0
	red.b = 0
	red.a = 1

	yellow = ColorRGBA()
	yellow.r = 0.4
	yellow.g = 1
	yellow.b = 0
	yellow.a = 1

	green = ColorRGBA()
	green.r = 0
	green.g = 1
	green.b = 0
	green.a = 1

	blue = ColorRGBA()
	blue.r = 0
	blue.g = 0
	blue.b = 1
	blue.a = 1

	white = ColorRGBA()
	white.r = 0.3
	white.g = 1
	white.b = 0.3
	white.a = 1

	for color in [red,yellow,green,white,blue,green]:
		rospy.loginfo("Setting rgb to %s [%d, %d, %d]",color.r,color.g,color.b,color.a)
		light_mode.colors= 27*[color]
		pub.publish(light_mode)
		time.sleep(3)
Пример #37
0
    def create_plan_marker(self, plan, plan_values):
        # create an interactive marker for our server
        int_marker = InteractiveMarker()
        int_marker.header.frame_id = "/map"
        int_marker.name = plan.ID
        int_marker.description = plan.ID
        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.1

        # random.seed(float(plan.ID))
        # 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 = []
        for view in plan.views:
            x = view.get_ptu_pose().position.x
            y = view.get_ptu_pose().position.y
            z = 0.0 # float(plan.ID) / 10
            p = Point()
            p.x = x - int_marker.pose.position.x  
            p.y = y - int_marker.pose.position.y
            p.z = z - int_marker.pose.position.z
            line_marker.points.append(p)

            line_marker.colors = []
            for i, view in enumerate(plan.views):
                color = ColorRGBA()
                val = float(i) / len(plan.views)
                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
Пример #38
0
    def callLedsForStraightMv(self, status):

        fColor = ColorRGBA()
        sColor = ColorRGBA()

        fColor.r = 0
        if status == 'STRAIGHT':
            fColor.g = 0
            fColor.b = 0.9
        else:
            fColor.g = 0.9
            fColor.b = 0
        sColor.r = 0
        sColor.g = 0.9
        sColor.b = 0

        ledGroup = LedGroup()
        ledGroup.ledMask = 3  # binary mask to decide which leds are active
        try:
            self.LEDS_FADE(ledGroup, fColor, sColor, rospy.Duration(0.5), True, rospy.Duration(2), 50)
        except rospy.ServiceException, e:
            print "Service call failed: %s" % e
Пример #39
0
    def callLedsForTurningMv(self, side):

        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()
        if side == 'LEFT':
            ledGroup.ledMask = 1  # binary mask to decide which leds are active
        else:
            ledGroup.ledMask = 2

        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
Пример #40
0
 def __init__(self):
     #ROSのパブリッシャなどの初期化
     #rospy.init_node('ccaviz', anonymous=True)
     self.mpub = rospy.Publisher('visualization_marker_array', MarkerArray, queue_size=10)
     self.carray = []
     clist = [[1, 0, 0, 1], [0, 1, 0, 1], [1, 1, 0, 1], [1, 0.5, 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)
Пример #41
0
def createPointLine (marker, d=0.1, n=50.0):
        
    t = 0.0
    while t < d:
        p = Point()
        p.z = t
        c = ColorRGBA()
        c.b, c.a = 1, 0.5
        
        marker.points.append(p)
        marker.colors.append(c)
        
        t += d/n
Пример #42
0
    def createPointsInMarker(self, data):
	# track_no_idx = 0
	# for i in range(0,768,12):
	for track_no_idx in self.track_no_idxs:
	# if not self.rangerate[track_no_idx] == 81.91:
	    point = Point()
	    dist  = self.dist [track_no_idx] #data.data[i+9] * .1
	    angle = self.angle[track_no_idx] #data.data[i+11]* .1
	    angle_rad = math.radians(angle)
	    point.x = - dist * math.sin(angle_rad)
	    point.y = - dist * math.cos(angle_rad)
	    point.z = 0
	    color = ColorRGBA()
	    if self.movingflags[track_no_idx]:
		color.r = 1.0
		color.g = 0.0
		color.b = 0.0
	    else:
		color.r = 0.0
		color.g = 1.0
		color.b = 0.0
	    color.a = 1.0
	    self.marker.points.append( point)
	    self.marker.colors.append( color)
Пример #43
0
def talker():
    lpub = rospy.Publisher('left_eye', ColorRGBA)
    rpub = rospy.Publisher('right_eye', ColorRGBA)
    rospy.init_node('led_tester')

    while not rospy.is_shutdown():
        t = rospy.get_rostime().to_sec()

        k = 4.0
        msg = ColorRGBA()
        msg.r = ( 1.0 + sin(0.0 + (k*t)) ) / 2.0
        msg.g = ( 1.0 + sin(2.1 + (k*t)) ) / 2.0
        msg.b = ( 1.0 + sin(4.2 + (k*t)) ) / 2.0

        pub.publish(msg)
        rospy.sleep(.1)
Пример #44
0
 def get_many_vectors(self):
     arrows = MarkerArray()
     coords = []
     i = 0
     color = ColorRGBA(0.0, 1.0, 0.0, 1.0)
     for lat in np.linspace(0, np.pi, 10):
         color.g += 0.1
         color.b = 0
         for lon in np.linspace(0, 2 * np.pi, 10):
             color.b += 0.1
             coords.append((lat, lon, 1, i, copy.copy(color)))
             i += 1
     arrows.markers = [
         create_arrow_marker(self.ell_space.ellipsoidal_to_pose(lat, lon, height), i, clr)
         for lat, lon, height, i, clr in coords
     ]
     return arrows
Пример #45
0
    def __init__(self):
        self.jsonInput()

        super(CCA, self).__init__()

        self.initUI()
        rospy.init_node('ros_cca', anonymous=True)
        self.mpub = rospy.Publisher('visualization_marker_array', MarkerArray, 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) 
Пример #46
0
def setLightCyanCircle_cb(req):
    rospy.wait_for_service('/light_torso/set_light')

    try:
      set_light_torso = rospy.ServiceProxy("/light_torso/set_light",SetLightMode)
      light_mode = LightMode()
      cyan_color = ColorRGBA()
      cyan_color.r = 0.0
      cyan_color.g = 1.0
      cyan_color.b = 0.5
      cyan_color.a = 0.4
      light_mode.colors.append(cyan_color)
      light_mode.mode = 7
      resp = set_light_torso(light_mode)
      print resp
      return
    except rospy.ServiceException, e:
        print "Service call failed: %s"%e
Пример #47
0
    def __init__(self):
        #ROSのパブリッシャなどの初期化
        #rospy.init_node('ccaviz', anonymous=True)

        fname = "/home/uema/catkin_ws/src/pose_cca/datas/20160520_a2.json"
        poses1, poses2, dts, dtd = self.json_pose_input(fname)
        self.poses1, self.poses2 = self.select_datas(poses1, poses2)
        #print poses1.shape

        self.mpub = rospy.Publisher('visualization_marker_array', MarkerArray, queue_size=10)
        self.carray = []
        clist = [[1, 0, 0, 1], [0, 1, 0, 1], [1, 1, 0, 1], [1, 0.5, 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)
Пример #48
0
        
        if remove_im() == True:
            
            object_added = False
            
 
    if object_added == False:
 
        add_object = rospy.ServiceProxy('/interaction_primitives/add_object', AddObject)
        rospy.loginfo('Calling %s service','/interaction_primitives/add_object')
    
        # color of the bounding box
        color = ColorRGBA()
        color.r = 1
        color.g = 1
        color.b = 0
        color.a = 1
           
        try:
          
            add_object(frame_id = '/map',
                       name = 'unknown_object',
                       description = 'Unknown object to grasp',
                       pose = est_result.pose,
                       bounding_box_lwh = est_result.bounding_box_lwh,
                       color = color,
                       use_material = False)
            
            object_added = True
            
            rospy.loginfo('IM added')