Trying to access a single drone suscribed topic value for the entire fleet of drone

asked 2022-07-01 03:33:08 -0500

Hi there !

I'm working on a fleet of drones in Gazebo, and I'm using ROS to control it (beginner). I have a topic that allows to publish a new target to one of my drones, but not to all. I add this target to a list, but it is not visible by other drones. How can I make this subscribed variable accessible to my entire fleet?

Here are my callback function, the published topic and my target tracking function, which only applies to the intelaero_bugwright_4 drone in this case.

def target_tracking(self):
    if len(self.target_list)>0:
        last = len(self.target_list) - 1
        target = self.target_list[last]
        self.target_pxyz = np.array([
            target.position.x,
            target.position.y,
            target.position.z])
        self.target_psi = quaternion2psi([
            target.orientation.x,
            target.orientation.y,
            target.orientation.z,
            target.orientation.w])
        TargetDiff = self.target_pxyz - self.state_pxyz
        NormTargetDiff = np.linalg.norm(TargetDiff)
        TargetDiff /= NormTargetDiff
        TargetDiff *= SigmoidLike(NormTargetDiff, self.R_trg, self.d_trg)
        return (TargetDiff*self.freq)
    else:
        return np.zeros(3)

rostopic pub /intelaero_bugwright_4/new_target geometry_msgs/Pose

    def callback_target(self,data):
    """
    """
    self.target_list.append(data)
edit retag flag offensive close merge delete