-
Notifications
You must be signed in to change notification settings - Fork 10
Code cleanup and Docker fixes #57
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d3946de
Code cleanup and Docker fixes
sea-bass 66f7780
README cleanups
sea-bass 1f13d13
Correct bad sentence
sea-bass 5fa9878
Clarify pre-commit command
sea-bass 2768787
Slight fix to TOPPRA comments
sea-bass 4f7dbe2
Space
sea-bass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,119 @@ | ||
#pragma once | ||
|
||
#include <ktopt_moveit_parameters.hpp> | ||
#include <moveit/planning_interface/planning_interface.h> | ||
#include <shape_msgs/msg/solid_primitive.h> | ||
#include <ktopt_moveit_parameters.hpp> | ||
|
||
// relevant drake includes | ||
#include "drake/common/eigen_types.h" | ||
#include "drake/multibody/parsing/parser.h" | ||
#include "drake/geometry/scene_graph.h" | ||
#include "drake/systems/framework/diagram.h" | ||
#include "drake/systems/framework/diagram_builder.h" | ||
#include "drake/multibody/plant/multibody_plant.h" | ||
#include "drake/planning/trajectory_optimization/kinematic_trajectory_optimization.h" | ||
#include "drake/solvers/solve.h" | ||
#include "drake/geometry/meshcat.h" | ||
#include "drake/geometry/meshcat_visualizer.h" | ||
#include "drake/geometry/drake_visualizer.h" | ||
#include "drake/geometry/meshcat_params.h" | ||
#include "drake/geometry/geometry_frame.h" | ||
#include "drake/geometry/geometry_instance.h" | ||
#include "drake/geometry/geometry_roles.h" | ||
#include "drake/geometry/proximity_properties.h" | ||
#include "drake/visualization/visualization_config.h" | ||
#include "drake/visualization/visualization_config_functions.h" | ||
#include <drake/geometry/meshcat.h> | ||
#include <drake/geometry/meshcat_visualizer.h> | ||
#include <drake/geometry/scene_graph.h> | ||
#include <drake/planning/trajectory_optimization/kinematic_trajectory_optimization.h> | ||
#include <drake/systems/framework/diagram.h> | ||
#include <drake/systems/framework/diagram_builder.h> | ||
#include <drake/multibody/inverse_kinematics/minimum_distance_lower_bound_constraint.h> | ||
#include <drake/multibody/inverse_kinematics/position_constraint.h> | ||
#include <drake/multibody/parsing/parser.h> | ||
#include <drake/multibody/plant/multibody_plant.h> | ||
|
||
namespace ktopt_interface | ||
{ | ||
// declare all namespaces to be used | ||
using drake::geometry::AddRigidHydroelasticProperties; | ||
using drake::geometry::Box; | ||
using drake::geometry::Cylinder; | ||
using drake::geometry::FrameId; | ||
using drake::geometry::GeometryFrame; | ||
using drake::geometry::GeometryId; | ||
using drake::geometry::GeometryInstance; | ||
using drake::geometry::IllustrationProperties; | ||
using drake::geometry::Meshcat; | ||
using drake::geometry::MeshcatParams; | ||
using drake::geometry::MeshcatVisualizer; | ||
using drake::geometry::MeshcatVisualizerParams; | ||
using drake::geometry::PerceptionProperties; | ||
using drake::geometry::ProximityProperties; | ||
using drake::geometry::Role; | ||
using drake::geometry::SceneGraph; | ||
using drake::geometry::Shape; | ||
using drake::geometry::SourceId; | ||
using drake::geometry::Sphere; | ||
using drake::math::RigidTransformd; | ||
using drake::multibody::AddMultibodyPlantSceneGraph; | ||
using drake::multibody::Frame; | ||
using drake::multibody::MinimumDistanceLowerBoundConstraint; | ||
using drake::multibody::MultibodyPlant; | ||
using drake::multibody::PackageMap; | ||
using drake::multibody::Parser; | ||
using drake::multibody::PositionConstraint; | ||
using drake::planning::trajectory_optimization::KinematicTrajectoryOptimization; | ||
using drake::solvers::Solve; | ||
using drake::systems::Context; | ||
using drake::systems::Diagram; | ||
using drake::systems::DiagramBuilder; | ||
using drake::visualization::ApplyVisualizationConfig; | ||
using drake::visualization::VisualizationConfig; | ||
using Eigen::Matrix3d; | ||
using Eigen::MatrixXd; | ||
using Eigen::Vector3d; | ||
using Eigen::VectorXd; | ||
using Joints = std::vector<const moveit::core::JointModel*>; | ||
|
||
/** | ||
* @brief Helper class that defines a planning context for Drake Kinematic Trajectory Optimization (KTOpt). | ||
* @details For more information, refer to the Drake documentation: | ||
* https://drake.mit.edu/doxygen_cxx/classdrake_1_1planning_1_1trajectory__optimization_1_1_kinematic_trajectory_optimization.html | ||
*/ | ||
class KTOptPlanningContext : public planning_interface::PlanningContext | ||
{ | ||
public: | ||
/** | ||
* @brief Constructs an instance of a KTOpt plannign context. | ||
* @param name The name of the planning context. | ||
* @param group_name The name of the joint group used for motion planning. | ||
* @param params The ROS parameters for this planner. | ||
*/ | ||
KTOptPlanningContext(const std::string& name, const std::string& group_name, const ktopt_interface::Params& params); | ||
|
||
/** | ||
* @brief Calculates a trajectory for the current request of this context. | ||
* @param res The result containing the respective trajectory, or error code on failure. | ||
*/ | ||
void solve(planning_interface::MotionPlanResponse& res) override; | ||
|
||
/** | ||
* @brief Calculates a trajectory for the current request of this context. | ||
* @details This function just delegates to the common response. | ||
* However, here the same trajectory is stored with the descriptions "plan","simplify", or "interpolate". | ||
* @param res The detailed result containing the respective trajectory, or error code on failure. | ||
*/ | ||
void solve(planning_interface::MotionPlanDetailedResponse& res) override; | ||
|
||
/** | ||
* @brief Terminates any running solutions. | ||
* @return True if successful, otherwise false. | ||
*/ | ||
bool terminate() override; | ||
|
||
/// @brief Clear the data structures used by the planner. | ||
void clear() override; | ||
|
||
void setRobotDescription(std::string robot_description); | ||
/** | ||
* @brief Sets the current robot description for planning. | ||
* @param robot_description The URDF string containing the robot description. | ||
*/ | ||
void setRobotDescription(const std::string& robot_description); | ||
|
||
/** | ||
* @brief Transcribes a MoveIt planning scene to the Drake multibody plant used by this planner. | ||
* @param planning_scene The MoveIt planning scene to transcribe. | ||
*/ | ||
void transcribePlanningScene(const planning_scene::PlanningScene& planning_scene); | ||
|
||
/** | ||
* @brief Adds path position constraints, if any, to the planning problem. | ||
* @param trajopt The Drake mathematical program containing the trajectory optimization problem. | ||
* @param plant The Drake multibody plant to use for planning. | ||
* @param plant_context The context associated with the multibody plant. | ||
* @param padding Additional position padding on the MoveIt constraint, in meters. | ||
* This ensures that constraints are more likely to hold for the entire trajectory, since the | ||
* Drake mathematical program only optimizes constraints at discrete points along the path. | ||
*/ | ||
void addPathPositionConstraints(KinematicTrajectoryOptimization& trajopt, const MultibodyPlant<double>& plant, | ||
Context<double>& plant_context, const double padding); | ||
|
||
private: | ||
/// @brief The ROS parameters associated with this motion planner. | ||
const ktopt_interface::Params params_; | ||
|
||
/// @brief The URDF robot description. | ||
std::string robot_description_; | ||
|
||
// drake related variables | ||
/// @brief The Drake diagram describing the entire system. | ||
std::unique_ptr<Diagram<double>> diagram_; | ||
|
||
/// @brief The builder for the Drake system diagram. | ||
std::unique_ptr<DiagramBuilder<double>> builder; | ||
|
||
/// @brief The context that contains all the data necessary to perform computations on the diagram. | ||
std::unique_ptr<Context<double>> diagram_context_; | ||
VectorXd nominal_q_; | ||
const std::string OCTOMAP_NS = "<octomap>"; | ||
|
||
// visualization | ||
std::shared_ptr<Meshcat> meshcat_; | ||
MeshcatVisualizer<double>* visualizer_; | ||
/// @brief The nominal joint configuration of the robot, used for joint centering objectives. | ||
Eigen::VectorXd nominal_q_; | ||
|
||
/// @brief Pointer to the Meshcat instance associated with this planner. | ||
std::shared_ptr<drake::geometry::Meshcat> meshcat_; | ||
|
||
/// @brief The Drake MeshCat visualizer associated with this planner. | ||
drake::geometry::MeshcatVisualizer<double>* visualizer_; | ||
}; | ||
} // namespace ktopt_interface |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.