Accessing Sensor Values from Windows Terminal

I was planning a potential project for experimenting with productivity with higher dimensions of maneuverability. Essentially, I’m trying to create a 3D mouse for my computer using VEX parts.

The controller (mouse) is connected to 3 strings, each coming out of different points in the framework. Each string is attached to a pulley on an axis.

There are 2 other pulleys on each axis connected to rubber bands. The purpose of these rubber bands is to pull slack out of the strings.

Each axis also has a potentiometer (or shaft encoder) connected to it to measure how far the string is pulled out. Each sensor value is used to triangulate the position of the controller. Simple enough.

The question I needed to ask was:
Is it possible to pull sensor values from a connected VEX brain for use in terminal programs (such as Python)? And if so, how?

Thanks in advance.

Use PROS for this.

PROS uses a standard serial interface for its debugging capability. Additionally, sample software already exists: JINX uses Python to parse data sent by PROS on the Cortex (make sure to work on optimization, though: the computer-side Python software JINX uses is definitely not fast enough as it stands currently for 3D mouse usage).

JINX isn’t really the right application for this sort of thing. That being said, you can definitely use PROS to publish any data off of the Cortex. What you could do for something like this is


printf

the data and use a library such as pyserial to read the data.

Your Cortex code could be something as simple as:


void operatorControl() {
     while(1) {
           printf("%d,%d,%d\n", analogRead(1), analogRead(2), analogRead(3));
           delay(20);
     }
}

pyserial will give you whatever the Cortex prints as a string, and then you can parse it using typical Python. There’s nice tutorials for getting data using pyserial, and tutorials on parsing your data. The PROS CLI is made using Python, you can check that out here (but what we do is quite a bit more than what you’re trying to do - but the fundamentals are the same). Also, you may want to have some code for finding a Cortex that’s connected to your laptop which made here.

As a side thought, you could use Powershell and simply pipe the output of


pros terminal

to your Python program and just read the input of that. As in you wouldn’t have to worry about any serial code and simply do


pros terminal | python my3dMouse.py

Hope this helps