3 #include <nav_msgs/Odometry.h> 4 #include <std_srvs/Empty.h> 5 #include "sensor_msgs/JointState.h" 6 #include "hebiros/AddGroupFromNamesSrv.h" 32 bool reset_callback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res) {
42 x = data.pose.pose.position.x;
43 y = data.pose.pose.position.y;
48 int main(
int argc,
char** argv){
49 ros::init(argc, argv,
"example_mobile_robot_node");
62 std::string group_name =
"mobile_robot";
81 "/hebiros/add_group_from_names");
85 "/hebiros/"+group_name+
"/command/joint_state", 100);
88 AddGroupFromNamesSrv add_group_srv;
89 add_group_srv.request.group_name = group_name;
90 add_group_srv.request.names = {
"Left",
"Right"};
91 add_group_srv.request.families = {
"Wheels"};
92 while(!add_group_client.
call(add_group_srv)) {}
95 sensor_msgs::JointState command_msg;
96 command_msg.name.push_back(
"Wheels/Left");
97 command_msg.name.push_back(
"Wheels/Right");
98 command_msg.velocity.resize(2);
112 current_time,
"map",
"odom"));
116 geometry_msgs::TransformStamped odom_trans;
117 odom_trans.header.stamp = current_time;
118 odom_trans.header.frame_id =
"odom";
119 odom_trans.child_frame_id =
"base_link";
120 odom_trans.transform.translation.x =
x;
121 odom_trans.transform.translation.y =
y;
122 odom_trans.transform.translation.z = 0.0;
123 odom_trans.transform.rotation =
odom_quat;
127 nav_msgs::Odometry odom;
128 odom.header.stamp = current_time;
129 odom.header.frame_id =
"odom";
130 odom.child_frame_id =
"base_link";
132 odom.pose.pose.position.x =
x;
133 odom.pose.pose.position.y =
y;
134 odom.pose.pose.position.z = 0.0;
137 odom.twist.twist.linear.x =
vx;
138 odom.twist.twist.linear.y =
vy;
139 odom.twist.twist.angular.z =
vth;
146 command_publisher.publish(command_msg);
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
void odometry_callback(nav_msgs::Odometry data)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool call(MReq &req, MRes &res)
bool reset_callback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void cmd_vel_callback(geometry_msgs::Twist msg)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ROSCPP_DECL void spinOnce()
geometry_msgs::Quaternion odom_quat