从A点到B点路程共50m,从起点开始运动,起始和结束速度为0,最大速度5m/s,最大加速度2m/s2,最大减速度2m/s2,分别使用T型和S型速度规划, 使用S型时最大加加速度4m/s3。
代码如下:
int main(int argc, char *argv[])
{
if (argc != 2)
{
printf( "Usage: ./velocity_test 0/1\n");
return -1;
}
velocity_handle handle = NULL;
if(strcmp(argv[1], "0") == 0)
{
handle = velocity_new_t();
velocity_set_config(handle, 5, 2, 2, 0);
}
else if(strcmp(argv[1], "1") == 0)
{
handle = velocity_new_s();
velocity_set_config(handle, 5, 2, 2, 4);
}
else
{
printf( "Usage: ./velocity_test 0/1\n");
return -1;
}
velocity_set_plan(handle, 50, 0, 0);
double time = velocity_get_plan_time(handle);
for(double t = 0; t < time; t+=0.001)
{
double pos = 0, vel = 0, acc = 0;
velocity_get_plan_slice(handle, t, &pos, &vel, &acc);
printf("pos:%f, vel:%f, acc:%f\n", pos, vel, acc);
}
velocity_delete(handle);
return 0;
}
ZMC600E 运动控制器提供T型和S型速度规划算法可以满足不同应用场景下的速度控制需求。深入掌握速度规划技术,将有助于提高设备的控制精度和效率,为工业生产带来更大的价值。