Logging and/or plotting a new topic

#1

Hey everybody

During my implemented algorithm, I am calculating certain parameters. Now I created a new topic for these and published the corresponding values. As far as I can tell, this worked (not sure though, but I don’t get any compile errors).

Now, I want to somehow plot these values. Therefore, I added a add_topic line in the file logger.cpp. Can this work and if not, how can I plot these topic values? Because when analyzing the resulting log files, there is my topic mentioned (after converting to a txt file), but when trying to make plots, it doesn’t come up in the list.

Does anybody can give me a hint, or maybe even a better alternative to get these parameters out of my code to analyze them? (Until now, I could only printf them to the terminal.

Thank you and regards!
Ed

#2

Hi,

To view the value of a topic in real time use the listener command. For analyzing the log file you can use several different tools or if you prefer matlab

#3

Thank you for your reply! I will definitely try out the listener command.

I am indeed able to analyze my log files and plot them with the use of the online tool or FlighPilot. The problem is, I am not sure how to get my newly created topic into the log file because until now I cannot plot it using e.g. FlighPilot.

I only added the topic to the logger.cpp file, is this enough?

#4

It depends on where you added it in the file. But for testing you can also define the topics to log in a text file. But in general yes, if you can see the topic publishing using uorb top or listener then adding the one line to logger.cpp should work

#5

Thanks for the answer. It worked indeed. I used the uorb top command and the listener command which gave me the expected values. Thus, publishing should work.

Now, I analyzed the log file and I see plots e.g. for actuator signals and so on. My new topic is listed in the FlightPlot app, too, but there are no values plotted if I select it.

Is there something else I have to consider such that the values are somehow saved in the log file? I really only added this one line add_topic(my_topic) in the logger.cpp file.

EDIT: I realised that I didn’t implement an unadvertise command, is this necessary?

#6

Try to run ulog2csv on the .ulg file, then you will get one CSV file for every topic which should be easy to inspect

#7

Thank you very much, it finally worked (even without running ulog2csv).