Skip to content

Commit 539f485

Browse files
committed
Add Tesseract planner for TrajOpt Ifopt
1 parent 3ddf97b commit 539f485

File tree

21 files changed

+1664
-19
lines changed

21 files changed

+1664
-19
lines changed

tesseract/tesseract_collision/include/tesseract_collision/core/types.h

+1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ struct ContactTestData
384384
*/
385385
enum class CollisionEvaluatorType
386386
{
387+
NONE,
387388
DISCRETE,
388389
LVS_DISCRETE,
389390
CONTINUOUS,

tesseract/tesseract_planning/tesseract_command_language/include/tesseract_command_language/cartesian_waypoint.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,11 @@ class CartesianWaypoint
264264

265265
/** @brief The Cartesian Waypoint */
266266
Eigen::Isometry3d waypoint;
267-
/** @brief Distance below waypoint that is allowed. Should be size = 6. First 3 elements are dx, dy, dz. The last 3 elements are angle axis error allowed (Eigen::AngleAxisd.axis() * Eigen::AngleAxisd.angle()) */
267+
/** @brief Distance below waypoint that is allowed. Should be size = 6. First 3 elements are dx, dy, dz. The last 3
268+
* elements are angle axis error allowed (Eigen::AngleAxisd.axis() * Eigen::AngleAxisd.angle()) */
268269
Eigen::VectorXd lower_tolerance;
269-
/** @brief Distance above waypoint that is allowed. Should be size = 6. First 3 elements are dx, dy, dz. The last 3 elements are angle axis error allowed (Eigen::AngleAxisd.axis() * Eigen::AngleAxisd.angle())*/
270+
/** @brief Distance above waypoint that is allowed. Should be size = 6. First 3 elements are dx, dy, dz. The last 3
271+
* elements are angle axis error allowed (Eigen::AngleAxisd.axis() * Eigen::AngleAxisd.angle())*/
270272
Eigen::VectorXd upper_tolerance;
271273

272274
bool isToleranced() const

tesseract/tesseract_planning/tesseract_motion_planners/CMakeLists.txt

+31-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ find_package(tesseract_environment REQUIRED)
1414
find_package(tesseract_common REQUIRED)
1515
find_package(tesseract_command_language REQUIRED)
1616
find_package(trajopt REQUIRED)
17+
find_package(trajopt_ifopt REQUIRED)
1718
find_package(trajopt_sco REQUIRED)
19+
find_package(trajopt_sqp REQUIRED)
1820
find_package(cmake_common_scripts REQUIRED)
1921
# serialization was required because ompl does not include find_dependency for its required dependencies
2022
find_package(Boost REQUIRED COMPONENTS serialization system filesystem program_options)
@@ -163,12 +165,35 @@ target_include_directories(${PROJECT_NAME}_trajopt SYSTEM PUBLIC
163165
${EIGEN3_INCLUDE_DIRS}
164166
${Boost_INCLUDE_DIRS})
165167

166-
configure_package(NAMESPACE tesseract
167-
TARGETS ${PROJECT_NAME}_core
168-
${PROJECT_NAME}_descartes
169-
${PROJECT_NAME}_ompl
170-
${PROJECT_NAME}_simple
171-
${PROJECT_NAME}_trajopt)
168+
# Trajopt_ifopt Planner
169+
add_library(${PROJECT_NAME}_trajopt_ifopt SHARED
170+
src/trajopt_ifopt/trajopt_ifopt_collision_config.cpp
171+
src/trajopt_ifopt/trajopt_ifopt_motion_planner.cpp
172+
src/trajopt_ifopt/trajopt_ifopt_utils.cpp
173+
src/trajopt_ifopt/profile/trajopt_ifopt_default_plan_profile.cpp
174+
src/trajopt_ifopt/profile/trajopt_ifopt_default_composite_profile.cpp
175+
src/trajopt_ifopt/problem_generators/default_problem_generator.cpp)
176+
target_link_libraries(${PROJECT_NAME}_trajopt_ifopt PUBLIC ${Boost_LIBRARIES} ${PROJECT_NAME}_core trajopt::trajopt_ifopt trajopt::trajopt_sqp)
177+
target_compile_options(${PROJECT_NAME}_trajopt_ifopt PRIVATE ${TESSERACT_COMPILE_OPTIONS_PRIVATE})
178+
target_compile_options(${PROJECT_NAME}_trajopt_ifopt PUBLIC ${TESSERACT_COMPILE_OPTIONS_PUBLIC})
179+
target_compile_definitions(${PROJECT_NAME}_trajopt_ifopt PUBLIC ${TESSERACT_COMPILE_DEFINITIONS})
180+
target_clang_tidy(${PROJECT_NAME}_trajopt_ifopt ARGUMENTS ${TESSERACT_CLANG_TIDY_ARGS} ENABLE ${TESSERACT_ENABLE_CLANG_TIDY})
181+
target_cxx_version(${PROJECT_NAME}_trajopt_ifopt PUBLIC VERSION ${TESSERACT_CXX_VERSION})
182+
target_code_coverage(${PROJECT_NAME}_trajopt_ifopt ALL EXCLUDE ${COVERAGE_EXCLUDE} ENABLE ${TESSERACT_ENABLE_TESTING})
183+
target_include_directories(${PROJECT_NAME}_trajopt_ifopt PUBLIC
184+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
185+
"$<INSTALL_INTERFACE:include>")
186+
target_include_directories(${PROJECT_NAME}_trajopt_ifopt SYSTEM PUBLIC
187+
${EIGEN3_INCLUDE_DIRS}
188+
${Boost_INCLUDE_DIRS})
189+
190+
configure_package(${PROJECT_NAME}_core
191+
${PROJECT_NAME}_descartes
192+
${PROJECT_NAME}_ompl
193+
${PROJECT_NAME}_simple
194+
${PROJECT_NAME}_trajopt
195+
${PROJECT_NAME}_trajopt_ifopt
196+
)
172197

173198
# Mark cpp header files for installation
174199
install(DIRECTORY include/${PROJECT_NAME}

tesseract/tesseract_planning/tesseract_motion_planners/include/tesseract_motion_planners/trajopt/profile/trajopt_profile.h

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3434
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3535

3636
#include <tesseract_command_language/core/instruction.h>
37+
#include <tesseract_command_language/joint_waypoint.h>
38+
#include <tesseract_command_language/cartesian_waypoint.h>
3739
#include <tesseract_command_language/types.h>
3840

3941
#ifdef SWIG

tesseract/tesseract_planning/tesseract_motion_planners/include/tesseract_motion_planners/trajopt/trajopt_utils.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ trajopt::TermInfo::Ptr createJointWaypointTermInfo(const Eigen::VectorXd& j_wp,
6666
trajopt::TermInfo::Ptr createTolerancedJointWaypointTermInfo(const Eigen::VectorXd& j_wp,
6767
const Eigen::VectorXd& lower_tol,
6868
const Eigen::VectorXd& upper_tol,
69-
int index,
70-
const Eigen::VectorXd& coeffs,
71-
trajopt::TermType type);
72-
69+
int index,
70+
const Eigen::VectorXd& coeffs,
71+
trajopt::TermType type);
7372

7473
trajopt::TermInfo::Ptr createCollisionTermInfo(
7574
int start_index,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @file default_problem_generator.h
3+
* @brief Generates a trajopt problem from a planner request
4+
*
5+
* @author Levi Armstrong
6+
* @date April 18, 2018
7+
* @version TODO
8+
* @bug No known bugs
9+
*
10+
* @copyright Copyright (c) 2020, Southwest Research Institute
11+
*
12+
* @par License
13+
* Software License Agreement (Apache License)
14+
* @par
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
* @par
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*/
26+
#ifndef TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_PROBLEM_GENERATOR_H
27+
#define TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_PROBLEM_GENERATOR_H
28+
29+
#include <tesseract_common/macros.h>
30+
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
31+
#include <ifopt/problem.h>
32+
TESSERACT_COMMON_IGNORE_WARNINGS_POP
33+
34+
#include <tesseract_motion_planners/core/types.h>
35+
#include <tesseract_motion_planners/trajopt_ifopt/profile/trajopt_ifopt_profile.h>
36+
37+
namespace tesseract_planning
38+
{
39+
std::shared_ptr<TrajOptIfoptProblem>
40+
DefaultTrajoptProblemGenerator(const std::string& name,
41+
const PlannerRequest& request,
42+
const TrajOptIfoptPlanProfileMap& plan_profiles,
43+
const TrajOptIfoptCompositeProfileMap& composite_profiles);
44+
45+
} // namespace tesseract_planning
46+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* @file trajopt_default_composite_profile.h
3+
* @brief
4+
*
5+
* @author Levi Armstrong
6+
* @date June 18, 2020
7+
* @version TODO
8+
* @bug No known bugs
9+
*
10+
* @copyright Copyright (c) 2020, Southwest Research Institute
11+
*
12+
* @par License
13+
* Software License Agreement (Apache License)
14+
* @par
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
* @par
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*/
26+
27+
#ifndef TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_COMPOSITE_PROFILE_H
28+
#define TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_COMPOSITE_PROFILE_H
29+
30+
#include <tesseract_common/macros.h>
31+
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
32+
#include <vector>
33+
#include <Eigen/Geometry>
34+
#include <Eigen/Core>
35+
#include <trajopt_ifopt/constraints/collision_evaluators.h>
36+
TESSERACT_COMMON_IGNORE_WARNINGS_POP
37+
38+
#include <tesseract_motion_planners/trajopt_ifopt/profile/trajopt_ifopt_profile.h>
39+
40+
namespace tesseract_planning
41+
{
42+
class TrajOptIfoptDefaultCompositeProfile : public TrajOptIfoptCompositeProfile
43+
{
44+
public:
45+
TrajOptIfoptDefaultCompositeProfile() = default;
46+
TrajOptIfoptDefaultCompositeProfile(const tinyxml2::XMLElement& xml_element);
47+
48+
/** @brief Configuration info for collisions that are modeled as costs */
49+
trajopt::TrajOptCollisionConfig::Ptr collision_cost_config;
50+
/** @brief Configuration info for collisions that are modeled as constraints */
51+
trajopt::TrajOptCollisionConfig::Ptr collision_constraint_config;
52+
/** @brief If true, a joint velocity cost with a target of 0 will be applied for all timesteps Default: true*/
53+
bool smooth_velocities = true;
54+
/** @brief This default to all ones, but allows you to weight different joints */
55+
Eigen::VectorXd velocity_coeff;
56+
/** @brief If true, a joint acceleration cost with a target of 0 will be applied for all timesteps Default: false*/
57+
bool smooth_accelerations = true;
58+
/** @brief This default to all ones, but allows you to weight different joints */
59+
Eigen::VectorXd acceleration_coeff;
60+
/** @brief If true, a joint jerk cost with a target of 0 will be applied for all timesteps Default: false*/
61+
bool smooth_jerks = true;
62+
/** @brief This default to all ones, but allows you to weight different joints */
63+
Eigen::VectorXd jerk_coeff;
64+
65+
/** @brief Set the resolution at which state validity needs to be verified in order for a motion between two states
66+
* to be considered valid in post checking of trajectory returned by TrajOptIfopt.
67+
*
68+
* The resolution is equal to longest_valid_segment_fraction * state_space.getMaximumExtent()
69+
*
70+
* Note: The planner takes the conservative of either longest_valid_segment_fraction or longest_valid_segment_length.
71+
*/
72+
double longest_valid_segment_fraction = 0.01; // 1%
73+
74+
/** @brief Set the resolution at which state validity needs to be verified in order for a motion between two states
75+
* to be considered valid. If norm(state1 - state0) > longest_valid_segment_length.
76+
*
77+
* Note: This gets converted to longest_valid_segment_fraction.
78+
* longest_valid_segment_fraction = longest_valid_segment_length / state_space.getMaximumExtent()
79+
*/
80+
double longest_valid_segment_length = 0.5;
81+
82+
/** @brief Special link collision cost distances */
83+
trajopt::SafetyMarginData::Ptr special_collision_cost{ nullptr };
84+
/** @brief Special link collision constraint distances */
85+
trajopt::SafetyMarginData::Ptr special_collision_constraint{ nullptr };
86+
87+
void apply(TrajOptIfoptProblem& problem,
88+
int start_index,
89+
int end_index,
90+
const ManipulatorInfo& manip_info,
91+
const std::vector<std::string>& active_links,
92+
const std::vector<int>& fixed_indices) const override;
93+
94+
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const override;
95+
};
96+
} // namespace tesseract_planning
97+
98+
#endif // TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_COMPOSITE_PROFILE_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* @file TrajOptIfopt_default_plan_profile.h
3+
* @brief
4+
*
5+
* @author Levi Armstrong
6+
* @date June 18, 2020
7+
* @version TODO
8+
* @bug No known bugs
9+
*
10+
* @copyright Copyright (c) 2020, Southwest Research Institute
11+
*
12+
* @par License
13+
* Software License Agreement (Apache License)
14+
* @par
15+
* Licensed under the Apache License, Version 2.0 (the "License");
16+
* you may not use this file except in compliance with the License.
17+
* You may obtain a copy of the License at
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
* @par
20+
* Unless required by applicable law or agreed to in writing, software
21+
* distributed under the License is distributed on an "AS IS" BASIS,
22+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23+
* See the License for the specific language governing permissions and
24+
* limitations under the License.
25+
*/
26+
27+
#ifndef TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_PLAN_PROFILE_H
28+
#define TESSERACT_MOTION_PLANNERS_TRAJOPT_IFOPT_DEFAULT_PLAN_PROFILE_H
29+
30+
#include <tesseract_common/macros.h>
31+
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
32+
#include <Eigen/Geometry>
33+
TESSERACT_COMMON_IGNORE_WARNINGS_POP
34+
35+
#include <tesseract_motion_planners/trajopt_ifopt/profile/trajopt_ifopt_profile.h>
36+
#include <tesseract_command_language/joint_waypoint.h>
37+
#include <tesseract_command_language/cartesian_waypoint.h>
38+
39+
namespace tesseract_planning
40+
{
41+
class TrajOptIfoptDefaultPlanProfile : public TrajOptIfoptPlanProfile
42+
{
43+
public:
44+
using Ptr = std::shared_ptr<TrajOptIfoptDefaultPlanProfile>;
45+
using ConstPtr = std::shared_ptr<const TrajOptIfoptDefaultPlanProfile>;
46+
47+
TrajOptIfoptDefaultPlanProfile() = default;
48+
TrajOptIfoptDefaultPlanProfile(const tinyxml2::XMLElement& xml_element);
49+
50+
Eigen::VectorXd cartesian_coeff{ Eigen::VectorXd::Constant(1, 1, 5) };
51+
Eigen::VectorXd joint_coeff{ Eigen::VectorXd::Constant(1, 1, 5) };
52+
TrajOptIfoptTermType term_type{ TrajOptIfoptTermType::CONSTRAINT };
53+
54+
void apply(TrajOptIfoptProblem& problem,
55+
const CartesianWaypoint& cartesian_waypoint,
56+
const Instruction& parent_instruction,
57+
const ManipulatorInfo& manip_info,
58+
const std::vector<std::string>& active_links,
59+
int index) const override;
60+
61+
void apply(TrajOptIfoptProblem& problem,
62+
const JointWaypoint& joint_waypoint,
63+
const Instruction& parent_instruction,
64+
const ManipulatorInfo& manip_info,
65+
const std::vector<std::string>& active_links,
66+
int index) const override;
67+
68+
tinyxml2::XMLElement* toXML(tinyxml2::XMLDocument& doc) const override;
69+
70+
// protected:
71+
// void addConstraintErrorFunctions(TrajOptIfopt::ProblemConstructionInfo& pci, const std::vector<int>& fixed_steps)
72+
// const;
73+
74+
// void addAvoidSingularity(TrajOptIfopt::ProblemConstructionInfo& pci, const std::vector<int>& fixed_steps) const;s
75+
};
76+
} // namespace tesseract_planning
77+
78+
#endif // TESSERACT_MOTION_PLANNERS_TrajOptIfopt_IFOPT_DEFAULT_PLAN_PROFILE_H

0 commit comments

Comments
 (0)