Transform link missing from base_footprint -> odom
Hello,
I am new to ROS and I am trying to make an indoor autonomous robot. However, I am getting an error when connecting the tf frame base_link to odom. I have linked a screenshot of the error. I am not sure what the cause of this error is. We used and adapted a good amount of code from Automatic Addison, although we use the MPU 6050 and different robot. I believe that the code could be an issue in our topic names; something that is occuring is that the code is mapping to imu/imu/data instead of what we want, which is just imu/data (only one), but we can't find in the code where exactly this changes. All the odom data is publishing in our ekf_odom_pub, attached below. I've also attached a picture of the TF tree, which shows that the odom/base_link is not linked. Any help or pointers would be awesome!
We have tried things like rostopic echo, list, etc, and data is printing for odom and imu. We suspect that because of this that it isn't a data issue but just a tf pub/sub issue.
`
#include "ros/ros.h"
#include "std_msgs/Int16.h"
#include <nav_msgs/Odometry.h>
#include <geometry_msgs/PoseStamped.h>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_ros/transform_broadcaster.h>
#include <cmath>
// Create odometry data publishers
ros::Publisher odom_data_pub;
ros::Publisher odom_data_pub_quat;
nav_msgs::Odometry odomNew;
nav_msgs::Odometry odomOld;
// Initial pose
const double initialX = 0.0;
const double initialY = 0.0;
const double initialTheta = 0.00000000001;
const double PI = 3.141592;
// Robot physical constants
const double TICKS_PER_REVOLUTION = 620; // For reference purposes.
const double WHEEL_RADIUS = 0.033; // Wheel radius in meters
const double WHEEL_BASE = 0.165; // Center of left tire to center of right tire
const double TICKS_PER_METER = 2700; // Original was 2800
// Distance both wheels have traveled
double distanceLeft = 0;
double distanceRight = 0;
// Flag to see if initial pose has been received
bool initialPoseRecieved = false;
using namespace std;
// Get initial_2d message from either Rviz clicks or a manual pose publisher
void set_initial_2d(const geometry_msgs::PoseStamped &rvizClick) {
odomOld.pose.pose.position.x = rvizClick.pose.position.x;
odomOld.pose.pose.position.y = rvizClick.pose.position.y;
odomOld.pose.pose.orientation.z = rvizClick.pose.orientation.z;
initialPoseRecieved = true;
}
// Calculate the distance the left wheel has traveled since the last cycle
void Calc_Left(const std_msgs::Int16& leftCount) {
static int lastCountL = 0;
if(leftCount.data != 0 && lastCountL != 0) {
int leftTicks = (leftCount.data - lastCountL);
if (leftTicks > 10000) {
leftTicks = 0 - (65535 - leftTicks);
}
else if (leftTicks < -10000) {
leftTicks = 65535-leftTicks;
}
else{}
distanceLeft = leftTicks/TICKS_PER_METER;
}
lastCountL = leftCount.data;
}
// Calculate the distance the right wheel has traveled since the last cycle
void Calc_Right(const std_msgs::Int16& rightCount) {
static int lastCountR = 0;
if(rightCount.data != 0 && lastCountR != 0) {
int rightTicks = rightCount.data - lastCountR;
if (distanceRight > 10000) {
distanceRight = (0 - (65535 - distanceRight))/TICKS_PER_METER;
}
else if (rightTicks < -10000) {
rightTicks = 65535 - rightTicks;
}
else{}
distanceRight = rightTicks/TICKS_PER_METER;
}
lastCountR = rightCount.data;
}
// Publish a nav_msgs::Odometry message in quaternion format
void publish_quat() {
tf2 ...