Hey Janak,
A lot of information here, let’s take it one by one. Please check the following:
- What kind of message is in
cmdVel
? It should be of type “Empty” for takeoff and land. I asked as I didn’t see that part of your code. - Publishing to a publisher does not work if it’s not yet “ready”. This usually happens if you try to publish immediately after creating the publisher.
- Where are you creating the publishers? Is your code recreating them on the fly? Ideally, you should create them in a ‘global’ place such that they are created once and available in all parts of the code.
- See How to publish once (only one message) into a topic and get it to work for a surefire way of publishing only once.
Have a look at that and then let’s know what’s left.