Need help getting a 2D vector representing the direction of the joystic

Originally posted here in official answers locked forum:

Drag the GetJoystickAnalog block from the left menu into your program flow, to get the popup dialog box.
Click the Help button at the bottom.

If the following text were in the Help, your questions would have been answered there.

  • Channel (1…4), The mapping of channel to sticks is shown on the cover of the Vexnet Joystick, as shown by this picture:
    [https://vexforum.com/wiki/index.php/VEXnet_Joystick
  • GetJoyStickAnalog return variable type is ‘int’ as seen in the right hand EasyCv4 window Project Explorer, Header file API.h
  • The value returned has a range from +127 to -127

Line Follower: first step is to see the sample code provided with EasyCv4,
File Menu, Open Project, Samples (bottom left corner) LineFollowerTest to see how to read the line follower sensor.
To get ideas on how to implement a program to autonomously follow a line,
use the Search feature of vexforum:
There are four pages of threads under “line follower”](https://vexforum.com/wiki/index.php/VEXnet_Joystick)

Some more clarification on the joystick channels:
Channel 1 is the side-to-side motion of the right joystick.
Channel 2 is the up-and-down motion of the right joystick.
Channel 3 is the up-and-down motion of the left joystick.
Channel 4 is the side-to-side motion of the left joystick.

The value of a channel in a program is dictated by its position. If the right joystick is not touched and is exactly centered, then Channels 2 and 3 = 0. If the right joystick is moved as far up as it can go and is not moved to the side, then Channel 2 = 127 and Channel 3 = 0. If the right joystick is all the way down and not moved at all to one side then Channel 2 = -127 and Channel 3 = 0.

If you are looking for straight up vectors this would be how to find them.


joystick1 = GetJoystick(1);
joystick2 = GetJoystick(2);
joystick3 = GetJoystick(3);
joystick4 = GetJoystick(4);

You don’t need to code these, just drag them from the joystick panel.

The directional vector would be

joystick1 i + joystick2 j for the right stick and

joystick4 i + joystick3 j for the left.