Jump to content

Camera (Pitch & Yaw) Help


Recommended Posts

Posted

So for some reason I cannot set the camera to move to specific pitch and yaw degrees. Everytime I do I get different results on current pitch and yaw.

My Code:

if (camera != null) {
    targetPitch = random(22, 67);
    targetYaw += 1;
    camera.movePitch(targetPitch);
    camera.moveYaw(targetYaw);
    log("Camera moved successfully to position [Current(Pitch: " + camera.getPitchAngle() + ", Yaw:" + camera.getYawAngle() + "), Target(Pitch: " + targetPitch + ", Yaw: " + targetYaw + ")]");
    return;
}



Results (Log):

Camera moved successfully to position [Current(Pitch: 24, Yaw: 0), Target(Pitch: 25, Yaw: 7)]
Camera moved successfully to position [Current(Pitch: 33, Yaw: 1), Target(Pitch: 33, Yaw: 8)]
Camera moved successfully to position [Current(Pitch: 58, Yaw: 3), Target(Pitch: 57, Yaw: 9)]

 

Is there a way I can get it to the specific target, so I'm able to do a check with a boolean statement?

Posted (edited)

camera.movePitch() and camera.moveYaw()  both return boolean so you can use them in an if statement.

if you want to turn to a target or position you can  use  toEntity or toPosition .

More info here. https://osbot.org/api/org/osbot/rs07/api/Camera.html

 

You're using a random number for your pitch and your target yaw is just your old value +1. If you want to test a specific location put a specific number as your target.

 

Edited by zwaffel
Posted
On 6/5/2019 at 6:23 PM, zwaffel said:

camera.movePitch() and camera.moveYaw()  both return boolean so you can use them in an if statement.

if you want to turn to a target or position you can  use  toEntity or toPosition .

More info here. https://osbot.org/api/org/osbot/rs07/api/Camera.html

 

You're using a random number for your pitch and your target yaw is just your old value +1. If you want to test a specific location put a specific number as your target.

 

That actually helped me knowing it was a boolean statement, but it did not solve trying to set the actual pitch and yaw to it's specific target.

On 6/5/2019 at 6:50 PM, Neanel said:

Those functions have a margin of +-6, I believe.

But as zwaffel mentioned both return a boolean either way.
Or you could check if the currentPitch is within 6 of the targetPitch.
Or you could keep recalling the function until it has the exact position you want.

Recalling the function doesn't help any, still ends up being the same, and yeah currently working on a fix for when the camera stops moving to return another boolean as true, hopefully this will solve my issue.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...