ROS-Mobile / ROS-Mobile-Android

Visualization and controlling application for Android
464 stars 148 forks source link

Unable to drive the mobile base forward and reverse due to thin GUI interface #88

Closed amjack0 closed 2 years ago

amjack0 commented 2 years ago

Hi,

I am using the ROS Mobile app for publishing the /cmd_vel to drive the mobile base. I am able to connect the app with the master and able to drive the robot. My issue is I am unable to drive the robot in a pure forward and backward movement. Because I can not keep the round knob in a straight line with the VERY THIN VERTICAL AXIS in a GUI.

Am I missing something here ?

ROS Noetic + 20.04 LTS Android device: Samsung Galaxy Tab S T800 https://www.amazon.de/Samsung-Tablet-PC-interner-Speicher-Bluetooth-grau/dp/B00R48MCFC

ROSmobile

nicostudt commented 2 years ago

Thanks for pointing this out! As you said, it is nearly impossible to keep the knob at a zero degree angle to the vertical axis. I had the idea to introduce a new joystick mode like a "sticky axis" which would publish only one of the axis values.

In the meantime you could filter the axis you dont want on the ROS side.

amjack0 commented 2 years ago

Hi @nicostudt, Thanks for your support.

In the meantime you could filter the axis you dont want on the ROS side. Can you explain, What do you mean by this ?

nicostudt commented 2 years ago

For example write an additional node that republishes /cmd_vel on a new topic but only with the values you want.

nicostudt commented 2 years ago

Give me a minute. I'll try to write you the necessary code for the node.

nicostudt commented 2 years ago

There you go ;)

#! /usr/bin/env python

import rospy
from geometry_msgs.msg import Twist

def velCallback(velMsg: Twist):
    threshold = 0.2

    if (abs(velMsg.linear.x) < threshold):
        velMsg.linear.x = 0

    if (abs(velMsg.angular.z) < threshold):
        velMsg.angular.z = 0;

    publisher.publish(velMsg)

if __name__ == "__main__":
    topicInput = "/cmd_vel"
    topicOutput = "/cmd_vel/filtered"

    rospy.init_node('vel_filter', anonymous=True)

    subscriber = rospy.Subscriber(topicInput, Twist, velCallback)
    publisher = rospy.Publisher(topicOutput, Twist, queue_size=10)

    rospy.spin()
nicostudt commented 2 years ago

Of cause you can change the input/output topics, the axis you use and the "threshold". The threshold simulates the area in the picture you mentioned above. I assumed both of your axis have values between -1 and 1, but feel free to remove the threshold variable and put in your numbers.

nicostudt commented 2 years ago

both of your axis have values between -1 and 1 ... and are centered around 0

amjack0 commented 2 years ago

Vielen dank ;) Great support ! I will implement this into my code base, will share the results.

nicostudt commented 2 years ago

Gern geschehen :)

amjack0 commented 2 years ago

I resolved the issue with,

take the turn only when, if (abs(msg.angular.z) > abs(msg.linear.x)): is true. Else I drive forward and backward. With this I can do PURE forward and backward motion.

You can close the issue, if you like. Thank you ;)

nicostudt commented 2 years ago

Thanks for the feedback! I hope I could help you a little bit.