I need to create a code that tracks black on a grey marble floor, im not sure how to start it so If anyone could help or point me in the right direction that would be great its for a sumo project for in class robotics.
weilin
December 14, 2019, 10:14am
#2
Let us know if any of these are helpful for what you are doing:
http://cdn.robotc.net/pdfs/natural-language/hp_line_follower.pdf
2 Likes
This helps but I was looking for a program on Vexcode or vcs that implements the 3wire port to test if it works I know how to program it in Robotc but I know VexCode and vcs is different. is there anyway someone could make a sample file of the code using line tracker?
1 Like
weilin
December 19, 2019, 8:41am
#4
Please, look at this example of how 3-wire ports can be programmed with V5:
The issue is that the build system will not guarantee the order in which instances are created across different source files.
The instance of Brain is defined I’m assuming somewhere else such as robot-config.cpp. That means it may not have been created, and therefore the Brain.ThreeWirePort also not created, when you try to access it in your main.cpp source file. The solution is to either move
bumper LiftBumper = bumper(Brain.ThreeWirePort.A);
into the same file (and placed after) as the Br…
Code would be the same for VEX C++ and C++ Pro, somewhere an instance of a line sensor needs to be declared.
vex::line Line( Brain.ThreeWirePort.A );
or alternatively, just use a potentiometer device, they are both analog sensors returning the same values.
After you configure the port, you can read line follower by calling value() function, see the API
https://api.vexcode.cloud/v5/html/classvex_1_1line.html
Then you treat it the same as in the older RobotC code examples.
More topics with examples:
Create an instance of a light sensor, it’s probably not in the robot config as it’s not an often used sensor, it should be in the drawer when using C++ Pro
light Light( Brain.ThreeWirePort.A );
int main() {
while(1) {
int value = Light.value( analogUnits::range12bit );
Brain.Screen.printAt( 10, 50, "Light Sensor %d", value);
// Allow other tasks to run
this_thread::sleep_for(10);
}
}
Using 3-wire Line Trackers in a VEX V5 project: These projects demonstrate how how to use two of the existing VEX EDR line followers for a mobile robot. Read the Description tab in the projects for details on how this works. We will do new demos when the V5 Vision Sensor supports line detection.
Sample Projects: Blockly Python C++
[image]
Are you using VEX Light Sensor or the Line Tracker Sensor ?
Unlike Light sensor, Line Tracker has its own built-in infrared light source and doesn’t need any additional lighting.
Here is a great resource on how to use Line Trackers:
The main problem that I see with your code is that motor values for turnleft() and straight() are incorrect. Also you don’t have to start new task every time you need to adjust your heading.
And this is the sample code for the Line Follower robot with Triple Lin…