Skip to content

Commit 34aa8d3

Browse files
authored
Add TrajOpt Ifopt planner (#443)
1 parent 93a9745 commit 34aa8d3

File tree

24 files changed

+1705
-16
lines changed

24 files changed

+1705
-16
lines changed

.github/workflows/windows_noetic_build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ jobs:
3737
3838
rosdep install -q --from-paths . --ignore-src -y
3939
40-
catkin_make_isolated --install --force-cmake --only-pkg-with-deps tesseract_collision tesseract_common tesseract_environment tesseract_geometry tesseract_kinematics tesseract_scene_graph tesseract_support tesseract_urdf tesseract_visualization tesseract_motion_planners tesseract_process_managers tesseract_time_parameterization tesseract_python --cmake-args -DCMAKE_BUILD_TYPE=Release -DINSTALL_OMPL=ON -DINSTALL_OMPL_TAG=master
40+
catkin_make_isolated --install --force-cmake --only-pkg-with-deps tesseract_collision tesseract_common tesseract_environment tesseract_geometry tesseract_kinematics tesseract_scene_graph tesseract_support tesseract_urdf tesseract_visualization tesseract_motion_planners tesseract_process_managers tesseract_time_parameterization tesseract_python --cmake-args -DCMAKE_BUILD_TYPE=Release -DINSTALL_OMPL=ON -DINSTALL_OMPL_TAG=master -DBUILD_IPOPT=OFF -DBUILD_SNOPT=OFF
4141
call "D:\a\tesseract\tesseract\install_isolated\setup.bat"
42-
catkin_make_isolated --install --force-cmake --pkg tesseract_collision tesseract_common tesseract_environment tesseract_geometry tesseract_kinematics tesseract_scene_graph tesseract_support tesseract_urdf tesseract_visualization tesseract_motion_planners tesseract_process_managers tesseract_time_parameterization --cmake-args -DCMAKE_BUILD_TYPE=Release -DTESSERACT_ENABLE_TESTING=ON -DINSTALL_OMPL=ON -DINSTALL_OMPL_TAG=master
42+
catkin_make_isolated --install --force-cmake --pkg tesseract_collision tesseract_common tesseract_environment tesseract_geometry tesseract_kinematics tesseract_scene_graph tesseract_support tesseract_urdf tesseract_visualization tesseract_motion_planners tesseract_process_managers tesseract_time_parameterization --cmake-args -DCMAKE_BUILD_TYPE=Release -DTESSERACT_ENABLE_TESTING=ON -DINSTALL_OMPL=ON -DINSTALL_OMPL_TAG=master -DBUILD_IPOPT=OFF -DBUILD_SNOPT=OFF

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

+18
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,24 @@ 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
268+
* elements are angle axis error allowed (Eigen::AngleAxisd.axis() * Eigen::AngleAxisd.angle()) */
269+
Eigen::VectorXd lower_tolerance;
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())*/
272+
Eigen::VectorXd upper_tolerance;
273+
274+
bool isToleranced() const
275+
{
276+
// Check if they are empty
277+
if (lower_tolerance.size() == 0 || upper_tolerance.size() == 0)
278+
return false;
279+
280+
// Check if they are close to 0
281+
Eigen::VectorXd range = upper_tolerance - lower_tolerance;
282+
double sum = range.sum();
283+
return (sum < 1e-5);
284+
}
267285
};
268286

269287
} // namespace tesseract_planning

tesseract/tesseract_planning/tesseract_command_language/include/tesseract_command_language/joint_waypoint.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,29 @@ class JointWaypoint
265265
inline operator Eigen::Ref<Eigen::VectorXd>() { return Eigen::Ref<Eigen::VectorXd>(waypoint); }
266266

267267
//////////////////////////////////
268-
// Cartesian Waypoint Container //
268+
// Joint Waypoint Container //
269269
//////////////////////////////////
270270

271271
#endif // SWIG
272272

