How can I extract the frequency (in Hz) of a topic inside a rosbag? - ros

I have a rosbag file, which has recorded messages of several topics.
Is there a way I can know the frequency at which the messages of a particular topic were published (and recorded)?
when I do rosbag info I get something like
path: the.bag
version: 2.0
duration: 60.0s
start: Jul 01 2021 16:58:10.27 (1625158690.27)
end: Jul 01 2021 16:59:10.27 (1625158750.27)
size: 6.1 GB
messages: 37131
compression: none [1188/1188 chunks]
types: sensing_msgs/type1 [621fdfebbc8899ba27ee5fed4fcccaee]
sensing_msgs/type2 [cf69c51b4a51518b0ef7e36af744fc70]
sensor_msgs/Image [060021388200f6f0f447d0fcd9c64743]
topics: /mycamera/image 1187 msgs : sensor_msgs/Image
/mymessage1 29944 msgs : sensing_msgs/type1
/mymessage2/input 6000 msgs : sensing_msgs/type2

If you know message publication is continuous throughout the recording frequency is just total_messages / time. Otherwise you can get frequency via rosbag play <bag_file> and rostopic hz <topic_name>

Related

Finding the documentation for parsing data found in BLE Advertising Respones

This is not a programming related question. It's a question about where to find the right documentation.
If this is not the right place to ask, please let me know and I'll move the question
I'm working on a C++-Deamon for parsing recieved BLE Advertising Packages (like hcidump from bleuz). For this I'm focusing on parsing only LE Advertising Report events (Bluetooth Core Specification 7.7.65.2, S. 2382 ff)
E. g: I need to extract the local name and the 16-bit UUID. This information can be found (if broadcasted) in the field "data".
I can extract the data part from the Advertising Event Packet (since it's described in the Core Specification how these packages are arranged) but I can't parse the data. I wasn't able to find a description of the codes used in this data frame.
I also went through the Core Specification Supplement, but I couldn’t find the corresponding codes. I only found some examples:
See Site 26: Apparently the byte 0x09 indicates that the following n bytes are the broadcasted name of the BLE-Device.
Or Site 25: 0x03 seems to indicate that a "Complete list of 16-bit Service UUIDs" is following.
So far I gained my knowledge about this by just going throught these (incomplete) list of examples I found and from looking at the source code of hcidump.c.
Now the question is: Where can I find the official complete list to those bytes/codes?
Just an example of the package content I revieve:
Respone: 04 3E 1C 02 01 04 01 55 19 19 E4 8D FE 10 0F 09 54 65 73 74
20 49 50 53 50 20 6E 6F 64 65 C5
It should be able to extract the following data
HCI Event: LE Meta Event (0x3e) plen 28
LE Advertising Report
SCAN_RSP - Scan Response (4)
bdaddr FE:8D:E4:19:19:55 (Random)
Complete local name: 'Test IPSP node'
RSSI: -61
After going throught the whole Bluetooth SIG, I finally found the site where these codes are described:
https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/

Estimating mortality with acmeR package

There is a relatively new package that has come out called acmeR for producing estimates of mortality (for birds and bats), and it takes into consideration things like bleedthrough (was the carcass still there but undetected, and then found in a later search?), diminishing searcher efficiency, etc. This is extremely useful, except I can't seem to get it to work, despite it seeming to be pretty straightforward. The data structure should be like:
Date, in US format mm/dd/yyyy or ISO 8601 format yyyy-mm-dd
Time, in am/pm US format HH:MM:SS AM or 24-hr ISO format HH:MM:SS
ID, arbitrary distinct alpha strings unique to each carcas
Species, arbitrary distinct alpha strings (e.g. AOU, ABMP, IBP)
Event, “Place”, “Check”, or “Search” (only 1st letter counts)
Found, TRUE or FALSE (only 1st letter counts)
and look something like this:
“Date”,“Time”,“ID”,“Species”,“Event”,“Found”
“1/7/2011”,“08:00:00 PM”,“T091”,“UNBA”,“Place”,TRUE
“1/8/2011”,“12:00:00 PM”,“T091”,“UNBA”,“Check”,TRUE
“1/8/2011”,“16:00:00 PM”,“T091”,“UNBA”,“Search”,FALSE
My data look like this:
Date: Date, format: "2017-11-09" "2017-11-09" "2017-11-09" ...
Time: Factor w/ 644 levels "1:00 PM","1:01 PM",..: 467 491 518 89 164 176 232 39 53 247 ...
Species: Factor w/ 52 levels "AMCR","AMKE",..: 31 27 39 27 39 31 39 45 27 24 ...
ID: Factor w/ 199 levels "GHBT001","GHBT002",..: 1 3 2 3 2 1 2 7 3 5 ...
Event: Factor w/ 3 levels "Check","Place",..: 2 2 2 3 3 3 1 2 1 2 ...
Found: logi TRUE TRUE TRUE FALSE TRUE TRUE ...
I have played with the date, time, event, etc formats too, trying multiple formats because I have had some issues there. So here are some of the errors I have encountered, depending on what subset of data I use:
Error in optim(p0, f, rd = rd, method = "BFGS", hessian = TRUE) :non-finite value supplied by optim In addition: Warning message: In log(c(a0, b0, t0)) : NaNs produced
Error in read.data(fname, spec = spec, blind = blind) : Expecting date format YYYY-MM-DD (ISO) or MM/DD/YYYY (USA) USA
Error in solve.default(rv$hessian): system is computationally singular: reciprocal condition number = 1.57221e-20
Warning message: # In sqrt(diag(Sig)[2]) : NaNs produced
Error in solve.default(rv$hessian) : Lapack routine dgesv: system is exactly singular: U[2,2] = 0
The last error is most common (and note, my data are non-numeric, sooooo... I am not sure what math is being done behind the scenes to come up with these equations, then fail in the solve), but the others are persistent too. Sometimes, despite the formatting being exactly the same in one dataset, a subset of that data will return an error when the parent dataset does not (does not have anything to do with species being there/not being there in one or the other dataset, as far as I can tell).
I cannot find any bug reports or issues with the acmeR package out there - so maybe it runs perfectly and my data are the problem, but after three ecologists have vetted the data and pronounced it good, I am at a dead end.
Here is a subset of the data, so you can see what they look like:
Date Time Species ID Event Found
8 2017-11-09 1:39 PM VATH GHBT007 P T
11 2017-11-09 2:26 PM CORA GHBT004 P T
12 2017-11-09 2:30 PM EUST GHBT006 P T
14 2017-11-09 6:43 AM CORA GHBT004 S T
18 2017-11-09 8:30 AM EUST GHBT006 S T
19 2017-11-09 9:40 AM CORA GHBT004 C T
20 2017-11-09 10:38 AM EUST GHBT006 C T
22 2017-11-09 11:27 AM VATH GHBT007 S F
32 2017-11-09 10:19 AM EUST GHBT006 C F

MPEGTS h264 high#L4.0 can not play on ios device

My MPEG-TS video has problem playing on iOS via HTTP Live Streaming. The iPhone can play the file, but it seems it lost half of its frames. The video is slow and not continuous and smooth on the iPhone, but the VLC can play the stream without problems. I have posted the information of the mpegts file, it was encoded under profile High#L4.0 H264. iPhone 5c or 5s should have the ability to handle it.
Information probed by mediainfo command:
General
ID : 1 (0x1)
Complete name : segment00007.ts
Format : MPEG-TS
File size : 169 KiB
Duration : 5s 990ms
Overall bit rate mode : Variable
Overall bit rate : 216 Kbps
Video
ID : 65 (0x41)
Menu ID : 1 (0x1)
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High#L4.0
Format settings, CABAC : Yes
Format settings, ReFrames : 1 frame
Codec ID : 27
Duration : 6s 63ms
Bit rate : 206 Kbps
Width : 640 pixels
Height : 480 pixels
Display aspect ratio : 4:3
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Stream size : 152 KiB (90%)
$ avconv -i segment00007.ts
avconv version 9.14-6:9.14-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
built on Jul 15 2014 13:57:40 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=327815314, dts=327815357, size=7191
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=327997410, dts=327997563, size=7232
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=328104538, dts=328104565, size=1458
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=328117902, dts=328118015, size=1476
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=328141590, dts=328141634, size=1573
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=328165614, dts=328165629, size=1913
[mpegts # 0x16e7840] Invalid timestamps stream=0, pts=328180354, dts=328180554, size=7192
[mpegts # 0x16e7840] max_analyze_duration reached
Input #0, mpegts, from 'segment00007.ts':
Duration: 00:00:06.08, start: 3642.385822, bitrate: 227 kb/s
Program 1
Stream #0.0[0x41]: Video: h264 (High), yuv420p, 640x480, 30.08 fps, 90k tbn
At least one output file must be specified

reducing jitter of serial ntp refclock

I am currently trying to connect my DIY DC77 clock to ntpd (using Ubuntu). I followed the instructions here: http://wiki.ubuntuusers.de/Systemzeit.
With ntpq I can see the DCF77 clock
~$ ntpq -c peers
remote refid st t when poll reach delay offset jitter
==============================================================================
+dispatch.mxjs.d 192.53.103.104 2 u 6 64 377 13.380 12.608 4.663
+main.macht.org 192.53.103.108 2 u 12 64 377 33.167 5.008 4.769
+alvo.fungus.at 91.195.238.4 3 u 15 64 377 16.949 7.454 28.075
-ns1.blazing.de 213.172.96.14 2 u - 64 377 10.072 14.170 2.335
*GENERIC(0) .DCFa. 0 l 31 64 377 0.000 5.362 4.621
LOCAL(0) .LOCL. 12 l 927 64 0 0.000 0.000 0.000
So far this looks OK. However I have two questions.
What exactly is the sign of the offset? Is .DCFa. ahead of the system clock or behind the system clock?
.DCFa. points to refclock-0 which is a DIY DCF77 clock emulating a Meinberg clock. It is connected to my Ubuntu Linux box with an FTDI usb-serial adapter running at 9600 7e2. I verified with a DSO that it emits the time with jitter significantly below 1ms. So I assume the jitter is introduced by either the FTDI adapter or the kernel. How would I find out and how can I reduce it?
Part One:
Positive offsets indicate time in the client is behind time on the server.
Negative offsets indicate that time in the client is ahead of time on the server.
I always remember this as "what needs to happen to my clock?"
+0.123 = Add 0.123 to me
-0.123 = Subtract 0.123 from me
Part Two:
Yes the USB serial converters add jitter. Get a real serial port:) You can also use setserial and tell it that the serial port needs to be low_latency. Just apt-get setserial.
Bonus Points:
Lose the unreferenced local clock entry. NO LOCL!!!!

iPad MP4 playback issues

I'm wondering weather this is an issue with iOS devices or just the iPad (I've actually only had an iPad to play on).
If I were to write a HTML link that linked to an MP4 on a server (over HTTP), the iPad launches it in Safari but doesn't recognise that it's an MP4 and just serves a blank page.
I've had a look on other devices, such as Android for eg, and this fires up the media player and streams correctly.
Is there a specific way to get it to play in the default media player on iPad/iOS?
The problem is more than likely the particular encoding characteristics of the MP4. h264 and MPEG-4 have loads of little options and tweakable parameters. iOS devices are fairly specific about what they do and do not like. (To be fair, this is not a problem specific to iOS devices.)
Have a look at Brightcove's encoding recommendations and re-encode your media.
That failing, and assuming you have FFmpeg installed, post the results of ffmpeg -i problemfile.mp4 and comment below so I can have a look.
I'm experiencing a very similar problem with the iPad in playing an mp4 file, which in fact was encoded by Brightcove.
The video won't start inside an html5 video tag using the iPad, while it works perfectly in Chrome, Safari and IE9.
You can grab the video here: http://tinyurl.com/796c5ub and this is the output of $ffmpeg -i video1.mp4:
ffmpeg version 0.7.1, Copyright (c) 2000-2011 the FFmpeg developers
built on Jul 31 2011 18:31:40 with clang 2.1 (tags/Apple/clang-163.7.1)
configuration: --prefix=/opt/local --enable-gpl --enable-postproc --enable-swscale --enable-avfilter --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libdirac --enable-libschroedinger --enable-libfaac --enable-libxvid --enable-libx264 --enable-libvpx --enable-libspeex --enable-nonfree --mandir=/opt/local/share/man --enable-shared --enable-pthreads --disable-indevs --cc=/Developer/usr/bin/clang --arch=x86_64
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.122. 0 / 52.122. 0
libavformat 52.110. 0 / 52.110. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2011-12-06 08:00:00
encoder : Lavf53.17.0
Duration: 00:00:45.60, start: 0.000000, bitrate: 1818 kb/s
Stream #0.0(eng): Video: h264 (High), yuv420p, 1280x852, 1687 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
creation_time : 2011-12-06 08:00:00
Stream #0.1(eng): Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
Metadata:
creation_time : 2011-12-06 08:00:00
At least one output file must be specified
Found this while looking for a solution for iOS-related MP4-audio problems: Some of my MP4 audio files would start to play, but at a certain point in the file, playback on iOS would hang, while non-iOS players played the same MP4 files flawlessly till the end.
MP4 is a container format. Said to also contain non-audio/non-video streams and metadata headers that describe audio/video. iOS seems to dislike some stream types and if some headers are at unexpected positions in the file.
mp4box and ffmpeg can fix these headers and remove unwanted streams.
I only fiddled with mp4box, that did it for me to fix the audio problems:
mp4box -single 1 input.mp4 -out outputfixed.mp4
The "1" is the stream number containing the audio in my case (may vary, mp4box can also list the contained streams).
Later on I found that the GUI tool "MP4tag", that is primarily meant to edit tags, has a menu function called "MP4 optimize" that is said to be able to fix the same problem.
mp4box should also be able to fix vid+audio combinations, by retrieving more than one stream from the input file.

Resources