First of all, I would like to ask if I can do my project in constructsim because I do not have a laptop or desktop with Linux to do simulation?
Let me move on to my main question, Ι have a question about the project.
I saw the course on the basic kinematics of a mobile robot, but up to the point of a differential drive section 3.3. I was able to find the equations that give the wheel speeds (right and left) as you describe in 3.2, I also saw exercise 3.2 with its solution, but I was not able to understand it to modify my template code according to the solution.
Below are the tests I did in the code to print the values Vl and Vr.
#!/usr/bin/env python """ Test ROS Node """ import rospy, roslib import operator import time import sys #import pigpio from math import sin, cos, atan2, pi, sqrt import numpy as np from std_msgs.msg import Float64 from geometry_msgs.msg import Twist class TestNode(): """Test node for templating""" def __init__(self): #ROS subscriber self.sub = rospy.Subscriber('/cmd_listener', Twist, self._callback, queue_size=1) self.twist_vels = Twist() self.vr = Float64() self.vl = Float64() self.rate = rospy.Rate(1) def _callback(self, msg): L = 0.4 # L = 40cm R = 0.05 # R = 5cm self.twist_vels = msg self.vr = ((2*self.twist_vels.linear.x) + (self.twist_vels.angular.z*L))/(2*R) self.vl = ((2*self.twist_vels.linear.x) - (self.twist_vels.angular.z*L))/(2*R) print(self.vr, self.vl) def publish(self): msg2pub = String() msg2pub.data = 'test_msg' while not rospy.is_shutdown(): self.pub.publish(msg2pub) self.pub_rate.sleep() def turn_off_node(self): """ Execute here the code when the node is terminated Ctrl + c """ pass if __name__ == '__main__': #Initialize the node rospy.init_node("test_node") #Create test node object tn = TestNode() #Handle shutdown rospy.on_shutdown(tn.turn_off_node) rospy.spin()
Eventually, I could not see the speed values, what mistake did I make in the code?
Thanks in advance!