Skip to Content
ROS Programming: Building Powerful Robots
book

ROS Programming: Building Powerful Robots

by Anil Mahtani, Luis Sanchez, Enrique Fernandez, Aaron Martinez, Lentin Joseph
March 2018
Intermediate to advanced content levelIntermediate to advanced
1396 pages
42h 14m
English
Packt Publishing
Content preview from ROS Programming: Building Powerful Robots

Explaining the code

Initially, we have to include the JS module, which is mjpegcanvas.js, to get streamer functionality inside the browser. The following code does this job:

    <script src=" http://cdn.robotwebtools.org/   
    mjpegcanvasjs/current/mjpegcanvas.js"> 
    </script> 

The following is the function to start an MJPEG viewer inside the browser. You can set parameters such as width, height, and ROS image topic to display in the viewer.

       var viewer = new MJPEGCANVAS.Viewer({ 
          divID : 'mjpeg', 
          host : 'localhost', 
          width : 640, 
          height : 480, 
          topic : '/camera/rgb/image_raw', 
          interval : 200 
        }); 
       } 

To visualize multiple camera views, we can use code like this. Here, you can add any number of image topics. We also need to mention the image label. In the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Robots with ROS

Programming Robots with ROS

Morgan Quigley, Brian Gerkey, William D. Smart
Machine Learning Design Patterns

Machine Learning Design Patterns

Valliappa Lakshmanan, Sara Robinson, Michael Munn

Publisher Resources

ISBN: 9781788627436Supplemental Content