Skip to content

Commit

Permalink
Added unit tests for ifopt examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rjoomen committed Jan 10, 2024
1 parent 7538d7c commit bb38344
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 19 deletions.
24 changes: 14 additions & 10 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
Standard: Auto
TabWidth: 2
UseTab: Never
Expand All @@ -53,15 +56,16 @@ BreakBeforeBraces: Custom

# Control of individual brace wrapping cases
BraceWrapping: {
AfterClass: 'true'
AfterControlStatement: 'true'
AfterEnum : 'true'
AfterFunction : 'true'
AfterNamespace : 'true'
AfterStruct : 'true'
AfterUnion : 'true'
BeforeCatch : 'true'
BeforeElse : 'true'
IndentBraces : 'false'
AfterCaseLabel: 'true',
AfterClass: 'true',
AfterControlStatement: 'true',
AfterEnum : 'true',
AfterFunction : 'true',
AfterNamespace : 'true',
AfterStruct : 'true',
AfterUnion : 'true',
BeforeCatch : 'true',
BeforeElse : 'true',
IndentBraces : 'false',
}
...
2 changes: 1 addition & 1 deletion .run-clang-format
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
find . -type d \( -name bullet3_ros -o -name fcl_ros -o -name libccd_ros -o -name gtest_ros -o -name tesseract_ext \) -prune -o -type f -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|hxx\)' -exec clang-format-8 -style=file -i {} \;
find . -type d \( -name bullet3_ros -o -name fcl_ros -o -name libccd_ros -o -name gtest_ros -o -name tesseract_ext \) -prune -o -type f -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|hxx\)' -exec clang-format-15 $@ --style=file -i {} \;
19 changes: 17 additions & 2 deletions tesseract_examples/test/car_seat_example_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace tesseract_examples;
using namespace tesseract_common;
using namespace tesseract_environment;

TEST(TesseractExamples, CarSeatCppExampleUnit) // NOLINT
TEST(TesseractExamples, CarSeatCppTrajOptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
Expand All @@ -21,7 +21,22 @@ TEST(TesseractExamples, CarSeatCppExampleUnit) // NOLINT
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

CarSeatExample example(env, nullptr);
CarSeatExample example(env, nullptr, false, false);
EXPECT_TRUE(example.run());
}

TEST(TesseractExamples, CarSeatCppTrajOptIfoptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
locator->locateResource("package://tesseract_support/urdf/car_seat_demo.urdf")->getFilePath();
tesseract_common::fs::path srdf_path =
locator->locateResource("package://tesseract_support/urdf/car_seat_demo.srdf")->getFilePath();
auto env = std::make_shared<Environment>();
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

CarSeatExample example(env, nullptr, true, false);
EXPECT_TRUE(example.run());
}

Expand Down
48 changes: 48 additions & 0 deletions tesseract_examples/test/freespace_hybrid_example_unit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <tesseract_common/macros.h>
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <gtest/gtest.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_examples/freespace_hybrid_example.h>
#include <tesseract_support/tesseract_support_resource_locator.h>

using namespace tesseract_examples;
using namespace tesseract_common;
using namespace tesseract_environment;

TEST(TesseractExamples, FreespaceHybridTrajOptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
locator->locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.urdf")->getFilePath();
tesseract_common::fs::path srdf_path =
locator->locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.srdf")->getFilePath();
auto env = std::make_shared<Environment>();
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

FreespaceHybridExample example(env, nullptr, false, false);
EXPECT_TRUE(example.run());
}

TEST(TesseractExamples, FreespaceHybridTrajOptIfoptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
locator->locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.urdf")->getFilePath();
tesseract_common::fs::path srdf_path =
locator->locateResource("package://tesseract_support/urdf/lbr_iiwa_14_r820.srdf")->getFilePath();
auto env = std::make_shared<Environment>();
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

FreespaceHybridExample example(env, nullptr, true, false);
EXPECT_TRUE(example.run());
}

