10 subscribers[
"hebiros/"+group_name+
"/command"] =
14 subscribers[
"hebiros/"+group_name+
"/command/joint_state"] =
16 "hebiros/"+group_name+
"/command/joint_state", 100,
23 ROS_WARN(
"Improper group type during register subscribers call");
27 group->group_ptr->requestInfo(group->group_info);
29 group->group_ptr->addFeedbackHandler([
this, group_name](
const GroupFeedback& group_fbk) {
30 this->feedback(group_name, group_fbk);
33 group->setFeedbackFrequency(
35 group->setCommandLifetime(
40 std::string group_name) {
46 ROS_WARN(
"Improper group type during command call");
50 sensor_msgs::JointState joint_data;
51 joint_data.name = data->name;
52 joint_data.position = data->position;
53 joint_data.velocity = data->velocity;
54 joint_data.effort = data->effort;
55 SettingsMsg settings_data;
56 settings_data = data->settings;
59 addJointCommand(&group_command, joint_data, group_name);
60 addSettingsCommand(&group_command, settings_data, group_name);
62 group->
group_ptr->sendCommand(group_command);
72 ROS_WARN(
"Improper group type during jointCommand call");
76 sensor_msgs::JointState joint_data;
77 joint_data.name = data->name;
78 joint_data.position = data->position;
79 joint_data.velocity = data->velocity;
80 joint_data.effort = data->effort;
83 addJointCommand(&group_command, joint_data, group_name);
85 group->
group_ptr->sendCommand(group_command);
89 sensor_msgs::JointState data, std::string group_name) {
93 for (
int i = 0; i < data.name.size(); i++) {
96 int joint_index = group->
joints[data.name[i]];
98 if (i < data.position.size()) {
99 (*group_command)[joint_index].actuator().position().set(data.position[i]);
101 if (i < data.velocity.size()) {
102 (*group_command)[joint_index].actuator().velocity().set(data.velocity[i]);
104 if (i < data.effort.size()) {
105 (*group_command)[joint_index].actuator().effort().set(data.effort[i]);
115 SettingsMsg data, std::string group_name) {
119 for (
int i = 0; i < data.name.size(); i++) {
122 int joint_index = group->
joints[data.name[i]];
124 if (i < data.save_current_settings.size()) {
125 if (data.save_current_settings[i]) {
126 (*group_command)[joint_index].settings().saveCurrentSettings().set();
129 if (i < data.control_strategy.size()) {
131 data.control_strategy[i]);
132 (*group_command)[joint_index].
133 settings().actuator().controlStrategy().set(strategy);
141 addPositionGainsCommand(group_command, data.position_gains, group_name);
142 addVelocityGainsCommand(group_command, data.velocity_gains, group_name);
143 addEffortGainsCommand(group_command, data.effort_gains, group_name);
147 PidGainsMsg data, std::string group_name) {
151 for (
int i = 0; i < data.name.size(); i++) {
154 int joint_index = group->
joints[data.name[i]];
156 if (i < data.kp.size()) {
157 (*group_command)[joint_index].
158 settings().actuator().positionGains().kP().set(data.kp[i]);
160 if (i < data.ki.size()) {
161 (*group_command)[joint_index].
162 settings().actuator().positionGains().kI().set(data.ki[i]);
164 if (i < data.kd.size()) {
165 (*group_command)[joint_index].
166 settings().actuator().positionGains().kD().set(data.kd[i]);
168 if (i < data.feed_forward.size()) {
169 (*group_command)[joint_index].
170 settings().actuator().positionGains().feedForward().set(data.feed_forward[i]);
172 if (i < data.dead_zone.size()) {
173 (*group_command)[joint_index].
174 settings().actuator().positionGains().deadZone().set(data.dead_zone[i]);
176 if (i < data.i_clamp.size()) {
177 (*group_command)[joint_index].
178 settings().actuator().positionGains().iClamp().set(data.i_clamp[i]);
180 if (i < data.punch.size()) {
181 (*group_command)[joint_index].
182 settings().actuator().positionGains().punch().set(data.punch[i]);
184 if (i < data.min_target.size()) {
185 (*group_command)[joint_index].
186 settings().actuator().positionGains().minTarget().set(data.min_target[i]);
188 if (i < data.max_target.size()) {
189 (*group_command)[joint_index].
190 settings().actuator().positionGains().maxTarget().set(data.max_target[i]);
192 if (i < data.target_lowpass.size()) {
193 (*group_command)[joint_index].
194 settings().actuator().positionGains().targetLowpass().set(data.target_lowpass[i]);
196 if (i < data.min_output.size()) {
197 (*group_command)[joint_index].
198 settings().actuator().positionGains().minOutput().set(data.min_output[i]);
200 if (i < data.max_output.size()) {
201 (*group_command)[joint_index].
202 settings().actuator().positionGains().maxOutput().set(data.max_output[i]);
204 if (i < data.output_lowpass.size()) {
205 (*group_command)[joint_index].
206 settings().actuator().positionGains().outputLowpass().set(data.output_lowpass[i]);
208 if (i < data.d_on_error.size()) {
209 (*group_command)[joint_index].
210 settings().actuator().positionGains().dOnError().set(data.d_on_error[i]);
220 PidGainsMsg data, std::string group_name) {
224 for (
int i = 0; i < data.name.size(); i++) {
227 int joint_index = group->
joints[data.name[i]];
229 if (i < data.kp.size()) {
230 (*group_command)[joint_index].
231 settings().actuator().velocityGains().kP().set(data.kp[i]);
233 if (i < data.ki.size()) {
234 (*group_command)[joint_index].
235 settings().actuator().velocityGains().kI().set(data.ki[i]);
237 if (i < data.kd.size()) {
238 (*group_command)[joint_index].
239 settings().actuator().velocityGains().kD().set(data.kd[i]);
241 if (i < data.feed_forward.size()) {
242 (*group_command)[joint_index].
243 settings().actuator().velocityGains().feedForward().set(data.feed_forward[i]);
245 if (i < data.dead_zone.size()) {
246 (*group_command)[joint_index].
247 settings().actuator().velocityGains().deadZone().set(data.dead_zone[i]);
249 if (i < data.i_clamp.size()) {
250 (*group_command)[joint_index].
251 settings().actuator().velocityGains().iClamp().set(data.i_clamp[i]);
253 if (i < data.punch.size()) {
254 (*group_command)[joint_index].
255 settings().actuator().velocityGains().punch().set(data.punch[i]);
257 if (i < data.min_target.size()) {
258 (*group_command)[joint_index].
259 settings().actuator().velocityGains().minTarget().set(data.min_target[i]);
261 if (i < data.max_target.size()) {
262 (*group_command)[joint_index].
263 settings().actuator().velocityGains().maxTarget().set(data.max_target[i]);
265 if (i < data.target_lowpass.size()) {
266 (*group_command)[joint_index].
267 settings().actuator().velocityGains().targetLowpass().set(data.target_lowpass[i]);
269 if (i < data.min_output.size()) {
270 (*group_command)[joint_index].
271 settings().actuator().velocityGains().minOutput().set(data.min_output[i]);
273 if (i < data.max_output.size()) {
274 (*group_command)[joint_index].
275 settings().actuator().velocityGains().maxOutput().set(data.max_output[i]);
277 if (i < data.output_lowpass.size()) {
278 (*group_command)[joint_index].
279 settings().actuator().velocityGains().outputLowpass().set(data.output_lowpass[i]);
281 if (i < data.d_on_error.size()) {
282 (*group_command)[joint_index].
283 settings().actuator().velocityGains().dOnError().set(data.d_on_error[i]);
293 PidGainsMsg data, std::string group_name) {
297 for (
int i = 0; i < data.name.size(); i++) {
300 int joint_index = group->
joints[data.name[i]];
302 if (i < data.kp.size()) {
303 (*group_command)[joint_index].
304 settings().actuator().effortGains().kP().set(data.kp[i]);
306 if (i < data.ki.size()) {
307 (*group_command)[joint_index].
308 settings().actuator().effortGains().kI().set(data.ki[i]);
310 if (i < data.kd.size()) {
311 (*group_command)[joint_index].
312 settings().actuator().effortGains().kD().set(data.kd[i]);
314 if (i < data.feed_forward.size()) {
315 (*group_command)[joint_index].
316 settings().actuator().effortGains().feedForward().set(data.feed_forward[i]);
318 if (i < data.dead_zone.size()) {
319 (*group_command)[joint_index].
320 settings().actuator().effortGains().deadZone().set(data.dead_zone[i]);
322 if (i < data.i_clamp.size()) {
323 (*group_command)[joint_index].
324 settings().actuator().effortGains().iClamp().set(data.i_clamp[i]);
326 if (i < data.punch.size()) {
327 (*group_command)[joint_index].
328 settings().actuator().effortGains().punch().set(data.punch[i]);
330 if (i < data.min_target.size()) {
331 (*group_command)[joint_index].
332 settings().actuator().effortGains().minTarget().set(data.min_target[i]);
334 if (i < data.max_target.size()) {
335 (*group_command)[joint_index].
336 settings().actuator().effortGains().maxTarget().set(data.max_target[i]);
338 if (i < data.target_lowpass.size()) {
339 (*group_command)[joint_index].
340 settings().actuator().effortGains().targetLowpass().set(data.target_lowpass[i]);
342 if (i < data.min_output.size()) {
343 (*group_command)[joint_index].
344 settings().actuator().effortGains().minOutput().set(data.min_output[i]);
346 if (i < data.max_output.size()) {
347 (*group_command)[joint_index].
348 settings().actuator().effortGains().maxOutput().set(data.max_output[i]);
350 if (i < data.output_lowpass.size()) {
351 (*group_command)[joint_index].
352 settings().actuator().effortGains().outputLowpass().set(data.output_lowpass[i]);
354 if (i < data.d_on_error.size()) {
355 (*group_command)[joint_index].
356 settings().actuator().effortGains().dOnError().set(data.d_on_error[i]);
372 ROS_WARN(
"Improper group type during feedback call");
376 FeedbackMsg feedback_msg;
377 sensor_msgs::JointState joint_state_msg;
379 for (
int i = 0; i < group_fbk.
size(); i++) {
380 std::string name = group->
group_info[i].settings().name().get();
381 std::string family = group->
group_info[i].settings().family().get();
382 double position = group_fbk[i].actuator().position().get();
383 double velocity = group_fbk[i].actuator().velocity().get();
384 double effort = group_fbk[i].actuator().effort().get();
387 joint_state_msg.name.push_back(family+
"/"+name);
388 joint_state_msg.position.push_back(position);
389 joint_state_msg.velocity.push_back(velocity);
390 joint_state_msg.effort.push_back(effort);
392 feedback_msg.name.push_back(family+
"/"+name);
393 feedback_msg.position.push_back(position);
394 feedback_msg.velocity.push_back(velocity);
395 feedback_msg.effort.push_back(effort);
396 feedback_msg.position_command.push_back(group_fbk[i].actuator().positionCommand().
get());
397 feedback_msg.velocity_command.push_back(group_fbk[i].actuator().velocityCommand().
get());
398 feedback_msg.effort_command.push_back(group_fbk[i].actuator().effortCommand().
get());
399 geometry_msgs::Vector3 accelerometer_msg;
400 accelerometer_msg.x = group_fbk[i].imu().accelerometer().get().getX();
401 accelerometer_msg.y = group_fbk[i].imu().accelerometer().get().getY();
402 accelerometer_msg.z = group_fbk[i].imu().accelerometer().get().getZ();
403 feedback_msg.accelerometer.push_back(accelerometer_msg);
404 geometry_msgs::Vector3 gyro_msg;
405 gyro_msg.x = group_fbk[i].imu().gyro().get().getX();
406 gyro_msg.y = group_fbk[i].imu().gyro().get().getY();
407 gyro_msg.z = group_fbk[i].imu().gyro().get().getZ();
408 feedback_msg.gyro.push_back(gyro_msg);
409 geometry_msgs::Quaternion orient_msg;
410 const auto& orient = group_fbk[i].imu().orientation().get();
411 orient_msg.w = orient.getW();
412 orient_msg.x = orient.getX();
413 orient_msg.y = orient.getY();
414 orient_msg.z = orient.getZ();
415 feedback_msg.orientation.push_back(orient_msg);
416 feedback_msg.deflection.push_back(group_fbk[i].actuator().deflection().
get());
417 feedback_msg.deflection_velocity.push_back(group_fbk[i].actuator().deflectionVelocity().
get());
418 feedback_msg.motor_velocity.push_back(group_fbk[i].actuator().motorVelocity().
get());
419 feedback_msg.motor_current.push_back(group_fbk[i].actuator().motorCurrent().
get());
420 feedback_msg.motor_winding_current.push_back(group_fbk[i].actuator().motorWindingCurrent().
get());
421 feedback_msg.motor_sensor_temperature.push_back(
422 group_fbk[i].actuator().motorSensorTemperature().
get());
423 feedback_msg.motor_winding_temperature.push_back(
424 group_fbk[i].actuator().motorWindingTemperature().
get());
425 feedback_msg.motor_housing_temperature.push_back(
426 group_fbk[i].actuator().motorHousingTemperature().
get());
427 feedback_msg.board_temperature.push_back(group_fbk[i].boardTemperature().
get());
428 feedback_msg.processor_temperature.push_back(group_fbk[i].processorTemperature().
get());
429 feedback_msg.voltage.push_back(group_fbk[i].voltage().
get());
430 std_msgs::ColorRGBA led_msg;
431 led_msg.r = group_fbk[i].led().getColor().getRed();
432 led_msg.g = group_fbk[i].led().getColor().getGreen();
433 led_msg.b = group_fbk[i].led().getColor().getBlue();
434 if (group_fbk[i].led().hasColor()) {
440 feedback_msg.led_color.push_back(led_msg);
441 feedback_msg.sequence_number.push_back(group_fbk[i].actuator().sequenceNumber().
get());
442 feedback_msg.receive_time.push_back(group_fbk[i].actuator().receiveTime().
get());
443 feedback_msg.transmit_time.push_back(group_fbk[i].actuator().transmitTime().
get());
444 feedback_msg.hardware_receive_time.push_back(group_fbk[i].actuator().hardwareReceiveTime().
get());
445 feedback_msg.hardware_transmit_time.push_back(
446 group_fbk[i].actuator().hardwareTransmitTime().
get());
static int getInt(std::string name)
static void addEffortGainsCommand(hebi::GroupCommand *group_command, hebiros::PidGainsMsg data, std::string group_name)
A list of Feedback objects that can be received from a Group of modules; the size() must match the nu...
void command(const boost::shared_ptr< hebiros::CommandMsg const > data, std::string group_name)
static HebirosPublishersPhysical publishers_physical
sensor_msgs::JointState joint_state_msg
void registerGroupSubscribers(std::string group_name)
size_t size() const
Returns the number of module feedbacks in this group feedback.
static void addVelocityGainsCommand(hebi::GroupCommand *group_command, hebiros::PidGainsMsg data, std::string group_name)
static std::shared_ptr< ros::NodeHandle > n_ptr
static void addSettingsCommand(hebi::GroupCommand *group_command, hebiros::SettingsMsg data, std::string group_name)
hebiros::FeedbackMsg feedback_msg
std::shared_ptr< hebi::Group > group_ptr
static HebirosGroupRegistry & Instance()
static void addJointCommand(hebi::GroupCommand *group_command, sensor_msgs::JointState data, std::string group_name)
static void addPositionGainsCommand(hebi::GroupCommand *group_command, hebiros::PidGainsMsg data, std::string group_name)
HebirosGroup * getGroup(const std::string &name)
std::map< std::string, int > joints
A list of Command objects appropriate for sending to a Group of modules; the size() must match the nu...
void feedbackJointState(sensor_msgs::JointState joint_state_msg, std::string group_name)
void jointCommand(const boost::shared_ptr< sensor_msgs::JointState const > data, std::string group_name)
static bool jointFound(std::string group_name, std::string joint_name)
hebi::GroupInfo group_info
static void jointNotFound(std::string joint_name)
void feedback(std::string group_name, const hebi::GroupFeedback &group_fbk)
void feedback(hebiros::FeedbackMsg feedback_msg, std::string group_name)