Shaft Encoders - VEXcode Pro V5 Text

My team, on our new robot, installed shaft encoders for all of our wheels. How do I enter it into the robot config.ccp? So far I got this:

encoder LeftDriveEncoder = encoder(const encoder &);

I’m not sure what I am supposed to put in the parenthesis.

Well I just changed it to “inertial” instead of “encoder”, and put “PORT1” into the parenthesis, and the error went away. Would that work?

No, that would initialize an inertial sensor, which is not a shaft encoder, and connects to the brain using a smart port rather than 2 3-wire ports.

Some code to initialize an encoder might look like:

encoder LeftDriveEncoder = encoder(Brain.ThreeWirePort.A);

That’s if your encoder is connected to ports A and B - for one of the other supported combinations (C&D, E&F, G&H), substitute the lower letter (C, E, or G, respectively).

1 Like

Thank you, I did that and everything seems to be in order. By any chance do you know how to program it for autonomous?

“How to program a shaft encoder for autonomous” would depend on a number of factors, chief among which is, what functionality do you want the sensor to enable?

You may find the API reference helpful.

1 Like

I was told that the encoders could be used to create a sort of coordinate plane across the field, in which I could send the robot to certain x and y coordinates.

Using tracking wheels to keep track of the robot’s absolute position throughout the match is commonly called “odometry” or “position tracking” - this document from team 5225A is a good introduction. A forum search will turn up lots of useful results as well.

1 Like

Okay, will do. I will also attempt to understand this document of yours, although I am not entirely fluent in whatever language that is at this time. Anyways, thank you for deciding I am worth your time.

I couldn’t find any examples for VEXcode Pro V5 Text. Can anyone help?

There won’t be examples for odometry in VEXcode Pro V5 Text. You will have to program it yourself. Matlab is hosting a seminar on Feb 3rd from 7-9, which will explain how to implement odometry, as well as other concepts such as PID.

If you are asking about encoders, just use the API. The new VEXcode V5 Pro Text will not have any example programs of using this sensor.

1 Like

That’s not what I meant. There isn’t anything in the forums that actually explains how to program it, which holbrook suggested. Also, I didn’t really understand the document he linked at all. It doesn’t even mention actual programming, with any language, just some equations and stuff I can’t even incorporate into V5 Text.

There aren’t many example of odometry in the forum because not many people give templates on how to program odometry. It is probably the most complicated control thing that people spend months learning how to program. I am also actively trying to learn odometry right now. Like I said, the Webinar on February 3rd will help program the odometry function. I should also mention that you can incorporate the functions into V5 text. It will just take some more programming.

1 Like

Yes, I get what you mean. Well I can’t make it to the seminar, and I’m also not very skilled in math or programming, so I doubt I’ll get anywhere. Anyways thanks for you help.

I believe that they will have the files available for use and a recording of the seminar. You would just have to email this address:

They might have more seminars in the future.

I shooted them some mail. Hopefully I will get that and gain some brain cells trying even harder to comprehend this… stuff. I am thanking you once again.