def trigger(self): co = Color() co.header.frame_id = self.frame_id co.header.stamp = rospy.Time.now() co.r = co.g = co.b = 0.0 if self.sensor.light_mode: co.intensity = self.sensor.get_reflected_light() color_light = self.sensor.get_light_color() if color_light == Type.COLORRED: co.r = 1.0 co.g = 0.0 co.b = 0.0 elif color_light == Type.COLORGREEN: co.r = 0.0 co.g = 1.0 co.b = 0.0 elif color_light == Type.COLORBLUE: co.r = 0.0 co.g = 0.0 co.b = 1.0 else: co.r = 1.0 co.g = 1.0 co.b = 1.0 else: co.intensity = 0.0 color = self.sensor.get_color() if color == 1: # black co.r = 0.0 co.g = 0.0 co.b = 0.0 elif color == 2: # blue co.r = 0.0 co.g = 0.0 co.b = 1.0 elif color == 3: # green co.r = 0.0 co.g = 1.0 co.b = 0.0 elif color == 4: # yellow co.r = 1.0 co.g = 1.0 co.b = 0.0 elif color == 5: # red co.r = 1.0 co.g = 0.0 co.b = 1.0 elif color == 6: # white co.r = 1.0 co.g = 1.0 co.b = 1.0 else: rospy.logerr('Undefined color detected by the Color sensor') self.pub.publish(co)
def trigger(self): co = Color() co.header.frame_id = self.frame_id co.header.stamp = rospy.Time.now() co.intensity = 0.0 color = self.color.get_color() if color == 1: # black co.r = 0.0 co.g = 0.0 co.b = 0.0 elif color == 2: # blue co.r = 0.0 co.g = 0.0 co.b = 1.0 elif color == 3: # green co.r = 0.0 co.g = 1.0 co.b = 0.0 elif color == 4: # yellow co.r = 1.0 co.g = 1.0 co.b = 0.0 elif color == 5: # red co.r = 1.0 co.g = 0.0 co.b = 1.0 elif color == 6: # white co.r = 1.0 co.g = 1.0 co.b = 1.0 else: rospy.logerr('Undefined color of color sensor') self.pub.publish(co)
def trigger(self): co = Color() co.header.frame_id = self.frame_id co.header.stamp = rospy.Time.now() co.r = self.color_r co.g = self.color_g co.b = self.color_b co.intensity = self.intensity.get_reflected_light(self.color) self.pub.publish(co)
def trigger(self): co = Color() co.header.frame_id = self.frame_id co.header.stamp = rospy.Time.now() #co.r = self.color_r #co.g = self.color_g #co.b = self.color_b # changed get_reflected_light(self.color) -> get_sample() co.intensity = self.intensity.get_sample() self.pub.publish(co)
def trigger(self): co = Color() co.header.frame_id = self.frame_id co.header.stamp = rospy.Time.now() co.r = self.color_r co.g = self.color_g co.b = self.color_b # Get the reflected light reading. # This turns on the LED if color = red/green/blue co.intensity = self.intensity.get_reflected_light(self.color) self.pub.publish(co)