VRC Change Up 2020-2021 Dev Log

VRC Change Up 2020-2021 Dev Log

I will record every time of club activity here, normally once a week, regarding coding log and other working tasks. repo: vexcode_changeup05/31/20 Summary Today we officially began our new season robotics development. To be honest, I have less time available this season due to my SAT and TOEFL ex
Read More
My first VEX tournament of the season

My first VEX tournament of the season

Now I am on the bullet train from Xi’an to Baoding, crossing one tunnel after another, passing one bridge after another. Just a few minutes ago, I was sleeping deeply, but now I think I am conscious. Sleepless night From the beginning of the summer vacation, I was studying TOEFL everyday followi
Read More
VEX programming tips

VEX programming tips

使用万能的电机控制自定义函数

由于电机的端口是一个motor类型的变量,所以我们可以将电机当作变量传参。

模板

1
2
3
4
5
void m(motor motorname,int speed=100,int tor=100) //定义一个名为m的函数,三个参数分别是电机端口、速度(默认100)、力矩(默认100)。
{
motorname.setMaxTorque(tor,percentUnits::pct);
motorname.spin(directionType::fwd,speed,percentUnits::pct);
}

实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 底盘四个电机全功率向前1000ms
using namespace vex;
void test()
{
//四个电机同时以速度100,力矩100向前
m(MotorLF,100,100);
m(MotorLB,100,100);
m(MotorRF,100,100);
m(MotorRB,100,100);
//延时1000ms
task::sleep(1000);
//四个电机同时停
m(MotorLF,0);//由于在这里(一般情况下)力矩默认都为100,所以可以直接不传入力矩这个参数,跳过即可)
m(MotorLB,0);
m(MotorRF,0);
m(MotorRB,0);
}
Read More