16 virtual bool update(Eigen::VectorXd& ) = 0;
18 virtual bool send() = 0;
63 static std::unique_ptr<Gripper>
create(
const std::string& family,
const std::string& name,
double close_effort,
double open_effort) {
65 if (
auto group = getGroup(lookup, family, name))
66 return std::unique_ptr<Gripper>(
new Gripper(group, close_effort, open_effort));
71 static std::unique_ptr<Gripper>
create(std::shared_ptr<hebi::Group>& group,
double close_effort,
double open_effort) {
72 if (!group || group->size() != 1)
74 return std::unique_ptr<Gripper>(
new Gripper(group, close_effort, open_effort));
78 static std::unique_ptr<Gripper>
create(
hebi::Lookup& lookup,
const std::string& family,
const std::string& name,
double close_effort,
double open_effort) {
79 if (
auto group = getGroup(lookup, family, name))
80 return std::unique_ptr<Gripper>(
new Gripper(group, close_effort, open_effort));
91 bool update(Eigen::VectorXd& aux_state)
override {
93 auto n = aux_state.size();
98 if (n == 1 && std::isfinite(aux_state[0])) {
102 return group_->getNextFeedback(
feedback_);
109 return group_->sendCommand(
command_);
158 if (!gains_cmd.readGains(gains_file))
161 return group_->sendCommandWithAcknowledgement(gains_cmd);
167 command_[0].actuator().effort().set(value * close_effort_ + (1.0 - value) * open_effort_);
172 Gripper(std::shared_ptr<hebi::Group> group,
double close_effort,
double open_effort)
173 :
EndEffectorBase(1), group_(group), close_effort_(close_effort), open_effort_(open_effort) {
177 static std::shared_ptr<hebi::Group> getGroup(
Lookup& lookup,
const std::string& family,
const std::string& name) {
178 auto group = lookup.
getGroupFromNames(std::vector<std::string>{ family}, std::vector<std::string>{ name });
179 if (!group || group->size() != 1)
184 std::shared_ptr<hebi::Group> group_;
186 double close_effort_{};
187 double open_effort_{};
A list of Feedback objects that can be received from a Group of modules; the size() must match the nu...
Definition: group_feedback.hpp:18
static std::unique_ptr< Gripper > create(hebi::Lookup &lookup, const std::string &family, const std::string &name, double close_effort, double open_effort)
Definition: end_effector.hpp:78
static double StateToDouble(State state)
Definition: end_effector.hpp:58
hebi::GroupCommand & pendingCommand()
Definition: end_effector.hpp:20
void toggle()
Definition: end_effector.hpp:144
bool update(Eigen::VectorXd &aux_state) override
Definition: end_effector.hpp:91
~Gripper() override=default
const hebi::GroupCommand & pendingCommand() const
Definition: end_effector.hpp:22
double getState()
Definition: end_effector.hpp:116
bool send() override
Definition: end_effector.hpp:108
std::shared_ptr< Group > getGroupFromNames(const std::vector< std::string > &families, const std::vector< std::string > &names, int32_t timeout_ms=DEFAULT_TIMEOUT) const
Get a group from modules with the given names and families.
Definition: lookup.cpp:27
virtual bool update(Eigen::VectorXd &)=0
void close()
Definition: end_effector.hpp:136
void setState(double state)
Definition: end_effector.hpp:121
static std::unique_ptr< Gripper > create(std::shared_ptr< hebi::Group > &group, double close_effort, double open_effort)
Definition: end_effector.hpp:71
hebi::GroupFeedback feedback_
Definition: end_effector.hpp:27
bool loadGains(const std::string &gains_file)
Definition: end_effector.hpp:156
void open()
Definition: end_effector.hpp:131
A list of Command objects appropriate for sending to a Group of modules; the size() must match the nu...
Definition: group_command.hpp:19
void setCommand(double value)
Definition: end_effector.hpp:166
Definition: end_effector.hpp:48
hebi::GroupCommand command_
Definition: end_effector.hpp:26
EndEffectorBase(size_t aux_size)
Definition: end_effector.hpp:13
virtual ~EndEffectorBase()=default
Maintains a registry of network-connected modules and returns Group objects to the user.
Definition: lookup.hpp:24
Definition: end_effector.hpp:11
void setState(State state)
Definition: end_effector.hpp:126
static std::unique_ptr< Gripper > create(const std::string &family, const std::string &name, double close_effort, double open_effort)
Definition: end_effector.hpp:63
State
Definition: end_effector.hpp:53