how can a python script connect to 2 rosmasters at the same time?
Hello,
I made a basic script that takes apriltag_ros /tag_detections topic and republishes it as odometry data. The python script is as follows:
#!/usr/bin/env python
import roslib;
import rospy
from apriltag_ros.msg import AprilTagDetectionArray
from nav_msgs.msg import Odometry
class OdomApril():
def __init__(self):
rospy.init_node('odom_april', anonymous=False)
self.april_pub = rospy.Publisher('/odom_april', Odometry, queue_size=128)
rospy.wait_for_message('/tag_detections', AprilTagDetectionArray)
rospy.Subscriber('/tag_detections', AprilTagDetectionArray, self.pub_april_odom)
rospy.loginfo("Publishing april odometry on /odom_april")
def pub_april_odom(self, msg):
odom = Odometry()
if(msg.detections):
odom.header = msg.header
odom.child_frame_id = 'base_footprint'
odom.pose = msg.detections[0].pose.pose
self.april_pub.publish(odom)
if __name__ == '__main__':
try:
OdomApril()
rospy.spin()
except:
pass
I am running a robot, with robot_pose_ekf, imu, and odometry in the raspberry pi on board the robot. However I am running apriltag_ros software in a laptop, attached to a ceiling mounted camera.
my purpose is to visualize both the robots odomety, and the apriltag based odometry in the same rviz.
Could it be possible for a python program, to subscribe to one ros master, and then publish to another ros master?
Best regards, C.A.