Skip to content

Commit

Permalink
solved setPose for real now
Browse files Browse the repository at this point in the history
  • Loading branch information
felipetrentin committed May 7, 2022
1 parent 9ba8793 commit 6b9579e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/src/main/cpp/t265wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// <https://www.gnu.org/licenses/>.

#include <jni.h>
#include <librealsense2/rs.hpp>
#include "librealsense2/rs.hpp"
#include <mutex>
/* Header for class com_spartronics4915_lib_T265Camera */

Expand Down
15 changes: 9 additions & 6 deletions lib/src/main/java/com/spartronics4915/lib/T265Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,15 @@ public void sendOdometry(double velocityXMetersPerSecond, double velocityYMeters
*/
public synchronized void setPose(Pose2d newPose) {
synchronized (mUpdateMutex) {
Pose2d campose = (mLastRecievedCameraUpdate == null
? new Pose2d()
: mLastRecievedCameraUpdate);

//camera offset, relative to arena
mOriginOffset =
newPose.relativeTo(
mLastRecievedCameraUpdate == null
? new Pose2d()
: mLastRecievedCameraUpdate);
new Pose2d(
newPose.getTranslation().minus(campose.getTranslation().rotateBy(campose.getRotation().times(-1).plus(newPose.getRotation()))),
newPose.getRotation().minus(campose.getRotation()));
}
}

Expand Down Expand Up @@ -416,8 +420,7 @@ private synchronized void consumePoseUpdate(
}

final Pose2d transformedPose =
mOriginOffset.transformBy(
new Transform2d(currentPose.getTranslation(), currentPose.getRotation()));
mOriginOffset.transformBy(new Transform2d(currentPose.getTranslation(), currentPose.getRotation()));

mPoseConsumer.accept(
new CameraUpdate(transformedPose, new ChassisSpeeds(dx, dy, dtheta), confidence));
Expand Down

0 comments on commit 6b9579e

Please sign in to comment.