-
Notifications
You must be signed in to change notification settings - Fork 10
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
README clean up and integration of Kinematic limits from Robot Model #49
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c873ba5
adds urdf as a param
kamiradi f15c196
adds a small introduction on the readme
kamiradi ec9acd3
[FT] Sets up pos/vel bounds in KTOPT
kamiradi 9c59be2
pre-commits
kamiradi f2202db
addresses review comments
kamiradi 61e4381
pre-commit stuff
kamiradi e5ab7f4
adds acceleration and place holder jerk constraint
kamiradi 75d73ed
initialises bounds with dofs by reserving memory -
kamiradi a88ce75
[FIX] fixes incorrect integration of inactive kinematic limits
kamiradi 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 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 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 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 |
---|---|---|
|
@@ -16,6 +16,9 @@ rclcpp::Logger getLogger() | |
{ | ||
return moveit::getLogger("moveit.planners.ktopt_interface.planning_context"); | ||
} | ||
|
||
constexpr double kDefaultJointMaxPosition = 1.0e6; | ||
|
||
} // namespace | ||
|
||
KTOptPlanningContext::KTOptPlanningContext(const std::string& name, const std::string& group_name, | ||
|
@@ -47,6 +50,74 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res) | |
const moveit::core::RobotState start_state(*getPlanningScene()->getCurrentStateUpdated(req.start_state)); | ||
const auto joint_model_group = getPlanningScene()->getRobotModel()->getJointModelGroup(getGroupName()); | ||
RCLCPP_INFO_STREAM(getLogger(), "Planning for group: " << getGroupName()); | ||
const int num_positions = plant.num_positions(); | ||
const int num_velocities = plant.num_velocities(); | ||
|
||
// extract position and velocity bounds | ||
std::vector<double> lower_position_bounds; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try initialize all of these with the known size (number of dofs) for efficiency. If you initialize them, change the Or you can |
||
std::vector<double> upper_position_bounds; | ||
std::vector<double> lower_velocity_bounds; | ||
std::vector<double> upper_velocity_bounds; | ||
std::vector<double> lower_acceleration_bounds; | ||
std::vector<double> upper_acceleration_bounds; | ||
std::vector<double> lower_jerk_bounds; | ||
std::vector<double> upper_jerk_bounds; | ||
lower_position_bounds.reserve(num_positions); | ||
upper_position_bounds.reserve(num_positions); | ||
lower_velocity_bounds.reserve(num_positions); | ||
upper_velocity_bounds.reserve(num_positions); | ||
lower_acceleration_bounds.reserve(num_positions); | ||
upper_acceleration_bounds.reserve(num_positions); | ||
lower_jerk_bounds.reserve(num_positions); | ||
upper_jerk_bounds.reserve(num_positions); | ||
|
||
const auto& all_joint_models = joint_model_group->getJointModels(); | ||
for (const auto& joint_model : all_joint_models) | ||
{ | ||
const auto& joint_name = joint_model->getName(); | ||
const bool is_active = joint_model_group->hasJointModel(joint_name); | ||
|
||
if (is_active) | ||
{ | ||
// Set bounds for active joints | ||
const auto& bounds = joint_model->getVariableBounds()[0]; | ||
lower_position_bounds.push_back(bounds.min_position_); | ||
upper_position_bounds.push_back(bounds.max_position_); | ||
lower_velocity_bounds.push_back(-bounds.max_velocity_); | ||
upper_velocity_bounds.push_back(bounds.max_velocity_); | ||
lower_acceleration_bounds.push_back(-bounds.max_acceleration_); | ||
upper_acceleration_bounds.push_back(bounds.max_acceleration_); | ||
lower_jerk_bounds.push_back(-params_.joint_jerk_bound); | ||
upper_jerk_bounds.push_back(params_.joint_jerk_bound); | ||
} | ||
else | ||
{ | ||
// Set default values for inactive joints | ||
lower_position_bounds.push_back(-kDefaultJointMaxPosition); | ||
upper_position_bounds.push_back(kDefaultJointMaxPosition); | ||
lower_velocity_bounds.push_back(0.0); | ||
upper_velocity_bounds.push_back(0.0); | ||
lower_acceleration_bounds.push_back(0.0); | ||
upper_acceleration_bounds.push_back(0.0); | ||
lower_jerk_bounds.push_back(0.0); | ||
upper_jerk_bounds.push_back(0.0); | ||
} | ||
} | ||
|
||
Eigen::Map<const Eigen::VectorXd> lower_position_bounds_eigen(lower_position_bounds.data(), | ||
lower_position_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> upper_position_bounds_eigen(upper_position_bounds.data(), | ||
upper_position_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> lower_velocity_bounds_eigen(lower_velocity_bounds.data(), | ||
lower_velocity_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> upper_velocity_bounds_eigen(upper_velocity_bounds.data(), | ||
upper_velocity_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> lower_acceleration_bounds_eigen(lower_acceleration_bounds.data(), | ||
lower_acceleration_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> upper_acceleration_bounds_eigen(upper_acceleration_bounds.data(), | ||
upper_acceleration_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> lower_jerk_bounds_eigen(lower_jerk_bounds.data(), lower_jerk_bounds.size()); | ||
Eigen::Map<const Eigen::VectorXd> upper_jerk_bounds_eigen(upper_jerk_bounds.data(), upper_jerk_bounds.size()); | ||
|
||
// q represents the complete state (joint positions and velocities) | ||
VectorXd q = VectorXd::Zero(plant.num_positions() + plant.num_velocities()); | ||
|
@@ -97,12 +168,10 @@ void KTOptPlanningContext::solve(planning_interface::MotionPlanResponse& res) | |
trajopt.AddPathVelocityConstraint(goal_velocity, goal_velocity, 1.0); | ||
|
||
// TODO: Add constraints on joint position/velocity/acceleration | ||
// trajopt.AddPositionBounds( | ||
// plant_->GetPositionLowerLimits(), | ||
// plant_->GetPositionUpperLimits()); | ||
// trajopt.AddVelocityBounds( | ||
// plant_->GetVelocityLowerLimits(), | ||
// plant_->GetVelocityUpperLimits()); | ||
trajopt.AddPositionBounds(lower_position_bounds_eigen, upper_position_bounds_eigen); | ||
trajopt.AddVelocityBounds(lower_velocity_bounds_eigen, upper_velocity_bounds_eigen); | ||
trajopt.AddAccelerationBounds(lower_acceleration_bounds_eigen, upper_acceleration_bounds_eigen); | ||
trajopt.AddJerkBounds(lower_jerk_bounds_eigen, upper_jerk_bounds_eigen); | ||
|
||
// Add constraints on duration | ||
// TODO: These should be parameters | ||
|
@@ -181,9 +250,7 @@ void KTOptPlanningContext::setRobotDescription(std::string robot_description) | |
// TODO:(kamiradi) Figure out object parsing | ||
// auto robot_instance = Parser(plant_, scene_graph_).AddModelsFromString(robot_description_, ".urdf"); | ||
|
||
// HACK: For now loading directly from drake's package map | ||
const char* ModelUrl = "package://drake_models/franka_description/" | ||
"urdf/panda_arm_hand.urdf"; | ||
const char* ModelUrl = params_.drake_robot_description.c_str(); | ||
const std::string urdf = PackageMap{}.ResolveUrl(ModelUrl); | ||
auto robot_instance = Parser(&plant, &scene_graph).AddModels(urdf); | ||
plant.WeldFrames(plant.world_frame(), plant.GetFrameByName("panda_link0")); | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to share the basic command