11 #include <geometry_msgs/Twist.h> 12 #include "sensor_msgs/JointState.h" 13 #include "hebiros/FeedbackMsg.h" 34 int main(
int argc,
char ** argv) {
37 ros::init(argc, argv,
"example_omnibase_odometry");
48 std::string group_name =
"omniGroup";
57 "/hebiros/"+group_name+
"/odometry", 100);
67 double d0;
double d1;
double d2;
69 double dtheta0;
double dtheta1;
double dtheta2;
70 sensor_msgs::JointState prevPose;
71 sensor_msgs::JointState currPose;
72 geometry_msgs::Twist output;
73 bool startup_complete =
false;
76 double wheelRadius = 0.0762;
77 double baseRadius = 0.235;
83 if ( !startup_complete ) {
87 startup_complete =
true;
96 d0 = (currPose.position[0] - prevPose.position[0]) * wheelRadius;
97 d1 = (currPose.position[1] - prevPose.position[1]) * wheelRadius;
98 d2 = (currPose.position[2] - prevPose.position[2]) * wheelRadius;
103 dtheta0 = d0 / (baseRadius);
104 dtheta1 = d1 / (baseRadius);
105 dtheta2 = d2 / (baseRadius);
106 output.angular.z += (dtheta0 + dtheta1 + dtheta2) / 3;
110 dx = (d0/2 + d1/2 - d2) * 2/3;
111 dy = (d0 * (-
sqrt(3)/2) + d1 * (
sqrt(3)/2)) * 2/3;
115 output.linear.x += dy *
sin(output.angular.z)
116 + dx *
cos(output.angular.z);
118 output.linear.y += dy * cos(output.angular.z)
119 - dx *
sin(output.angular.z);
122 odometry_publisher.
publish(output);
sensor_msgs::JointState feedback
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())
void feedback_callback(sensor_msgs::JointState data)
int main(int argc, char **argv)
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
sensor_msgs::JointState commands
EIGEN_DEVICE_FUNC const CosReturnType cos() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
ROSCPP_DECL void spinOnce()