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

Added extended testing, separated tests and benchmarks #8

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

bwingo47
Copy link
Collaborator

Problem data JSON files are copied over from IkBench. Now has separate bench compile options

@hrp2-14
Copy link
Member

hrp2-14 commented Aug 11, 2024

Hi ! This project doesn't usually accept pull requests on the main branch.
If this wasn't intentionnal, you can change the base branch of this PR to devel
(No need to close it for that). Best, a bot.

@bwingo47 bwingo47 changed the base branch from main to devel August 11, 2024 03:21
@bwingo47 bwingo47 requested a review from jorisv August 11, 2024 03:22
Comment on lines +9 to +10
.cache
.DS_Store
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be set in your local .gitignore on your computer.

Comment on lines +88 to +89
option(BUILD_WITH_EXTENDED_TESTING "Build library with extended testing" OFF)
option(BUILD_WITH_BENCHMARK "Build library with timing benchmarks" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
option(BUILD_WITH_EXTENDED_TESTING "Build library with extended testing" OFF)
option(BUILD_WITH_BENCHMARK "Build library with timing benchmarks" OFF)
option(BUILD_EXTENDED_TESTING "Build library with extended testing" OFF)
option(BUILD_BENCHMARK "Build library with timing benchmarks" OFF)

Comment on lines +158 to +165
# set(LIB_EXTENDED_TEST_DIR ${PROJECT_SOURCE_DIR}/problems)
# set(LIB_EXTENDED_TEST_HEADERS
# ${LIB_EXTENDED_TEST_DIR}/test-problems.hpp)
# set(LIB_EXTENDED_TEST_SOURCES
# ${LIB_EXTENDED_TEST_DIR}/test-problems.cpp)
# set(LIB_BENCH_DIR ${PROJECT_SOURCE_DIR}/bench)
# set(LIB_BENCH_SOURCES
# ${LIB_BENCH_DIR}/timings.cpp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not used, should be removed.

Comment on lines +178 to +186
# if(BUILD_WITH_BENCHMARK)
# list(APPEND LIB_SOURCES ${LIB_BENCH_SOURCES})
# endif()

# if(BUILD_WITH_EXTENDED_TESTING)
# list(APPEND LIB_HEADERS ${LIB_EXTENDED_TEST_HEADERS})
# list(APPEND LIB_SOURCES ${LIB_EXTENDED_TEST_SOURCES})
# endif()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@@ -4,6 +4,7 @@

#pragma once

#include "fwd.hpp"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "fwd.hpp"
#include "loik/fwd.hpp"

Comment on lines +1 to +295

// converged
problem_struct.converged = problem_sol.get<bool>("converged");

// primal_infeasible
problem_struct.primal_infeasible = problem_sol.get<bool>("primal_infeasible");

// dual_infeasible
problem_struct.dual_infeasible = problem_sol.get<bool>("dual_infeasible");

// primal_residual
problem_struct.primal_residual = problem_sol.get<double>("primal_residual");

// dual_residual
problem_struct.dual_residual = problem_sol.get<double>("dual_residual");

// mu
problem_struct.mu = problem_sol.get<double>("mu");

// n_iter
problem_struct.n_iter = problem_sol.get<int>("n_iter");

// n_tail_solve_iter
problem_struct.n_tail_solve_iter = problem_sol.get<int>("n_tail_solve_iter");

// n_active_ineq_constraint

// vis
const ptree& vis_pt = problem_sol.get_child("vis");
utils::PtreeToContainerOfObj<Motion, pin_aligned_vec>(vis_pt, problem_struct.vis);

// yis
const ptree& yis_pt = problem_sol.get_child("yis");
utils::PtreeToContainerOfObj<Vec6, pin_aligned_vec>(yis_pt, problem_struct.yis);

// w
const ptree& w_pt = problem_sol.get_child("w");
utils::PtreeToDataObj<DVec>(w_pt, problem_struct.w);


// z
const ptree& z_pt = problem_sol.get_child("z");
utils::PtreeToDataObj<DVec>(z_pt, problem_struct.z);


/// push problem to problem_sequence
problem_sequence.push_back(problem_struct);

} //endfor

} // SequenceDiffIKProblems::LoadProblemsFromJson


/// explicit instantiation and specializations
namespace utils {
using Index = typename loik::DiffIKProblem<double>::Index;
using DVec = typename loik::DiffIKProblem<double>::DVec;
using Vec6 = typename loik::DiffIKProblem<double>::Vec6;
using Motion = typename loik::DiffIKProblem<double>::Motion;
using Mat6x6 = typename loik::DiffIKProblem<double>::Mat6x6;

template<typename T>
using pin_aligned_vec = typename pinocchio::container::aligned_vector<T>;

// explicit instantiation
template void PtreeToVec<DVec>(const ptree&, const DVec&);
template void PtreeToVec<Vec6>(const ptree&, const Vec6&);
template void PtreeToMat<Mat6x6>(const ptree&, const Mat6x6&);


// `PtreeToDataObj` specializations
template <>
void PtreeToDataObj<DVec>(const ptree& pt, const DVec& vec) { PtreeToVec<DVec>(pt, vec); } // PtreeToDataObj<DVec>
template <>
void PtreeToDataObj<Vec6>(const ptree& pt, const Vec6& vec) { PtreeToVec<Vec6>(pt, vec); } // PtreeToDataObj<Vec6>
template <>
void PtreeToDataObj<Mat6x6>(const ptree& pt, const Mat6x6& mat) { PtreeToMat<Mat6x6>(pt, mat); } // PtreeToDataObj<Mat6x6>
template <>
void PtreeToDataObj<Motion>(const ptree& pt, const Motion& motion)
{
Motion& motion_out = const_cast<Motion&>(motion);
Motion::Vector6 motion_v6 = Motion::Vector6::Zero();
PtreeToVec(pt, motion_v6);
motion_out = motion_v6;
} // PtreeToDataObj<Motion>

// explicit instantiation
template void PtreeToDataObj<Index>(const ptree&, const Index&);
template void PtreeToContainerOfObj<Index, std::vector>(const ptree&, const std::vector<Index>&);
template void PtreeToContainerOfObj<DVec, pin_aligned_vec>(const ptree&, const pin_aligned_vec<DVec>&);
template void PtreeToContainerOfObj<Vec6, pin_aligned_vec>(const ptree&, const pin_aligned_vec<Vec6>&);
template void PtreeToContainerOfObj<Mat6x6, pin_aligned_vec>(const ptree&, const pin_aligned_vec<Mat6x6>&);
template void PtreeToContainerOfObj<Motion, pin_aligned_vec>(const ptree&, const pin_aligned_vec<Motion>&);

} // namespace utils

template struct DiffIKProblem<double>;
template struct SequenceDiffIKProblems<double>;

} // namespace loik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is ill-formated

Comment on lines +100 to +101
// std::string("/panda_description/urdf/panda.urdf");
// urdf_filename =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed

Copy link
Member

@jcarpent jcarpent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some comments.
@bwingo47 Could you handle them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants