Hi there, I’m hoping to get some insight into a problem I’m having with using multiple instances of the same uORB topic.
I have a custom uORB topic that I’ve made and successfully can be subscribed and published to, but I can’t seem to create multiple instances of my topic.
I’ve tried using the same method with a “pre-done” uORB topic and it works well. Here is some of the code that is working and I am trying to replicate with my new topic, which is not working.
orb_advert_t batt_stat_pub;
struct battery_status_s batt_stat;
memset(&batt_stat, 0, sizeof(batt_stat));
int instance = 1;
batt_stat_pub = orb_advertise_multi(ORB_ID(battery_status), &batt_stat, &instance);
if(batt_stat_pub == NULL){
PX4_INFO("Publish error");
}
orb_publish(ORB_ID(battery_status), batt_stat_pub, &batt_stat);
// In a different file
uORB::Subscription _battery_status_updates{ORB_ID(battery_status), 1};
struct battery_status_s batt_stat;
_battery_status_updates.copy(&batt_stat);
Using this method works very well with the “pre-done” messages but does not create a new instance when I am working with a topic that I’ve added and instead the values that I publish are sent to instance 0.
Any insight would be grealy appreciated, thanks!