开发者

CeeBot : getting robot tilt

Using CeeBot, I haven't found a way to get the tilt a开发者_如何学Gongle 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 ?


You're looking for the "pitch" value of your robot.

For example, this relatively simple code segment finds the nearest TargetBot and then uses the pitch value plus some basic trigonometry to feed the correct value into 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);

Obviously, it doesn't take into account the min/max elevations for the particular bot weapon you're using, or the min-max range of it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