2

Using CeeBot, I haven't found a way to get the tilt angle of a robot.

For example, if the robot have to shoot at an enemy, it has to change the angle of the canon to aim at the enemy.

But if the robot is not on a flat ground, but on a steep, the angle of the canon will have to take into account the angle of the steep.

Is it possible to know this angle ?

4

1 回答 1

1

您正在寻找机器人的“音高”值。

例如,这个相对简单的代码段找到最近的 TargetBot,然后使用音高值加上一些基本的三角函数将正确的值输入到 aim()

//our variables
object KillMe;
float range;
float ZDif;
float absoluteElevation;
float correctedElevation;


//calculate the angle we need to adjust our cannon
range = distance(this.position, KillMe.position);
absoluteElevation = atan((KillMe.position.z - position.z)/distance(this.position,KillMe.position));
correctedElevation = absoluteElevation - pitch;

aim(correctedElevation);
fire(0.1);

显然,它没有考虑您正在使用的特定机器人武器的最小/最大高度,或者它的最小-最大范围。

于 2013-11-13T21:53:53.520 回答