I think that I got the basic of my ros project!
I have it such that it will tell me what the distance is at 180 degrees, will convert that to a string (a if >0.3, b if <0.2, c if in between) - figure a- and then a script to convert the string output published in the cmd_vel topic - figure b. rviz shows my data points appropriately. My rqt graph is what I was hoping it be -figure c. However I either get no movement on my robot, or a counterclockwise angular movement without linear movement. I think the problem must something with my callback script in figure b but I cant figure it out. I think its a simple syntatical error but I need some help
Thank you so much for any help. I feel that I am close!
Hi @r.franklinismail ,
I see that you are defining the Twist message, but it seems you are not publishing it after defining its values in your callback
Thank you!!! @marco.nc.arruda
This is very helpful
I still dont have any connection to the /cmd_vel after I use the following code. I double checked by using rostopic echo /cmd_vel and saw that nothing was being published into this.
The code I used to publish was
if request == “a”:
Twistobj.linear.x == 20 , Twistobj.angular.x == 2
elif request == “b”:
Twistobj.linear.x == 2 , Twistobj.angular.x == -2
elif request == “c”:
Twistobj.linear.x == 2 , Twistobj.angular.x == 0
print (“request completed”)
I also tried using
and got smae result
when I defined pub earlier in my code I defined it as
pub = rospy.Publisher(’/cmd_vel’, Twist, queue_size=1)
and I also made an instance of Twist so I feel like it should dump any data from pub.publisher() into the /cmd_vel topic? no?
No, the object is not published automatically.
You should put after your
if / elif / elif logic something like