Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused functions #41

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions include/gtsamutils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -------------------------------------------------------------------- //

Check notice on line 1 in include/gtsamutils.h

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on include/gtsamutils.h

File include/gtsamutils.h does not conform to LLVM style guidelines. (lines 11, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399)

Check notice on line 1 in include/gtsamutils.h

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on include/gtsamutils.h

File include/gtsamutils.h does not conform to LLVM style guidelines. (lines 11, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 129, 130, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399)
// (c) Copyright 2021 Massachusetts Institute of Technology //
// Author: Tim McGrath //
// All rights reserved. See LICENSE file for license information. //
Expand All @@ -8,7 +8,7 @@

#pragma once

#include <vector>

Check failure on line 11 in include/gtsamutils.h

View workflow job for this annotation

GitHub Actions / cpp-linter

/include/gtsamutils.h:11:10 [clang-diagnostic-error]

'vector' file not found

Check failure on line 11 in include/gtsamutils.h

View workflow job for this annotation

GitHub Actions / cpp-linter

/include/gtsamutils.h:11:10 [clang-diagnostic-error]

'vector' file not found
#include <gtsam/geometry/Point3.h>
#include <gtsam/geometry/Rot3.h>
#include <gtsam/geometry/Pose3.h>
Expand All @@ -17,21 +17,11 @@
#include "imu/imu.h"
#include <gtsam/base/numericalDerivative.h>

namespace gtsamutils{

Check warning on line 20 in include/gtsamutils.h

View workflow job for this annotation

GitHub Actions / cpp-linter

/include/gtsamutils.h:20:11 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'gtsamutils' is non-const and globally accessible, consider making it const

Check warning on line 20 in include/gtsamutils.h

View workflow job for this annotation

GitHub Actions / cpp-linter

/include/gtsamutils.h:20:11 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'gtsamutils' is non-const and globally accessible, consider making it const
Eigen::MatrixXd Point3VectorToEigenMatrix(const std::vector<gtsam::Point3>& p);
Eigen::MatrixXd Vector3VectorToEigenMatrix(const std::vector<gtsam::Vector3>& v);
std::vector<gtsam::Rot3> Pose3VectorToRot3Vector(const std::vector<gtsam::Pose3>& poses);
std::vector<gtsam::Point3> Pose3VectorToPoint3Vector(const std::vector<gtsam::Pose3>& poses);
std::vector<double> vectorizePoint3x(std::vector<gtsam::Point3>);
std::vector<double> vectorizePoint3y(std::vector<gtsam::Point3>);
std::vector<double> vectorizePoint3z(std::vector<gtsam::Point3>);
std::vector<double> vectorizeVector3X(std::vector<gtsam::Vector3>);
std::vector<double> vectorizeVector3Y(std::vector<gtsam::Vector3>);
std::vector<double> vectorizeVector3Z(std::vector<gtsam::Vector3>);
std::vector<double> vectorizeQuaternionS(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>>);
std::vector<double> vectorizeQuaternionX(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>>);
std::vector<double> vectorizeQuaternionY(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>>);
std::vector<double> vectorizeQuaternionZ(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>>);
std::vector<double> vectorSetMagnitudes(const std::vector<Eigen::Vector3d>& v);
Eigen::MatrixXd vectorRot3ToYprMatrix(const std::vector<gtsam::Rot3>& R);
std::vector<gtsam::Rot3> imuOrientation(const imu& myImu); // pull out stored quaternion as a vector<Rot3>
Expand All @@ -40,7 +30,6 @@
gtsam::Vector3 gyros_Vector3(const imu& myImu, const int& idx);
Eigen::MatrixXd gyroMatrix(const imu& myImu);
Eigen::MatrixXd accelMatrix(const imu& myImu);
double median(std::vector<double> v);
uint nearestIdxToVal(std::vector<double> v, double val);
void saveMatrixToFile(const gtsam::Matrix& A, const std::string &s, const std::string& filename);
void writeEigenMatrixToCsvFile(const std::string& name, const Eigen::MatrixXd& matrix, const Eigen::IOFormat& CSVFormat=Eigen::IOFormat(Eigen::StreamPrecision, Eigen::DontAlignCols, ", ", "\n"));
Expand Down
92 changes: 1 addition & 91 deletions src/gtsamutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,7 @@ namespace gtsamutils{
}
return accels;
}

double median(std::vector<double> len){
assert(!len.empty());
if (len.size() % 2 == 0) {
const auto median_it1 = len.begin() + len.size() / 2 - 1;
const auto median_it2 = len.begin() + len.size() / 2;

std::nth_element(len.begin(), median_it1 , len.end());
const auto e1 = *median_it1;

std::nth_element(len.begin(), median_it2 , len.end());
const auto e2 = *median_it2;

return (e1 + e2) / 2;

} else {
const auto median_it = len.begin() + len.size() / 2;
std::nth_element(len.begin(), median_it , len.end());
return *median_it;
}
}


