Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % This function takes in a square positon on the chess board,
- % e.g. 'A2' or 'h8'
- % Returns motor angles based off calibration values
- % +------------------------+
- % |a8 h8|
- % | |
- % | |
- % | |
- % | |
- % |a1 h1 |
- % +------------------------+
- % TODO:
- % If X,Y motor axes not perpendicular and parallel to
- % respective sides of chess board, need to calculate
- % based off the board being diagonal
- function [bigDC, smallDC] = squareToDegrees(spot)
- % Make sure spot is 2 chars long
- if length(spot) ~= 2
- fprintf("Error: square spot not 2 chars.\n");
- return;
- end
- % Get ascii values for spot
- ascii = double(spot);
- %% CALIBRATION
- % Going from h1 to h8, bigDC Motor values for each square
- % Based off -12800 at 8, 0 at 1
- calibrationBigDC = [-12800, -10971, -9143, -7314,...
- -5486, -3657, -1829, 0];
- % Going from a1 to h1, smallDC motor values for each square
- % These calculated based off -21500 at a, 0 at h
- calibrationSmallDC = [-21500, -18426, -15355, -12284, ...
- -9213, -6142, -3071, 0];
- %% USE CALIBRATION
- % ascii(1) = 97 for a, 104 for h (-96 gives 1through8)
- smallDC = calibrationSmallDC(ascii(1) - 96);
- % ascii(2) = 49 for '1', 56 for '8' (-48 gives 1through8)
- bigDC = calibrationBigDC(8 - (ascii(2) - 48 - 1));
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement