Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gabe noisy light #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
@@ -1,3 +1,5 @@
Gabe: Currently adding noise to get\_ambientlight().

# Kilosim: Kilobot Simulator

[![Build Status](https://travis-ci.com/jtebert/kilosim.svg?token=s6ZVW1bvfNjgbZQh2x9M&branch=master)](https://travis-ci.com/jtebert/kilosim)
Expand Down Expand Up @@ -67,4 +69,4 @@ There are no fixed requirements for the contents of the configuration files; it'

**TBD**

This shouldn't be publicly used or shared until a license has been set for this software.
This shouldn't be publicly used or shared until a license has been set for this software.
5 changes: 4 additions & 1 deletion src/LightPattern.cpp
Expand Up @@ -39,7 +39,10 @@ uint16_t LightPattern::get_ambientlight(const double x, const double y) const
// Convert the color from RGB to grayscale using approximate luminosity
// Each value is 8-bit, so the resulting value is in the scale [0-255]
double luminosity = (0.3 * c.r) + (0.59 * c.g) + (0.11 * c.b);
// Scale to 10-bit [0-1023]
double std_dev = -0.0001123*luminosity*luminosity + 0.2197*luminosity + 0.8684; // polynomial std_dev
//double std_dev = 0.13*luminosity + 6.1; // linear std_dev
luminosity = normal_rand(luminosity, std_dev);

uint16_t lum_10bit = (uint16_t)luminosity * 4;
return lum_10bit;
}
Expand Down
3 changes: 2 additions & 1 deletion src/LightPattern.h
Expand Up @@ -10,6 +10,7 @@
#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>
#include "random.hpp"

namespace Kilosim
{
Expand Down Expand Up @@ -92,4 +93,4 @@ class LightPattern
void set_light_pattern(const std::string img_src);
};
} // namespace Kilosim
#endif
#endif