Ros Intro

  • Upload
    lakhi

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

  • 7/31/2019 Ros Intro

    1/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Intelligent Robotics: ROS

    Mark Rowan

    University of Birmingham

    Semester 1 2011

    Mark Rowan Intelligent Robotics: ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    2/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Outline

    1 Introduction to ROS

    2 Writing your own ROS node

    3 Working together

    4 Final words

    Mark Rowan Intelligent Robotics: ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    3/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Outline

    1 Introduction to ROS

    2 Writing your own ROS node

    3 Working together

    4 Final words

    Mark Rowan Intelligent Robotics: ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    4/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    What is ROS?

    Interface between low-level robot and high-level programming

    languages.

    Languages: C++, Python, Java.

    Robots: all sorts!

    Open-source community-driven platform, supported by Willow

    Garage and Google.

    Fast becoming the industry standard in robotics software.

    Mark Rowan Intelligent Robotics: ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    5/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    What is ROS?

    Interface between low-level robot and high-level programming

    languages.

    Languages: C++, Python, Java.

    Robots: all sorts!

    Open-source community-driven platform, supported by Willow

    Garage and Google.

    Fast becoming the industry standard in robotics software.

    Mark Rowan Intelligent Robotics: ROS

    I t d ti t ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    6/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    What kind of programs do we write?

    Laser scans

    Movement commands

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    7/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    ROS nodes

    Program components in ROS are modular, called Nodes.

    e.g. One node to control a laser,

    one node to control the wheels,

    one node to process laser data and decide what movements to

    make.

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    8/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Communication between nodes

    Nodes send data by talking and listening (or publishing and

    subscribing).Messages containing data are published on topics.

    Any node can subscribe to messages on any topic.

    Nodes need a method by which to find each other: roscore

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    9/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Communication between nodes

    Publisher topic Subscriber

    talker chatter (std_msgs/String) listener

    roscore

    rostopic pub /chatter std_msgs/String Hello World -r 10

    rostopic echo /chatter

    Keeps going even when we kill echo. . .Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    10/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Communication between nodes

    Publisher topic Subscriber

    talker chatter (std_msgs/String) listener

    roscore

    rostopic pub /chatter std_msgs/String Hello World -r 10

    rostopic echo /chatter

    Keeps going even when we kill echo. . .Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    11/32

    Introduction to ROS

    Writing your own ROS node

    Working together

    Final words

    Lots of nodes

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    12/32

    Writing your own ROS node

    Working together

    Final words

    Useful tools

    rostopic list list all currently published topics.rostopic echo listen to messages on a topic.

    Ctrl+C kill current program in terminal.

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    13/32

    Writing your own ROS node

    Working together

    Final words

    Outline

    1 Introduction to ROS

    2 Writing your own ROS node

    3 Working together

    4 Final words

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    14/32

    Writing your own ROS node

    Working together

    Final words

    Module webpage

    All this information is on the module webpage in the Notes section:http://www.cs.bham.ac.uk/internal/courses/

    int-robot/2011/

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    http://www.cs.bham.ac.uk/internal/courses/int-robot/2011/http://www.cs.bham.ac.uk/internal/courses/int-robot/2011/http://www.cs.bham.ac.uk/internal/courses/int-robot/2011/http://www.cs.bham.ac.uk/internal/courses/int-robot/2011/http://find/http://goback/
  • 7/31/2019 Ros Intro

    15/32

    Writing your own ROS node

    Working together

    Final words

    Writing a ROS Java node

    import org . ros .node.

    ;import org . ros . node. to pi c . Publ ishe r ;

    import org . ros . message . geometry_msgs . Twi st ;

    import org . ro s . message . sensor_msgs . LaserScan ;

    import org . ros . message . MessageLi stener ;

    p u b l i c c l as s Mover implements NodeMain {

    p r i v a t e Node node ;

    p r i v a t e P u b l i s h e r < T w i s t > pub ;

    p u b l i c v oi d main( NodeConfigurat ion nc) throws E x ce p t io n {

    node = new DefaultNodeFactory ( ) . newNode( "robot_mover" , nc ) ;

    pub = node. newPublis her ( " cmd_vel" , " geometry_msgs / Twi st " );

    node. newSubscriber ( " base_scan" , " sensor_msgs / LaserScan" , new MessageListener( ) {

    p u b l i c v oi d onNewMessage( LaserScan message ) {

    move( message ) ; / / C a l l method t o c ho os e movement d i r e c t i o n

    }} ) ;

    }

    p u b l i c v oi d shutdown ( ) {

    node. shutdown ( ) ;

    }

    }

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    W iti ROS d

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    16/32

    Writing your own ROS node

    Working together

    Final words

    Writing a ROS Java node

    import org . ros .node.

    ;import org . ros . node. to pi c . Publ ishe r ;

    import org . ros . message . geometry_msgs . Twi st ;

    import org . ro s . message . sensor_msgs . LaserScan ;

    import org . ros . message . MessageLi stener ;

    p u b l i c c l as s Mover implements NodeMain {

    p r i v a t e Node node ;

    p r i v a t e P u b l i s h e r < T w i s t > pub ;

    p u b l i c v oi d main( NodeConfigurat ion nc) throws E x ce p t io n {

    node = new DefaultNodeFactory ( ) . newNode( "robot_mover" , nc ) ;

    pub = node. newPublis her ( " cmd_vel" , " geometry_msgs / Twi st " );

    node. newSubscriber ( " base_scan" , " sensor_msgs / LaserScan" , new MessageListener( ) {

    p u b l i c v oi d onNewMessage( LaserScan message ) {

    move( message ) ; / / C a l l method t o c ho os e movement d i r e c t i o n

    }} ) ;

    }

    p u b l i c v oi d shutdown ( ) {

    node. shutdown ( ) ;

    }

    }

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    Writing o r o n ROS node

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    17/32

    Writing your own ROS node

    Working together

    Final words

    Writing a ROS Java node

    import org . ros .node.

    ;import org . ros . node. to pi c . Publ ishe r ;

    import org . ros . message . geometry_msgs . Twi st ;

    import org . ro s . message . sensor_msgs . LaserScan ;

    import org . ros . message . MessageLi stener ;

    p u b l i c c l as s Mover implements NodeMain {

    p r i v a t e Node node ;

    p r i v a t e P u b l i s h e r < T w i s t > pub ;

    p u b l i c v oi d main( NodeConfigurat ion nc) throws E x ce p t io n {

    node = new DefaultNodeFactory ( ) . newNode( "robot_mover" , nc ) ;

    pub = node. newPublis her ( " cmd_vel" , " geometry_msgs / Twi st " );

    node. newSubscriber ( " base_scan" , " sensor_msgs / LaserScan" , new MessageListener( ) {

    p u b l i c v oi d onNewMessage( LaserScan message ) {

    move( message ) ; / / C a l l method t o c ho os e movement d i r e c t i o n

    }} ) ;

    }

    p u b l i c v oi d shutdown ( ) {

    node. shutdown ( ) ;

    }

    }

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROS

    Writing your own ROS node

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    18/32

    Writing your own ROS node

    Working together

    Final words

    Writing a ROS Java node

    import org . ros .node.

    ;import org . ros . node. to pi c . Publ ishe r ;

    import org . ros . message . geometry_msgs . Twi st ;

    import org . ro s . message . sensor_msgs . LaserScan ;

    import org . ros . message . MessageLi stener ;

    p u b l i c c l as s Mover implements NodeMain {

    p r i v a t e Node node ;

    p r i v a t e P u b l i s h e r < T w i s t > pub ;

    p u b l i c v oi d main( NodeConfigurat ion nc) throws E x ce p t io n {

    node = new DefaultNodeFactory ( ) . newNode( "robot_mover" , nc ) ;

    pub = node. newPublis her ( " cmd_vel" , " geometry_msgs / Twi st " );

    node. newSubscriber ( " base_scan" , " sensor_msgs / LaserScan" , new MessageListener( ) {

    p u b l i c v oi d onNewMessage( LaserScan message ) {

    move( message ) ; / / C a l l method t o c ho os e movement d i r e c t i o n

    }} ) ;

    }

    p u b l i c v oi d shutdown ( ) {

    node. shutdown ( ) ;

    }

    }

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    19/32

    Writing your own ROS node

    Working together

    Final words

    Writing a ROS Java node

    import org . ros .node.

    ;import org . ros . node. to pi c . Publ ishe r ;

    import org . ros . message . geometry_msgs . Twi st ;

    import org . ro s . message . sensor_msgs . LaserScan ;

    import org . ros . message . MessageLi stener ;

    p u b l i c c l as s Mover implements NodeMain {

    p r i v a t e Node node ;

    p r i v a t e P u b l i s h e r < T w i s t > pub ;

    p u b l i c v oi d main( NodeConfigurat ion nc) throws E x ce p t io n {

    node = new DefaultNodeFactory ( ) . newNode( "robot_mover" , nc ) ;

    pub = node. newPublis her ( " cmd_vel" , " geometry_msgs / Twi st " );

    node. newSubscriber ( " base_scan" , " sensor_msgs / LaserScan" , new MessageListener( ) {

    p u b l i c v oi d onNewMessage( LaserScan message ) {

    move( message ) ; / / C a l l method t o c ho os e movement d i r e c t i o n

    }} ) ;

    }

    p u b l i c v oi d shutdown ( ) {

    node. shutdown ( ) ;

    }

    }

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    20/32

    Writing your own ROS node

    Working together

    Final words

    Compiling and running

    First time: rosmake robotics

    All other times: roscd robotics && ant compile

    Run: rosrun rosjava_bootstrap run.py robotics ex1.Node

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    21/32

    Writing your own ROS node

    Working together

    Final words

    Outline

    1 Introduction to ROS

    2 Writing your own ROS node

    3 Working together

    4 Final words

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    22/32

    g y

    Working together

    Final words

    Teams of 3, each team given a laptop with ROS installed.

    Share code using SVN.

    Register a repository at

    https://codex.cs.bham.ac.uk/svnadmin/

    Commit after every new feature or bug fix.

    Useful commit messages.

    Update before you commit!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    https://codex.cs.bham.ac.uk/svnadmin/https://codex.cs.bham.ac.uk/svnadmin/http://find/http://goback/
  • 7/31/2019 Ros Intro

    23/32

    Working together

    Final words

    Teams of 3, each team given a laptop with ROS installed.

    Share code using SVN.

    Register a repository at

    https://codex.cs.bham.ac.uk/svnadmin/

    Commit after every new feature or bug fix.

    Useful commit messages.

    Update before you commit!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    https://codex.cs.bham.ac.uk/svnadmin/https://codex.cs.bham.ac.uk/svnadmin/http://find/http://goback/
  • 7/31/2019 Ros Intro

    24/32

    Working together

    Final words

    Teams of 3, each team given a laptop with ROS installed.

    Share code using SVN.

    Register a repository at

    https://codex.cs.bham.ac.uk/svnadmin/

    Commit after every new feature or bug fix.

    Useful commit messages.

    Update before you commit!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    https://codex.cs.bham.ac.uk/svnadmin/https://codex.cs.bham.ac.uk/svnadmin/http://find/http://goback/
  • 7/31/2019 Ros Intro

    25/32

    Working together

    Final words

    Teams of 3, each team given a laptop with ROS installed.

    Share code using SVN.

    Register a repository at

    https://codex.cs.bham.ac.uk/svnadmin/

    Commit after every new feature or bug fix.

    Useful commit messages.

    Update before you commit!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    W ki t th

    https://codex.cs.bham.ac.uk/svnadmin/https://codex.cs.bham.ac.uk/svnadmin/http://find/http://goback/
  • 7/31/2019 Ros Intro

    26/32

    Working together

    Final words

    Teams of 3, each team given a laptop with ROS installed.

    Share code using SVN.

    Register a repository at

    https://codex.cs.bham.ac.uk/svnadmin/

    Commit after every new feature or bug fix.

    Useful commit messages.

    Update before you commit!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    Working together

    https://codex.cs.bham.ac.uk/svnadmin/https://codex.cs.bham.ac.uk/svnadmin/http://find/http://goback/
  • 7/31/2019 Ros Intro

    27/32

    Working together

    Final words

    Teams of 3, each team given a laptop with ROS installed.

    Share code using SVN.

    Register a repository at

    https://codex.cs.bham.ac.uk/svnadmin/

    Commit after every new feature or bug fix.

    Useful commit messages.

    Update before you commit!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    Working together

    https://codex.cs.bham.ac.uk/svnadmin/https://codex.cs.bham.ac.uk/svnadmin/http://find/http://goback/
  • 7/31/2019 Ros Intro

    28/32

    Working together

    Final words

    Outline

    1 Introduction to ROS

    2 Writing your own ROS node

    3 Working together

    4 Final words

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    Working together

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    29/32

    Working together

    Final words

    Experiment!

    Record your findings.

    Collaborate but give credit.

    Good luck!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    Working together

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    30/32

    Working together

    Final words

    Experiment!

    Record your findings.

    Collaborate but give credit.

    Good luck!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    Working together

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    31/32

    Working together

    Final words

    Experiment!

    Record your findings.

    Collaborate but give credit.

    Good luck!

    Mark Rowan Intelligent Robotics: ROS

    Introduction to ROSWriting your own ROS node

    Working together

    http://find/http://goback/
  • 7/31/2019 Ros Intro

    32/32

    g g

    Final words

    Experiment!

    Record your findings.

    Collaborate but give credit.

    Good luck!

    Mark Rowan Intelligent Robotics: ROS

    http://find/http://goback/