273273
Eigen::VectorXd waypoint;
274274
std::vector<std::string> joint_names;
275+
/** @brief Joint distance below waypoint that is allowed. Each element should be <= 0 */
276+
Eigen::VectorXd lower_tolerance;
277+
/** @brief Joint distance above waypoint that is allowed. Each element should be >= 0 */
278+
Eigen::VectorXd upper_tolerance;
279+
280+
bool isToleranced() const
281+
{
282+
// Check if they are empty
283+
if (lower_tolerance.size() == 0 || upper_tolerance.size() == 0)
284+
return false;
285+
286+
// Check if they are close to 0
287+
Eigen::VectorXd range = upper_tolerance - lower_tolerance;
288+
double sum = range.sum();
289+
return (sum < 1e-5);
290+
}
275291
};
276292
} // namespace tesseract_planning
277293

tesseract/tesseract_planning/tesseract_motion_planners/CMakeLists.txt

+27-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ find_package(tesseract_environment REQUIRED)
1818
find_package(tesseract_common REQUIRED)
1919
find_package(tesseract_command_language REQUIRED)
2020
find_package(trajopt REQUIRED)
21+
find_package(trajopt_ifopt REQUIRED)
2122
find_package(trajopt_sco REQUIRED)
23+
find_package(trajopt_sqp REQUIRED)
24+
find_package(cmake_common_scripts REQUIRED)
2225
# serialization was required because ompl does not include find_dependency for its required dependencies
2326
find_package(Boost REQUIRED COMPONENTS serialization system filesystem program_options)
2427

@@ -166,12 +169,35 @@ target_include_directories(${PROJECT_NAME}_trajopt SYSTEM PUBLIC
166169
${EIGEN3_INCLUDE_DIRS}
167170
${Boost_INCLUDE_DIRS})
168171

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

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

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3333
#include <Eigen/Geometry>
3434
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3535

36+
#include <tesseract_command_language/cartesian_waypoint.h>
37+
#include <tesseract_command_language/joint_waypoint.h>
3638
#include <tesseract_motion_planners/trajopt/profile/trajopt_profile.h>
3739

3840
#ifdef SWIG
@@ -81,14 +83,14 @@ class TrajOptDefaultPlanProfile : public TrajOptPlanProfile
8183
constraint_error_functions;
8284

8385
void apply(trajopt::ProblemConstructionInfo& pci,
84-
const Eigen::Isometry3d& cartesian_waypoint,
86+
const CartesianWaypoint& cartesian_waypoint,
8587
const Instruction& parent_instruction,
8688
const ManipulatorInfo& manip_info,
8789
const std::vector<std::string>& active_links,
8890
int index) const override;
8991

9092
void apply(trajopt::ProblemConstructionInfo& pci,
91-
const Eigen::VectorXd& joint_waypoint,
93+
const JointWaypoint& joint_waypoint,
9294
const Instruction& parent_instruction,
9395
const ManipulatorInfo& manip_info,
9496
const std::vector<std::string>& active_links,

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

+4-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
@@ -58,14 +60,14 @@ class TrajOptPlanProfile
5860
TrajOptPlanProfile& operator=(TrajOptPlanProfile&&) = default;
5961

6062
virtual void apply(trajopt::ProblemConstructionInfo& pci,
61-
const Eigen::Isometry3d& cartesian_waypoint,
63+
const CartesianWaypoint& cartesian_waypoint,
6264
const Instruction& parent_instruction,
6365
const ManipulatorInfo& manip_info,
6466
const std::vector<std::string>& active_links,
6567
int index) const = 0;
6668

6769
virtual void apply(trajopt::ProblemConstructionInfo& pci,
68-
const Eigen::VectorXd& joint_waypoint,
70+
const JointWaypoint& joint_waypoint,
6971
const Instruction& parent_instruction,
7072
const ManipulatorInfo& manip_info,
7173
const std::vector<std::string>& active_links,

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

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ trajopt::TermInfo::Ptr createJointWaypointTermInfo(const Eigen::VectorXd& j_wp,
6363
const Eigen::VectorXd& coeffs,
6464
trajopt::TermType type);
6565

66+
trajopt::TermInfo::Ptr createTolerancedJointWaypointTermInfo(const Eigen::VectorXd& j_wp,
67+
const Eigen::VectorXd& lower_tol,
68+
const Eigen::VectorXd& upper_tol,
69+
int index,
70+
const Eigen::VectorXd& coeffs,
71+
trajopt::TermType type);
72+
6673
trajopt::TermInfo::Ptr createCollisionTermInfo(
6774
int start_index,
6875
int end_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

0 commit comments

Comments
 (0)