コード例 #1
0
ファイル: simulator.c プロジェクト: RoboticsatUCD/SUMOcode
void new_robot(robot_t * robot, int id)
{
	robot->v = 0.0;
	robot->rotv = 0.0;
	robot->width = 20.0; // 20 centimeters
	robot->mass = 3.0; // 3 kilograms
	
	if(id == 0)
	{
		robot->pos.x = -12.5 - robot->width / 2.0;
		robot->pos.y = 0.0;
		robot->rot = 0.0;
		robot->color = (color_t){255, 0, 0};
	}
	else if(id == 1)
	{
		robot->pos.x = 12.5 + robot->width / 2.0;
		robot->pos.y = 0.0;
		robot->rot = 180.0;
		robot->color = (color_t){0, 0, 255};
	}
	else
	{
		robot->pos.x = 0.0;
		robot->pos.y = 0.0;
		robot->rot = randFloat() * 360.0;//0.0;
		robot->color = rainbowColor(rand() % 1536);
	}
}
コード例 #2
0
uint16_t rainbow(uint16_t tick, uint32_t color) {

  for (uint16_t i=0; i<NUM_LEDS; i++) {
    setLedColor(i, rainbowColor(i+tick, NUM_LEDS));
  }

  return NUM_LEDS;
}
コード例 #3
0
ファイル: simulator.c プロジェクト: RoboticsatUCD/SUMOcode
color_t rainbowColor(int n)
{
	// red -> orange -> yellow
	if(n < 0x100) return RGB(255, n, 0);
	// yellow -> green
	if(n < 0x100 * 2) return RGB((0x100 * 2 - 1) - n, 255, 0);
	// green -> teal
	if(n < 0x100 * 3) return RGB(0, 255, n - (0x100 * 2 - 1));
	// teal -> blue
	if(n < 0x100 * 4) return RGB(0, (0x100 * 4 - 1) - n, 255);
	// blue -> purple
	if(n < 0x100 * 5) return RGB(n - (0x100 * 4 - 1), 0, 255);
	// purple -> red
	if(n < 0x100 * 6) return RGB(255, 0, (0x100 * 6 - 1) - n);
	// poop
	return rainbowColor(n % 1536);
}