About vision.get_by_code(...) and vision.read_by_code(...)

#define DATASUM 2;
std::array<pros::vision_object_s_t, DATASUM> _data = {0}; 
void VisionData::loop()
    while (true)
        uint32_t now = pros::millis();
        if (_mode == 0)
            _visionF.read_by_size(0, DATASUM, _data.data());
            // _data[0] = _visionF.get_by_code(0, 10);
            // _data[1] = _visionF.get_by_code(1, 10);
            _visionF.read_by_code(0, 10, DATASUM, _data.data());
        pros::Task::delay_until(&now, 50);

I want to make real-time changes to vision working mode.
if i use

             _data[0] = _visionF.get_by_code(0, _myColor);
             _data[1] = _visionF.get_by_code(1, _myColor);

it will return my color code. it’s right .
if i use

            _visionF.read_by_code(0, 10, DATASUM, _data.data());

it will return error data.
What’s the difference between these two functions?

Can vex sdk give a threshold adjustment function with use creat_color_code?
flag has two colors .red&&blue + green;
But the flag is transparent in the middle
As a result, it’s hard to find the flag “get_by_code”.
We use logic rather than mathematics to combine color blocks now. It’s too inefficient.

1 Like