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) {
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);
174 command_[0].actuator().effort().set(static_cast<float>(value * close_effort_ + (1.0 - value) * open_effort_));
179 Gripper(std::shared_ptr<hebi::Group>
group,
double close_effort,
double open_effort)
184 static std::shared_ptr<hebi::Group> getGroup(
Lookup& lookup,
const std::string& family,
const std::string& name) {
185 auto group = lookup.
getGroupFromNames(std::vector<std::string>{ family}, std::vector<std::string>{ name });
191 std::shared_ptr<hebi::Group> group_;
193 double close_effort_{};
194 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
Represents a group of physical HEBI modules, and allows Command, Feedback, and Info objects to be sen...
Definition: group.hpp:106
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
size_t size() const
Returns the number of modules in the group.
Definition: group.cpp:48
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:173
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
const Group & group() const
Definition: end_effector.hpp:165
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
Group & group()
Definition: end_effector.hpp:169
State
Definition: end_effector.hpp:53