Jump to content

Camera (Pitch & Yaw) Help


Ex0rcism

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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