The ROS driver for your camera should have a parameter or a dynamic_reconfigure option to adjust the frame rate.
Without knowing which camera you're using or which ROS driver you're using, I can't provide more specific advice.
UPDATE
The usb_cam driver decodes the image and passes it directly to the image_transport publisher, so it isn't passing mjpeg images through directly.
The "quick and dirty" approach mentioned by the compressed_image_transport page is dirty because it only publishes compressed images, and doesn't provide the uncompressed images that most other ROS nodes expect.
If you really want compressed images directly from the camera you'll have to modify the source for the usb_cam driver or write a new camera driver. You'll probably want to stop using the image_transport library and implement image transport yourself, either:
- Do the "quick and dirty" solution, and publish directly to the compressed image topic
- Publish directly on the compressed topic, and decompress the image and publish a copy to the image_raw topic.
Originally posted by ahendrix with karma: 47576 on 2016-08-02
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by Rouno on 2016-08-02:
Thanks for the answer
I have no problem changing usb_cam/image_raw framerate. My issue is on the compressed topic of it (through image_transport plugin)
I would like to stream the 120fps mjpeg stream to a remote node but it seems that ros is re-encoding the usb camera output at a fixed framerate
Comment by ahendrix on 2016-08-02:
Yes; a quick read of the usb_cam source confirms that it is decoding the incoming data and sending it through the image_transport publisher, which does its own compression. I don't see any obvious places where the code might be limiting the frame rate. Perhaps it's just limited on CPU cycles?
Comment by Rouno on 2016-08-02:
I will have a look on my cpu performance indeed. But in any case, shouldn't we be able to send directly mjpeg from a camera on the network without re encoding overhead ?
There are few words about this in the last section of image compressed plugin wiki but I'm not dure it's the right way to do it
Comment by Rouno on 2016-08-03:
I have edited the topic title and content to be more specific