Comments (6)
Oh, I guess you're right. I haven't considered controlling multiple joystick at once, so in my case the simplification works just fine. I have already implemented it this way withou issues. But yes, If I wanted to use more joysticks at once your solution is better.
from ros-mobile-android.
Yep, thats a big problem. Just to explain this:
Each Joystick widget create its own publisher. If two of them use the same topic name, one of them discards the other. It's only possible with ROS2 but there is also some kind of priority involved..
You could for example create an additional node which combines all the latest values from your 3 topics into one Twist message.
from ros-mobile-android.
Okay, this would be one of the simplest solution I came up with:
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
def msgCallback(inputMsg: Twist):
if inputMsg.linear.x:
outputMsg.linear.x = inputMsg.linear.x
if inputMsg.linear.y:
outputMsg.linear.y = inputMsg.linear.y
if inputMsg.linear.z:
outputMsg.linear.z = inputMsg.linear.z
if inputMsg.angular.x:
outputMsg.angular.x = inputMsg.angular.x
if inputMsg.angular.y:
outputMsg.angular.y = inputMsg.angular.y
if inputMsg.angular.z:
outputMsg.angular.z = inputMsg.angular.z
publisher.publish(outputMsg)
if __name__ == "__main__":
outputMsg = Twist()
rospy.init_node('combiner', anonymous=True)
subscriber1 = rospy.Subscriber("/twistX", Twist, msgCallback)
subscriber2 = rospy.Subscriber("/twistY", Twist, msgCallback)
subscriber3 = rospy.Subscriber("/twistZ", Twist, msgCallback)
publisher = rospy.Publisher("/twist", Twist, queue_size=10)
rospy.spin()
Please dont judge me on that... :D
So basically this node subscribes to all of your three joystick topics, which you have to change, and republish the combination via another topic (here "/twist", but of cause you can name however you like).
from ros-mobile-android.
Thanks, I will use the workaround.
I didn't realize multiple publishers on the same topic will be overriding each other.
Edit: By the way :D The callback could be just like this
def msgCallback(msg):
publisher.publish(msg)
from ros-mobile-android.
Regarding your edit:
I think you are not right, because only the values of the individual topics have to be copied to the tmp message if their not zero. Otherwise, you wouldnt get any benefits besides three times the message amount and a lot of zeros ^^
from ros-mobile-android.
I hope I was able to help you. I will close the issue, but feel free to open it again if you continue to have problems with that :)
from ros-mobile-android.
Related Issues (20)
- viz Unable to display grid map HOT 1
- Problem showing camera stream in Viz HOT 3
- Sending smartphone camera image to robot HOT 2
- viz2d can not load grid map
- Debug Widget HOT 2
- Does this only work if the robot/ linux computer is connected to the same WiFi as Android Phone?
- How to save the occupancy grid map using this app.
- rg.apache.http.conn.HttpHostConnectException: Connect to raw.githubusercontent.com:443 [raw.githubusercontent.com/0.0.0.0, raw.githubusercontent.com/0:0:0:0:0:0:0:0] failed: HOT 1
- Nodes do not subscribe the topics HOT 3
- I want to publish smartphone camera images using "ROS-Mobile".
- Unable to drive the mobile base forward and reverse due to thin GUI interface HOT 11
- Logger component not updating HOT 6
- Could not visualize the battery state topic using battery widget in Noetic HOT 12
- Possibility to save configurations HOT 3
- No data shown in VIZ tab. HOT 2
- Visualizing Pointcloud2 message type HOT 4
- Connecting to ROS and give error " HTTP method 'POST' not allowed" HOT 3
- How to use realsense as camera, and display in ROS-Mobile HOT 1
- I want to use my phone as a gps module HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ros-mobile-android.