24 services[
"hebiros/"+group_name+
"/size"] =
26 "hebiros/"+group_name+
"/size",
29 services[
"hebiros/"+group_name+
"/set_feedback_frequency"] =
31 SetFeedbackFrequencySrv::Response>(
32 "hebiros/"+group_name+
"/set_feedback_frequency",
35 services[
"hebiros/"+group_name+
"/set_command_lifetime"] =
37 SetCommandLifetimeSrv::Response>(
38 "hebiros/"+group_name+
"/set_command_lifetime",
41 services[
"hebiros/"+group_name+
"/send_command_with_acknowledgement"] =
43 SendCommandWithAcknowledgementSrv::Response>(
44 "hebiros/"+group_name+
"/send_command_with_acknowledgement",
49 EntryListSrv::Request &req, EntryListSrv::Response &res) {
51 EntryListMsg entry_list_msg;
55 entry_list_msg.size = entry_list->size();
58 for (
auto entry : *entry_list) {
59 entry_msg.name = entry.name_;
60 entry_msg.family = entry.family_;
62 entry_msg.mac_address = 0;
64 ROS_INFO(
"/%s/%s/%2x:%2x:%2x:%2x:%2x:%2x", entry_msg.family.c_str(), entry_msg.name.c_str(),
65 entry.mac_address_[0], entry.mac_address_[1], entry.mac_address_[2],
66 entry.mac_address_[3], entry.mac_address_[4], entry.mac_address_[5]);
67 entry_list_msg.entries.push_back(entry_msg);
70 res.entry_list = entry_list_msg;
75 AddGroupFromNamesSrv::Request &req, AddGroupFromNamesSrv::Response &res,
76 std::map<std::string, std::string> joint_full_names) {
78 auto& registry = HebirosGroupRegistry::Instance();
80 if (registry.hasGroup(req.group_name)) {
82 ROS_WARN(
"Group [%s] already exists", req.group_name.c_str());
90 ROS_WARN(
"Lookup of group [%s] failed", req.group_name.c_str());
95 group->joint_full_names = joint_full_names;
110 AddGroupFromNamesSrv::Request &req, AddGroupFromNamesSrv::Response &res) {
112 std::map<std::string, std::string> joint_full_names;
118 AddGroupFromURDFSrv::Request &req, AddGroupFromURDFSrv::Response &res) {
120 std::string urdf_name(
"robot_description");
124 ROS_WARN(
"Could not load robot_description");
131 std::set<std::string> joint_names;
132 std::set<std::string> family_names;
133 std::map<std::string, std::string> joint_full_names;
136 urdf_model.getRoot().get());
138 AddGroupFromNamesSrv::Request names_req;
139 AddGroupFromNamesSrv::Response names_res;
140 names_req.group_name = req.group_name;
141 names_req.families.insert(names_req.families.end(), family_names.begin(), family_names.end());
142 names_req.names.insert(names_req.names.end(), joint_names.begin(), joint_names.end());
148 AddModelFromURDFSrv::Request &req, AddModelFromURDFSrv::Response &res) {
154 SizeSrv::Request &req, SizeSrv::Response &res, std::string group_name) {
163 SetFeedbackFrequencySrv::Request &req, SetFeedbackFrequencySrv::Response &res,
164 std::string group_name) {
166 auto& registry = HebirosGroupRegistry::Instance();
180 SetCommandLifetimeSrv::Request &req, SetCommandLifetimeSrv::Response &res,
181 std::string group_name) {
183 auto& registry = HebirosGroupRegistry::Instance();
196 SendCommandWithAcknowledgementSrv::Request &req,
197 SendCommandWithAcknowledgementSrv::Response &res, std::string group_name) {
203 ROS_WARN(
"Improper group type during command call");
209 sensor_msgs::JointState joint_data;
210 joint_data.name = req.command.name;
211 joint_data.position = req.command.position;
212 joint_data.velocity = req.command.velocity;
213 joint_data.effort = req.command.effort;
214 SettingsMsg settings_data;
215 settings_data = req.command.settings;
220 return group->
group_ptr->sendCommandWithAcknowledgement(group_command);
bool sendCommandWithAcknowledgement(SendCommandWithAcknowledgementSrv::Request &req, SendCommandWithAcknowledgementSrv::Response &res, std::string group_name)
static HebirosPublishersPhysical publishers_physical
bool addModelFromURDF(AddModelFromURDFSrv::Request &req, AddModelFromURDFSrv::Response &res)
bool addGroup(AddGroupFromNamesSrv::Request &req, AddGroupFromNamesSrv::Response &res, const std::map< std::string, std::string > &joint_full_names, std::unique_ptr< HebirosGroup > group_tmp)
void registerNodeServices()
virtual void setFeedbackFrequency(float frequency_hz)
bool setCommandLifetime(SetCommandLifetimeSrv::Request &req, SetCommandLifetimeSrv::Response &res, std::string group_name)
void registerGroupPublishers(std::string group_name)
void registerGroupSubscribers(std::string group_name)
bool setFeedbackFrequency(SetFeedbackFrequencySrv::Request &req, SetFeedbackFrequencySrv::Response &res, std::string group_name)
void addJointChildren(std::set< std::string > &names, std::set< std::string > &families, std::map< std::string, std::string > &full_names, const urdf::Link *link)
std::shared_ptr< EntryList > getEntryList()
static std::shared_ptr< ros::NodeHandle > n_ptr
bool addGroupFromNames(AddGroupFromNamesSrv::Request &req, AddGroupFromNamesSrv::Response &res)
static void addSettingsCommand(hebi::GroupCommand *group_command, hebiros::SettingsMsg data, std::string group_name)
bool setFeedbackFrequency(SetFeedbackFrequencySrv::Request &req, SetFeedbackFrequencySrv::Response &res, std::string group_name)
virtual void setCommandLifetime(float lifetime_ms)
std::shared_ptr< hebi::Group > group_ptr
bool entryList(EntryListSrv::Request &req, EntryListSrv::Response &res)
bool addModelFromURDF(AddModelFromURDFSrv::Request &req, AddModelFromURDFSrv::Response &res)
static HebirosGroupRegistry & Instance()
static void addJointCommand(hebi::GroupCommand *group_command, sensor_msgs::JointState data, std::string group_name)
HebirosGroup * getGroup(const std::string &name)
bool addGroup(AddGroupFromNamesSrv::Request &req, AddGroupFromNamesSrv::Response &res, std::map< std::string, std::string > joint_full_names)
URDF_EXPORT bool initParam(const std::string ¶m)
void registerGroupActions(std::string group_name)
A list of Command objects appropriate for sending to a Group of modules; the size() must match the nu...
void registerGroupServices(std::string group_name)
bool size(SizeSrv::Request &req, SizeSrv::Response &res, std::string group_name)
static HebirosSubscribersPhysical subscribers_physical
bool size(SizeSrv::Request &req, SizeSrv::Response &res, std::string group_name)
static std::map< std::string, ros::ServiceServer > services
static HebirosActions actions
bool setCommandLifetime(SetCommandLifetimeSrv::Request &req, SetCommandLifetimeSrv::Response &res, std::string group_name)
static HebirosServicesPhysical services_physical
bool addGroupFromURDF(AddGroupFromURDFSrv::Request &req, AddGroupFromURDFSrv::Response &res)
bool addGroupFromURDF(AddGroupFromURDFSrv::Request &req, AddGroupFromURDFSrv::Response &res)
std::shared_ptr< Group > getGroupFromNames(const std::vector< std::string > &families, const std::vector< std::string > &names, int32_t timeout_ms=DEFAULT_TIMEOUT)
Get a group from modules with the given names and families.