ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Wed, 16 Sep 2020 16:46:34 -0500Extract linear velocityhttps://answers.ros.org/question/361614/extract-linear-velocity/Greetings, dear community! I was wondering if you could help with some questions. I'm a college student and a beginner at using ROS, and right now I'm trying to implement a trajectory tracking algorithm for a differential robot. I'm using as a base a open model Gazebo simulation available on https://docs.neobotix.de/display/ROSSim/ROS-Simulation, and I wrote my nodes for the algorithm. The problem that I'm facing right now is I don't know from which topic of the simulation I should take the reading of the wheels previous velocities needed for the program. The last attempt I did was to subscribe to the joint topic to get the wheels angular displacement to obtain the wheel angular velocity and multiply the result by the wheel radius, and get in this way the wheel previous linear velocity. But the robot didn't performance as I was expecting. The work I've done so far can be found on https://gitlab.com/ga_07/electrical-project.git, inside my_simulation directory. I will appreciate any help you can give me!Tue, 15 Sep 2020 09:43:20 -0500https://answers.ros.org/question/361614/extract-linear-velocity/Comment by gabo07 for <p>Greetings, dear community! I was wondering if you could help with some questions. I'm a college student and a beginner at using ROS, and right now I'm trying to implement a trajectory tracking algorithm for a differential robot. I'm using as a base a open model Gazebo simulation available on <a href="https://docs.neobotix.de/display/ROSSim/ROS-Simulation">https://docs.neobotix.de/display/ROSS...</a>, and I wrote my nodes for the algorithm. The problem that I'm facing right now is I don't know from which topic of the simulation I should take the reading of the wheels previous velocities needed for the program. The last attempt I did was to subscribe to the joint topic to get the wheels angular displacement to obtain the wheel angular velocity and multiply the result by the wheel radius, and get in this way the wheel previous linear velocity. But the robot didn't performance as I was expecting. The work I've done so far can be found on <a href="https://gitlab.com/ga_07/electrical-project.git">https://gitlab.com/ga_07/electrical-p...</a>, inside my_simulation directory. I will appreciate any help you can give me!</p>
https://answers.ros.org/question/361614/extract-linear-velocity/?comment=361743#post-id-361743Sure! Here's a part of my code in which I have the question. I'm trying to get the linear velocity from each wheel (that's what I was expecting), so I tried a subscription to joint_state topic to obtain the wheel displacement measured on radians. Using those data, I calculated the angular velocity and then multiply it by wheel radius to finally have the linear velocity. I'm not sure if this is a correct way to get those values and I think this could be one of the mistakes on my simulation. I'll be thankful for any advice or help you can give meWed, 16 Sep 2020 16:46:34 -0500https://answers.ros.org/question/361614/extract-linear-velocity/?comment=361743#post-id-361743Comment by gabo07 for <p>Greetings, dear community! I was wondering if you could help with some questions. I'm a college student and a beginner at using ROS, and right now I'm trying to implement a trajectory tracking algorithm for a differential robot. I'm using as a base a open model Gazebo simulation available on <a href="https://docs.neobotix.de/display/ROSSim/ROS-Simulation">https://docs.neobotix.de/display/ROSS...</a>, and I wrote my nodes for the algorithm. The problem that I'm facing right now is I don't know from which topic of the simulation I should take the reading of the wheels previous velocities needed for the program. The last attempt I did was to subscribe to the joint topic to get the wheels angular displacement to obtain the wheel angular velocity and multiply the result by the wheel radius, and get in this way the wheel previous linear velocity. But the robot didn't performance as I was expecting. The work I've done so far can be found on <a href="https://gitlab.com/ga_07/electrical-project.git">https://gitlab.com/ga_07/electrical-p...</a>, inside my_simulation directory. I will appreciate any help you can give me!</p>
https://answers.ros.org/question/361614/extract-linear-velocity/?comment=361741#post-id-361741enter code here
from sensor_msgs.msg import JointState
self.joint_sub = rospy.Subscriber("joint_states", JointState, self.joint_callback, queue_size=100)
def joint_move(self):
if (self.Ts == 0):
self.Ts = 0.01
if((self.x_n != 0) and (self.y_n != 0)):
self.wxk_1 = (self.x_n - self.x_n_1)/self.Ts
self.wyk_1 = (self.y_n - self.y_n_1)/self.Ts
self.vxk_1 = self.R * self.wxk_1
self.vyk_1 = self.R * self.wyk_1
self.x_n_1 = self.x_n
self.y_n_1 = self.y_n
if (self.debug == True):
print("self.wxk_1: ", self.wxk_1)
print("self.wyk_1: ", self.wyk_1)
print("self.vxk_1: ", self.vxk_1)
print("self.vyk_1: ", self.vyk_1)
def joint_callback(self, msg):
self.x_n = msg.position[0]
self.y_n = msg.position[1]Wed, 16 Sep 2020 16:33:16 -0500https://answers.ros.org/question/361614/extract-linear-velocity/?comment=361741#post-id-361741Comment by jayess for <p>Greetings, dear community! I was wondering if you could help with some questions. I'm a college student and a beginner at using ROS, and right now I'm trying to implement a trajectory tracking algorithm for a differential robot. I'm using as a base a open model Gazebo simulation available on <a href="https://docs.neobotix.de/display/ROSSim/ROS-Simulation">https://docs.neobotix.de/display/ROSS...</a>, and I wrote my nodes for the algorithm. The problem that I'm facing right now is I don't know from which topic of the simulation I should take the reading of the wheels previous velocities needed for the program. The last attempt I did was to subscribe to the joint topic to get the wheels angular displacement to obtain the wheel angular velocity and multiply the result by the wheel radius, and get in this way the wheel previous linear velocity. But the robot didn't performance as I was expecting. The work I've done so far can be found on <a href="https://gitlab.com/ga_07/electrical-project.git">https://gitlab.com/ga_07/electrical-p...</a>, inside my_simulation directory. I will appreciate any help you can give me!</p>
https://answers.ros.org/question/361614/extract-linear-velocity/?comment=361642#post-id-361642> But the robot didn't performance as I was expecting.
What did you expect and what did you get? Instead of describing your approach can you please show us (i.e., paste the relevant code directly into your question)Tue, 15 Sep 2020 18:41:15 -0500https://answers.ros.org/question/361614/extract-linear-velocity/?comment=361642#post-id-361642