I need a help with real robot odometry
I have bought a small DC motor and I am using this software to control the motor: LINK
Now, when I can control the robot and also getting ticks via magnetic encoders, it is time to navigate the robot autonomously. Here, I need your help to advice me on how can I correctly control the robot. Here is what I think I have to do:
First, using a custom made global planner, I am setting a path from starting point to goal point (in this case, I am getting a starting point from the transform information between /odom and /base_footprint). I call the service GetPlan. Eventually, I am getting a plan in nav_msgs::Plan fashion.
After getting a plan, it is now the part to start the motor (I am not yet using local planner). Here, next step I think is that I should invoke odometry node on callback and using AMCL lidar localization, extract a more precise location. After knowing the current location and the next goal point, I can use a constant velocity of 0.5 m/s, I know the distance to the next location, therefore, I have to set a time => t = v/d to know how long I need to publish the twist message of x (or y) = 0.5 m/s. For that, I will publish the velocity message to /cmd_vel topic for a t period of time (not for an infinite time as usual).
I will create a motor node, which is only subscribed to /cmd_vel topic and as soon it gets to the callback (I think it should be in a callback for t seconds only), I will use the above LINK example code to set the velocity 0.5 m/s to run the motor for a callback period of time, so the robot will start moving. While doing that, inside the callback, I will also publish the ticks to some custom topic like /ticks. After t seconds, the motor node will exit the callback and will be in a waiting mode.
As motor node was publishing ticks to /ticks topic for t time, odom node will also be subscribed to the /ticks topic to get the position of a robot. But here is my struggle, how can I do that? As odom node will already be subscribed to the path topic from which it extracts the path.
Question, do you have a full robot or just a single DC motor?