ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

roslibjs audio_common_msgs wrong array length

asked 2017-01-29 20:19:52 -0600

Swoncen gravatar image


I publish audio_common_msgs Audiodata from my ros module and subscribe to it via roslibjs

    var audio_topic = new ROSLIB.Topic({
    ros : ros,
    name : '/camera/audio',
    messageType : 'audio_common_msgs/AudioData'

It works but the length of the data is incorrect. I send predefined array sizes of 512 and check in my ros module if the length is really 512. However in my roslibjs webpage the data is of length 684. I dont know where the other array values come from. Can someone help me out?


edit retag flag offensive close merge delete


Can u share u'r code how u played the audio using roslibjs? i'm really stuck in it.

dinesh gravatar image dinesh  ( 2020-04-17 10:17:37 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-01-30 04:15:17 -0600

gvdhoorn gravatar image

Could it be that the binary data is encoded as base64? Similar to how images are encoded in roslibjs?

edit flag offensive delete link more


Excellent comment. This was so obvious but I didn't think of it. I try to enocde it in the evening and see if it's true. base64: 64 = 2^6, so 6 bits instead of 8: (512/6) *8 = 682,6. So it is not exactly 684, but very close and it could be filled up to 684 (next even number) or something like that.

Swoncen gravatar image Swoncen  ( 2017-01-30 04:38:55 -0600 )edit

It's correct with "atob()". Thanks!

Swoncen gravatar image Swoncen  ( 2017-01-30 17:31:44 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-01-29 20:19:52 -0600

Seen: 183 times

Last updated: Jan 30 '17