ROS WARN Could not process inbound connection: topic types do not match
Hello, I'm working with ROS and AirSim, I'm also using the AirSim ROS Wrapper to comunicate between the two. As you can see, in the link there are some publishers, subscribers and so on... to do the comunication.
I wrote a python script that subscribes to the topic /cmdvel and then publishes the twist messages on the AirSim topic /airsimnode/velcmdbodyframe (a topic from AirSim ROS Wrapper Node). I think the comunication between the two is fine, however when I try to publish on /cmdvel by doing "rostopic pub /cmd_vel geometry..." I get this warning message on my console:
Could not process inbound connection: topic types do not match: [airsim_ros_pkgs/VelCmd] vs. [geometry_msgs/Twist]{'topic': '/airsim_node/drone_1/vel_cmd_body_frame', 'tcp_nodelay': '0', 'md5sum': 'a787b2802160dcc7fe02d089e10afe56', 'type': 'airsim_ros_pkgs/VelCmd', 'callerid': '/airsim_node'}
I think both of these topics are geometry_msgs/Twist twist, I don't know what I'm doing wrong. Can somebody help me? I will leave my code here, in case there's any mistake:
import rospy
import roslib
import tf
from std_msgs.msg import String
from geometry_msgs.msg import Twist
def callback(msg):
pub = rospy.Publisher('/airsim_node/drone_1/vel_cmd_body_frame', Twist, queue_size=10)
rospy.loginfo("Publishing: [%f, %f, %f]" %(msg.linear.x, msg.linear.y, msg.linear.z))
pub.publish(msg)
def listener():
global msg
rospy.init_node('cmdvel_listener', anonymous=True)
msg = Twist
rospy.Subscriber("/cmd_vel", Twist, callback)
rospy.spin()
if __name__ == '__main__':
listener()
Asked by nmpm on 2020-08-25 05:53:21 UTC
Answers
First, the AirSim is not expecting a geometry/twist msg but rather a airsim_ros_pkgs/VelCmd. The message types must match between a publisher and subscriber. So you need to import this message type into your script. Also, it’s not a good idea to define a publisher inside a callback. Either create a Class or define it in your main setup.
Asked by prefpkg21 on 2020-08-25 06:25:46 UTC
Comments
Hello, thanks for replying. Ok, but in the AirSim Ros Wrapper website when I click to see the type of the airsim_ros_pkgs/VelCmd it show me that it is geometry_msgs/Twist twist or am I missing something? Also, thanks for the heads up on the code, I'm new to python.
Asked by nmpm on 2020-08-25 06:55:37 UTC
The message is not a Twist, it has a twist inside it.
Asked by fergs on 2020-08-25 07:59:26 UTC
Oh ok!! I've been trying to add the import but I don't seem to find it. Do you have any idea what the import may be? Just one more thing that is in my mind... As VelCmd contains Twist inside do I just need to import this message type or do I still need to "transform" the data from Twist to VelCmd? TIA
Asked by nmpm on 2020-08-25 11:04:57 UTC
Comments