Start to code for programming skill

Hello,

My robot works well with controller. Now, I start to code for programming skill. Do I need add sensor to my robot? Otherwise, how it knows where to turn or pick stuff?

Thank you!

basic programing does not need sensors, ex: (vex code v5 pro)

Right.spin (vex::directionType::rev, 100 , vex::velocityUnits::pct );
Right2.spin(vex::directionType::rev, 100 , vex::velocityUnits::pct );
Left.spin  (vex::directionType::rev, 100 , vex::velocityUnits::pct );
Left2.spin (vex::directionType::rev, 100 , vex::velocityUnits::pct );
wait (.5, seconds);
Right.stop();
Right2.stop();
Left.stop();
Left2.stop();
//turning 
Right.spin  (vex::directionType::rev, 50, vex::velocityUnits::pct );
Right2.spin (vex::directionType::rev, 50 , vex::velocityUnits::pct );
Left.spin   (vex::directionType::fwd, 50 , vex::velocityUnits::pct );
Left2.spin  (vex::directionType::fwd, 50 , vex::velocityUnits::pct );
wait (.95, seconds);
Right.stop();
Right2.stop();
Left2.stop();
Left.stop(); 

but you can use sensors to make more complex code

Thank you. Yes, I was thinking the exact codes you showed. Then, my robot would always start from a specific point, repeat the same route. I need to calculate exact how long it runs, and then turns, and picks rings, correct? If anything unexpected happens, my robot is lost. Is this the way to go?

this is the most simple way to program it, without sensors, it will be somewhat inaccurate because the real world works in annoying ways (you can introduce sensors with the waitUntil(); command). i had done my first two years of robotics without sensors, and i could get it really accurate, but with a lot of testing.

also, the V5 smart motors have motor encoders built-in so you can use them to make it a bit more accurate.

a bit more is quite the understatement here.

2 Likes

from what i have seen, the main reason my auton is inaccurate is because the wheels slip , so when i used the encoders, it was almost the same. (so now i am using an inertial sensor)

1 Like

I’m sure if you dig enough into control algorithms such as PID you’ll find out why encoders are far superior than time based autonomouses using bang bang.

2 Likes

yeah, but if you are just starting, i say get the basics down before going for a PID controller, as you need to understand the program you use. (at least according to rule < G6 >)

If we’re talking about fundementals here, I’d still tell a new team to attempt to use encoder ticks with at least some sort of p loop style code that slows the robot down before it gets to its target. Time based leaves bad habits that are harder to break once the team gets comfortable with not using sensor based code.

2 Likes

Thank you @7996B and @RanchSauce very much. I’m using VexCode V5 right now. Let me start without sensor first.

1 Like