uint nearestIdxToVal(std::vector<double> v, double val){
// this is gonna be ugly. copies entire vector and brute force searches for index nearest to value val.
Expand All @@ -189,76 +169,6 @@ namespace gtsamutils{
return nearestIdx;
}

std::vector<double> vectorizePoint3x(std::vector<gtsam::Point3> p){
std::vector<double> x(p.size());
for(uint i=0; i<p.size(); i++){
x[i]=p[i].x();
}
return x;
}
std::vector<double> vectorizePoint3y(std::vector<gtsam::Point3> p){
std::vector<double> y(p.size());
for(uint i=0; i<p.size(); i++){
y[i]=p[i].y();
}
return y;
}
std::vector<double> vectorizePoint3z(std::vector<gtsam::Point3> p){
std::vector<double> z(p.size());
for(uint i=0; i<p.size(); i++){
z[i]=p[i].z();
}
return z;
}
std::vector<double> vectorizeVector3X(std::vector<gtsam::Vector3> v){
std::vector<double> a(v.size());
for(uint i=0; i<v.size(); i++){
a[i]=v[i](0);
}
return a;
}
std::vector<double> vectorizeVector3Y(std::vector<gtsam::Vector3> v){
std::vector<double> a(v.size());
for(uint i=0; i<v.size(); i++){
a[i]=v[i](1);
}
return a;
}
std::vector<double> vectorizeVector3Z(std::vector<gtsam::Vector3> v){
std::vector<double> a(v.size());
for(uint i=0; i<v.size(); i++){
a[i]=v[i](2);
}
return a;
}
std::vector<double> vectorizeQuaternionS(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>> q){
std::vector<double> a(q.size());
for(uint i=0; i<q.size(); i++){
a[i]=q[i](0);
}
return a;
}
std::vector<double> vectorizeQuaternionX(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>> q){
std::vector<double> a(q.size());
for(uint i=0; i<q.size(); i++){
a[i]=q[i](1);
}
return a;
}
std::vector<double> vectorizeQuaternionY(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>> q){
std::vector<double> a(q.size());
for(uint i=0; i<q.size(); i++){
a[i]=q[i](2);
}
return a;
}
std::vector<double> vectorizeQuaternionZ(std::vector<Eigen::Vector4d,Eigen::aligned_allocator<Eigen::Vector4d>> q){
std::vector<double> a(q.size());
for(uint i=0; i<q.size(); i++){
a[i]=q[i](3);
}
return a;
}
void saveMatrixToFile(const gtsam::Matrix& A, const std::string &s, const std::string& filename) {
std::fstream stream(filename.c_str(), std::fstream::out | std::fstream::app);
print(A, s + "=", stream);
Expand Down
4 changes: 2 additions & 2 deletions src/lowerBodyPoseEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ void lowerBodyPoseEstimator::adjustDistalImuTrajectoryForInboundJointAngles(cons
if(zeroMedianCenterIntExtRot){
Eigen::VectorXd intExtRotAngs=origJointAngles.col(2);
std::vector<double> vec(intExtRotAngs.data(), intExtRotAngs.data() + intExtRotAngs.rows() * intExtRotAngs.cols()); // cast as std::vector
double myMedian=gtsamutils::median(vec);
double myMedian=mathutils::median(vec);
uint medIdx=gtsamutils::nearestIdxToVal(vec, myMedian);
//std::cout<<std::endl<<"int/ext rot median is "<<myMedian<<" and occurs at index "<<medIdx<<" (true val in array = "<<vec[medIdx]<<")"<<std::endl;
R_B_to_B2 = lowerBodyPoseEstimator::getDistalImuOrientationAdjustmentGivenDesiredIntExtRotAngle(R_ProxSeg_to_N[medIdx],distalImuPose[medIdx].rotation(),0.0,rightAxisDist,distalImuToProxJointCtr,distalImuToDistalJointCtr); // R[B->B2]
Expand All @@ -1911,7 +1911,7 @@ void lowerBodyPoseEstimator::adjustDistalImuTrajectoryForInboundJointAngles(cons
if(zeroMedianCenterAbAd){
Eigen::VectorXd abAdAngs=origJointAngles.col(1);
std::vector<double> vec(abAdAngs.data(), abAdAngs.data() + abAdAngs.rows() * abAdAngs.cols()); // cast as std::vector
double myMedian=gtsamutils::median(vec);
double myMedian=mathutils::median(vec);
uint medIdx=gtsamutils::nearestIdxToVal(vec, myMedian);
//std::cout<<std::endl<<"ab/ad rot median is "<<myMedian<<" and occurs at index "<<medIdx<<" (true val in array = "<<vec[medIdx]<<")"<<std::endl;
R_B_to_B2 = lowerBodyPoseEstimator::getDistalImuOrientationAdjustmentGivenDesiredAbAdAngle(R_ProxSeg_to_N[medIdx],distalImuPose[medIdx].rotation(),0.0,rightAxisDist,distalImuToProxJointCtr,distalImuToDistalJointCtr); // R[B->B2]
Expand Down
Loading