int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);

return RUN_ALL_TESTS();
}
19 changes: 17 additions & 2 deletions tesseract_examples/test/pick_and_place_example_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace tesseract_examples;
using namespace tesseract_common;
using namespace tesseract_environment;

TEST(TesseractExamples, PickAndPlaceCppExampleUnit) // NOLINT
TEST(TesseractExamples, PickAndPlaceCppTrajOptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
Expand All @@ -21,7 +21,22 @@ TEST(TesseractExamples, PickAndPlaceCppExampleUnit) // NOLINT
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

PickAndPlaceExample example(env, nullptr);
PickAndPlaceExample example(env, nullptr, false, false);
EXPECT_TRUE(example.run());
}

TEST(TesseractExamples, PickAndPlaceCppTrajOptIfoptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
locator->locateResource("package://tesseract_support/urdf/pick_and_place_plan.urdf")->getFilePath();
tesseract_common::fs::path srdf_path =
locator->locateResource("package://tesseract_support/urdf/pick_and_place_plan.srdf")->getFilePath();
auto env = std::make_shared<Environment>();
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

PickAndPlaceExample example(env, nullptr, true, false);
EXPECT_TRUE(example.run());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace tesseract_examples;
using namespace tesseract_common;
using namespace tesseract_environment;

TEST(TesseractExamples, DISABLED_PuzzlePieceAuxillaryAxesCppExampleUnit) // NOLINT
TEST(TesseractExamples, DISABLED_PuzzlePieceAuxillaryAxesCppTrajOptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
Expand All @@ -21,7 +21,22 @@ TEST(TesseractExamples, DISABLED_PuzzlePieceAuxillaryAxesCppExampleUnit) // NOL
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

PuzzlePieceAuxillaryAxesExample example(env, nullptr);
PuzzlePieceAuxillaryAxesExample example(env, nullptr, false, false);
EXPECT_TRUE(example.run());
}

TEST(TesseractExamples, DISABLED_PuzzlePieceAuxillaryAxesCppTrajOptIfoptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
locator->locateResource("package://tesseract_support/urdf/puzzle_piece_workcell.urdf")->getFilePath();
tesseract_common::fs::path srdf_path =
locator->locateResource("package://tesseract_support/urdf/puzzle_piece_workcell.srdf")->getFilePath();
auto env = std::make_shared<Environment>();
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

PuzzlePieceAuxillaryAxesExample example(env, nullptr, true, false);
EXPECT_TRUE(example.run());
}

Expand Down
19 changes: 17 additions & 2 deletions tesseract_examples/test/puzzle_piece_example_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace tesseract_examples;
using namespace tesseract_common;
using namespace tesseract_environment;

TEST(TesseractExamples, PuzzlePieceCppExampleUnit) // NOLINT
TEST(TesseractExamples, PuzzlePieceCppTrajOptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
Expand All @@ -21,7 +21,22 @@ TEST(TesseractExamples, PuzzlePieceCppExampleUnit) // NOLINT
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

PuzzlePieceExample example(env, nullptr);
PuzzlePieceExample example(env, nullptr, false, false);
EXPECT_TRUE(example.run());
}

TEST(TesseractExamples, PuzzlePieceCppTrajOptIfoptExampleUnit) // NOLINT
{
auto locator = std::make_shared<TesseractSupportResourceLocator>();
tesseract_common::fs::path urdf_path =
locator->locateResource("package://tesseract_support/urdf/puzzle_piece_workcell.urdf")->getFilePath();
tesseract_common::fs::path srdf_path =
locator->locateResource("package://tesseract_support/urdf/puzzle_piece_workcell.srdf")->getFilePath();
auto env = std::make_shared<Environment>();
if (!env->init(urdf_path, srdf_path, locator))
exit(1);

PuzzlePieceExample example(env, nullptr, true, false);
EXPECT_TRUE(example.run());
}

Expand Down

0 comments on commit bb38344

Please sign in to comment.