Colour sensor's light goes OFF

Hey Team,
I am using UART for Sphero RVR to run this over a Raspberry Pi. The colour sensor switches OFF the light very frequently while it is driving. Whenever the light goes OFF it gives index = 255. At index=255, we are trying to close the use of colour sensor and re-initialise it. But this doesn’t happen.

We were trying to call this function close_color_sensor at 255, but we don’t receive any response

#To close the use of colour sensor when index=255

async def close_color_sensor(self):
        print("Closing the color sensor")
        await self.rvr.enable_color_detection(is_enabled=False)

#To re-initialise colour sensor

async def init_color_sensor(self):
        print("in re-init color sensor")
        await self.rvr.enable_color_detection(is_enabled=True)
        await self.rvr.sensor_control.add_sensor_data_handler(
            service=RvrStreamingServices.color_detection,
            handler=self.color_detected_handler
        )
        await self.rvr.sensor_control.start(interval=250)

Looking forward for your valuable suggestions and solutions

Thank You
Prashastha Kovuri

Hi @Prashastha,

The white LEDs should stay on as long as the color sensor is enabled.

Can you post a full script that reproduces this issue?

Thanks,
Jim

@Sphero_JimK,

Handler for colour sensor

async def color_detected_handler(self, color_detected_data):
        self.index = color_detected_data["ColorDetection"]["Index"]
        print(self.index)
        if(self.index == 255):
            print("255 detected !! Sensor light gone :(")
            await self.close_color_sensor()
            await self.init_color_sensor()

This is how we are initialising colour sensor

async def init_color_sensor(self):
        print("in re-init color sensor")
        await self.rvr.enable_color_detection(is_enabled=True)
        await self.rvr.sensor_control.add_sensor_data_handler(
            service=RvrStreamingServices.color_detection,
            handler=self.color_detected_handler
        )
        await self.rvr.sensor_control.start(interval=250)```

Does the bottom light shut off after 5 minutes of inactivity? That would mean it’s going to standby mode, which disables the color sensor, among other things, to reduce power consumption.

If this fits your observations, you can just make sure your script sends a command more often than every 5 minutes to keep it awake. For a NOP that will just keep it awake you can use rvr.echo(). Check the echo.py example script in getting_started.

If it does not appear to be the inactivity timeout, please post a complete python script that demonstrates the issue and I can find some time to test it.

Jim