Question

Je reçois cette erreur "Erreur: aucune fonction correspondante pour l'appel à ‘ros::NodeHandle::subscribe(const char [24], int, <unresolved overloaded function type>)’

Ceci est ma fonction de rappel dans ma classe BangbangControlunit

// on message reciept: 'current_maintained_temp' void current_maintained_temp_callback(const std_msgs::Int32::ConstPtr& msg){ temp_to_maintain = msg->data;
}

Et c'est comme ça que j'utilise sous-ami dans ma fonction principale

// subscribe to 'current_maintained_temp' ros::Subscriber current_maintained_temp_sub = n.subscribe("current_maintained_temp", 1000, control.current_maintained_temp_callback);

Quelqu'un peut-il me dire ce que j'ai fait de mal?

Était-ce utile?

La solution

La signature appropriée pour créer un abonné avec une méthode de classe comme rappel est la suivante:

ros::Subscriber sub = nh.subscribe("my_topic", 1, &Foo::callback, &foo_object);

Donc, dans votre cas, vous devez utiliser:

current_maintained_temp_sub = n.subscribe("current_maintained_temp", 1000, &BangBangControlUnit::current_maintained_temp_callback, &control);

Vous pouvez en savoir plus sur les éditeurs et les abonnés en C ++ ici.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top