Skip to content
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

Just the interface for a combined gripper+manipulator. #11320

Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/manipulation_station/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ drake_cc_library(
],
)

drake_cc_library(
name = "combined_arm_and_gripper_model",
hdrs = [
"combined_arm_and_gripper_model.h",
],
visibility = ["//visibility:public"],
deps = [
"//multibody/tree",
],
)

drake_cc_binary(
name = "mock_station_simulation",
srcs = [
Expand Down
120 changes: 120 additions & 0 deletions examples/manipulation_station/combined_arm_and_gripper_model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#pragma once

#include "drake/common/eigen_types.h"
#include "drake/multibody/tree/multibody_tree_indexes.h"
#include "drake/systems/framework/context.h"
#include "drake/systems/framework/diagram.h"

namespace drake {

namespace systems {
template <typename T>
class DiagramBuilder;
}

namespace multibody {
template <typename T>
class MultibodyPlant;
}

namespace examples {
namespace manipulation_station {

/**
* An abstract class for adding a combined arm/gripper model and its
* controller to a Diagram and querying aspects of the model (e.g., the number
* of arm generalized positions).
*/
template <typename T>
class CombinedArmAndGripperModel {
public:
explicit CombinedArmAndGripperModel(
multibody::MultibodyPlant<T>* plant) : plant_(plant) {}
virtual ~CombinedArmAndGripperModel() {}

/// Gets the number of joints in the arm.
virtual int num_arm_joints() const = 0;

/// Gets the number of joints in the gripper.
virtual int num_gripper_joints() const = 0;

/// Gets the arm generalized positions.
virtual VectorX<T> GetArmPositions(
const systems::Context<T>& diagram_context,
const systems::Diagram<T>& diagram) const = 0;

/// Gets the gripper generalized positions.
virtual VectorX<T> GetGripperPositions(
const systems::Context<T>& diagram_context,
const systems::Diagram<T>& diagram) const = 0;

/// Sets the arm generalized positions.
virtual void SetArmPositions(
const systems::Context<T>& diagram_context,
const Eigen::Ref<const VectorX<T>>& q,
const systems::Diagram<T>& diagram,
systems::State<T>* diagram_state) const = 0;

/// Sets the gripper generalized positions to the default "open" position.
virtual void SetGripperPositionsToDefaultOpen(
const systems::Context<T>& diagram_context,
const systems::Diagram<T>& diagram,
systems::State<T>* diagram_state) const = 0;

/// Sets the gripper generalized positions.
virtual void SetGripperPositions(
const systems::Context<T>& diagram_context,
const Eigen::Ref<const VectorX<T>>& q,
const systems::Diagram<T>& diagram,
systems::State<T>* diagram_state) const = 0;

/// Gets the arm generalized velocities.
virtual VectorX<T> GetArmVelocities(
const systems::Context<T>& diagram_context,
const systems::Diagram<T>& diagram) const = 0;

/// Gets the gripper generalized velocities.
virtual VectorX<T> GetGripperVelocities(
const systems::Context<T>& diagram_context,
const systems::Diagram<T>& diagram) const = 0;

/// Sets the arm generalized velocities.
virtual void SetArmVelocities(
const systems::Context<T>& diagram_context,
const Eigen::Ref<const VectorX<T>>& v,
const systems::Diagram<T>& diagram,
systems::State<T>* diagram_state) const = 0;

/// Sets the gripper generalized velocities.
virtual void SetGripperVelocities(
const systems::Context<T>& diagram_context,
const Eigen::Ref<const VectorX<T>>& v,
const systems::Diagram<T>& diagram,
systems::State<T>* diagram_state) const = 0;

/// This method adds the arm and gripper models to the internal plant.
virtual void AddRobotModelToMultibodyPlant() = 0;

/// This method builds the control diagram for the arm and gripper
/// and adds it to the given builder for a Diagram.
virtual void BuildControlDiagram(systems::DiagramBuilder<T>* builder) = 0;

/// Gets a reference to the plant used for control.
virtual const multibody::MultibodyPlant<T>& get_controller_plant() const = 0;

/// Gets the model instance for the arm in the internal plant.
virtual multibody::ModelInstanceIndex arm_model_instance() const = 0;

/// Gets the model instance for the gripper in the internal plant.
virtual multibody::ModelInstanceIndex gripper_model_instance() const = 0;

protected:
// The MultibodyPlant holding the robot model (and possibly other models as
// well).
multibody::MultibodyPlant<T>* plant_{nullptr};
};

} // namespace manipulation_station
} // namespace examples
} // namespace drake