Teaching Assistant: Roi Yehoshua

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Teaching Assistant: Roi Yehoshua
Installing and Using Software from the Player Project Robert N. Lass Drexel University April 1 st, 2010 (no joke) (some slides adapted from Cannon & Winners)
Teaching Assistant: Roi Yehoshua
Robotics Simulator Intelligent Systems Lab. What is it ? Software framework - Simulating Robotics Algorithms.
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Using the Hokuyo Sensor with ROS on the Raspberry Pi
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Robot Operating System Tutorial ROS Basic
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Multi-Robot Systems with ROS Lesson 1
What is ROS? Robot Operating System
Teaching Assistant: Roi Yehoshua
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Purpose  This training course describes how to configure the the C/C++ compiler options.
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Teaching Assistant: Roi Yehoshua
Java: Chapter 1 Computer Systems Computer Programming II.
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
Teaching Assistant: Roi Yehoshua
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Introduction to Webots Outlines Introduction Introduction World Description World Description Controller Programming Controller Programming.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Teaching Assistant: Roi Yehoshua
Ling Chen ( From Shanghai University 1.
Teaching Assistant: Roi Yehoshua
Java development environment and Review of Java. Eclipse TM Intergrated Development Environment (IDE) Running Eclipse: Warning: Never check the “Use this.
Chapter 4 Introduction to Classes, Objects, Methods and strings
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
Teaching Assistant: Roi Yehoshua
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Teaching Assistant: Roi Yehoshua
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
Teaching Assistant: Roi Yehoshua
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Lecturer: Roi Yehoshua
Lecturer: Roi Yehoshua
C++ Lesson 1.
Lecturer: Roi Yehoshua
Lecturer: Roi Yehoshua
Lecturer: Roi Yehoshua
Lecturer: Roi Yehoshua
Lecturer: Roi Yehoshua
ROSLab: a High Level Programming Language for Robotic Applications
What is ROS? ROS is an open-source robot operating system
Multi-Robot Systems with ROS Lesson 10
ROSLab: A High-level Programming Environment for Robotic Co-design
The Finch Robot and the While Loop
Multi-Robot Systems with ROS Lesson 2
5 Variables, Data Types.
- The Robot Operating System
Robotics and Perception
Introduction to Classes and Objects
Robotic Perception and Action
Robotic Perception and Action
LEGO Mindstorms Robot and Java
Robot Operating System (ROS): An Introduction
Presentation transcript:

Teaching Assistant: Roi Yehoshua

Stage simulator Reading laser sensor data Writing a simple walker Your first assignment 2(C)2013 Roi Yehoshua

A 2D simulator that provides a virtual world populated by mobile robots, along with various objects for the robots to sense and manipulate 3(C)2013 Roi Yehoshua

Stage is already installed with ROS Indigo Stage ships with some example world files, including one that puts an Erratic-like robot in a Willow Garage-like environment To run it with an existing world file Browsing the stage window should show up 2 little squares: a red square which is a red box and a blue square which is the erratic robot 4 rosrun stage_ros stageros `rospack find stage_ros`/world/willow-erratic.world (C)2013 Roi Yehoshua

Click on the stage window and press R to see the perspective view. 5(C)2013 Roi Yehoshua

The world file is a description of the world that Stage must simulate. It describes robots, sensors, actuators, moveable and immovable objects. Sample world files can be found at the /world subdirectory in ros_stage package (C)2014 Roi Yehoshua

The basic syntactic features of the world file format: comments, entities and properties The define statement can be used to define new types of entities. – define myrobot position (player() laser() ) Entities have properties, indicated using name value pairs – myrobot (name "robot1" port 6665 pose [1 1 0]) This entry creates a position device named "robot1" attached to port 6665, with initial position (1, 1) and orientation of 0 (C)2014 Roi Yehoshua

define block model ( size [ ] gui_nose 0 ) define topurg ranger ( sensor( range_max 30.0 fov samples 1081 ) # generic model properties color "black" size [ ] ) define pr2 position ( size [ ] origin [ ] gui_nose 1 drive "omni" topurg(pose [ ]) ) define block model ( size [ ] gui_nose 0 ) define topurg ranger ( sensor( range_max 30.0 fov samples 1081 ) # generic model properties color "black" size [ ] ) define pr2 position ( size [ ] origin [ ] gui_nose 1 drive "omni" topurg(pose [ ]) )

(C)2014 Roi Yehoshua define floorplan model ( # sombre, sensible, artistic color "gray30" # most maps will need a bounding box boundary 1 gui_nose 0 gui_grid 0 gui_outline 0 gripper_return 0 fiducial_return 0 ranger_return 1 ) # set the resolution of the underlying raytrace model in meters resolution 0.02 interval_sim 100 # simulation timestep in milliseconds window ( size [ ] rotate [ ] scale ) define floorplan model ( # sombre, sensible, artistic color "gray30" # most maps will need a bounding box boundary 1 gui_nose 0 gui_grid 0 gui_outline 0 gripper_return 0 fiducial_return 0 ranger_return 1 ) # set the resolution of the underlying raytrace model in meters resolution 0.02 interval_sim 100 # simulation timestep in milliseconds window ( size [ ] rotate [ ] scale )

(C)2014 Roi Yehoshua # load an environment bitmap floorplan ( name "willow" bitmap "../maps/willow-full-0.05.pgm" size [ ] pose [ ] ) # throw in a robot pr2( pose [ ] name "pr2" color "blue") block( pose [ ] color "red") block( pose [ ] color "red“) # load an environment bitmap floorplan ( name "willow" bitmap "../maps/willow-full-0.05.pgm" size [ ] pose [ ] ) # throw in a robot pr2( pose [ ] name "pr2" color "blue") block( pose [ ] color "red") block( pose [ ] color "red“)

You have a simulated robot - let's make it move An easy way to do this is keyboard-based teleoperation For keyboard teleoperation, you need to get a package called teleop_twist_keyboard which is part of the brown_remotelab stack – (C)2013 Roi Yehoshua

Create a directory for downloaded packages – For example, ~/ros/stacks Edit ROS_PACKAGE_PATH in your.bashrc to include your own ros stacks directory Check the package out from the SVN: Compile the package 12 export ROS_PACKAGE_PATH=~/ros/stacks:${ROS_PACKAGE_PATH} $ cd ~/ros/stacks $ svn co $ cd ~/ros/stacks $ svn co $ rosmake brown_remotelab (C)2013 Roi Yehoshua

Now run teleop_twist_keyboard: You should see console output that gives you the key-to-control mapping, something like this: – Hold down any of those keys to drive the robot. E.g., to drive forward, hold down the i key. 13 $ rosrun teleop_twist_keyboard teleop_twist_keyboard.py (C)2013 Roi Yehoshua

14(C)2013 Roi Yehoshua

The stage simulator publishes several topics See what topics are available using rostopic list You can use rostopic echo -n 1 to look at an instance of the data on one of the topics 15(C)2013 Roi Yehoshua

16(C)2013 Roi Yehoshua

We will create a node called stopper that will make the robot move forward until it detects an obstacle in front of it We will use the laser sensor data to achieve this Create a new package called my_stage 17(C)2013 Roi Yehoshua $ cd ~/catkin_ws/src $ catkin_create_pkg my_stage std_msgs rospy roscpp $ cd ~/catkin_ws/src $ catkin_create_pkg my_stage std_msgs rospy roscpp

(C)2014 Roi Yehoshua18

A common laser sensor used in robotics (C)2014 Roi Yehoshua19

(C)2014 Roi Yehoshua20

In Stage Click D (or choose View > Data) to see the laser data on the map 21(C)2013 Roi Yehoshua

Laser data is published to the topic /base_scan The message type that used to send information of the laser is sensor_msgs/LaserScan You can see the structure of the message using Note that Stage produces perfect laser scans – Real robots and real lasers exhibit noise that Stage isn't simulating 22 $rosmsg show sensor_msgs/LaserScan (C)2013 Roi Yehoshua

23(C)2013 Roi Yehoshua

Example of a laser scan message from Stage simulator: 24(C)2013 Roi Yehoshua

In Eclipse under the package’s src directory add a new class named Stopper – This will create Stopper.h and Stopper.cpp Add a source file run_stopper.cpp – This will contain the main function 25(C)2013 Roi Yehoshua

26 #include "ros/ros.h" #include "sensor_msgs/LaserScan.h" class Stopper { public: // Tunable parameters const static double FORWARD_SPEED_MPS = 0.5; const static double MIN_SCAN_ANGLE_RAD = -30.0/180*M_PI; const static double MAX_SCAN_ANGLE_RAD = +30.0/180*M_PI; const static float MIN_PROXIMITY_RANGE_M = 0.5; // Should be smaller than sensor_msgs::LaserScan::range_max Stopper(); void startMoving(); private: ros::NodeHandle node; ros::Publisher commandPub; // Publisher to the robot's velocity command topic ros::Subscriber laserSub; // Subscriber to the robot's laser scan topic bool keepMoving; // Indicates whether the robot should continue moving void moveForward(); void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan); }; #include "ros/ros.h" #include "sensor_msgs/LaserScan.h" class Stopper { public: // Tunable parameters const static double FORWARD_SPEED_MPS = 0.5; const static double MIN_SCAN_ANGLE_RAD = -30.0/180*M_PI; const static double MAX_SCAN_ANGLE_RAD = +30.0/180*M_PI; const static float MIN_PROXIMITY_RANGE_M = 0.5; // Should be smaller than sensor_msgs::LaserScan::range_max Stopper(); void startMoving(); private: ros::NodeHandle node; ros::Publisher commandPub; // Publisher to the robot's velocity command topic ros::Subscriber laserSub; // Subscriber to the robot's laser scan topic bool keepMoving; // Indicates whether the robot should continue moving void moveForward(); void scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan); }; (C)2013 Roi Yehoshua

27 #include "Stopper.h" #include "geometry_msgs/Twist.h" Stopper::Stopper() { keepMoving = true; // Advertise a new publisher for the simulated robot's velocity command topic commandPub = node.advertise ("cmd_vel", 10); // Subscribe to the simulated robot's laser scan topic laserSub = node.subscribe("base_scan", 1, &Stopper::scanCallback, this); } // Send a velocity command void Stopper::moveForward() { geometry_msgs::Twist msg; // The default constructor will set all commands to 0 msg.linear.x = FORWARD_SPEED_MPS; commandPub.publish(msg); }; #include "Stopper.h" #include "geometry_msgs/Twist.h" Stopper::Stopper() { keepMoving = true; // Advertise a new publisher for the simulated robot's velocity command topic commandPub = node.advertise ("cmd_vel", 10); // Subscribe to the simulated robot's laser scan topic laserSub = node.subscribe("base_scan", 1, &Stopper::scanCallback, this); } // Send a velocity command void Stopper::moveForward() { geometry_msgs::Twist msg; // The default constructor will set all commands to 0 msg.linear.x = FORWARD_SPEED_MPS; commandPub.publish(msg); }; (C)2013 Roi Yehoshua

28 // Process the incoming laser scan message void Stopper::scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan) { // Find the closest range between the defined minimum and maximum angles int minIndex = ceil((MIN_SCAN_ANGLE_RAD - scan->angle_min) / scan- >angle_increment); int maxIndex = floor((MAX_SCAN_ANGLE_RAD - scan->angle_min) / scan- >angle_increment); float closestRange = scan->ranges[minIndex]; for (int currIndex = minIndex + 1; currIndex <= maxIndex; currIndex++) { if (scan->ranges[currIndex] < closestRange) { closestRange = scan->ranges[currIndex]; } ROS_INFO_STREAM("Closest range: " << closestRange); if (closestRange < MIN_PROXIMITY_RANGE_M) { ROS_INFO("Stop!"); keepMoving = false; } // Process the incoming laser scan message void Stopper::scanCallback(const sensor_msgs::LaserScan::ConstPtr& scan) { // Find the closest range between the defined minimum and maximum angles int minIndex = ceil((MIN_SCAN_ANGLE_RAD - scan->angle_min) / scan- >angle_increment); int maxIndex = floor((MAX_SCAN_ANGLE_RAD - scan->angle_min) / scan- >angle_increment); float closestRange = scan->ranges[minIndex]; for (int currIndex = minIndex + 1; currIndex <= maxIndex; currIndex++) { if (scan->ranges[currIndex] < closestRange) { closestRange = scan->ranges[currIndex]; } ROS_INFO_STREAM("Closest range: " << closestRange); if (closestRange < MIN_PROXIMITY_RANGE_M) { ROS_INFO("Stop!"); keepMoving = false; } (C)2013 Roi Yehoshua

29 void Stopper::startMoving() { ros::Rate rate(10); ROS_INFO("Start moving"); // Keep spinning loop until user presses Ctrl+C or the robot got too close to an obstacle while (ros::ok() && keepMoving) { moveForward(); ros::spinOnce(); // Need to call this function often to allow ROS to process incoming messages rate.sleep(); } void Stopper::startMoving() { ros::Rate rate(10); ROS_INFO("Start moving"); // Keep spinning loop until user presses Ctrl+C or the robot got too close to an obstacle while (ros::ok() && keepMoving) { moveForward(); ros::spinOnce(); // Need to call this function often to allow ROS to process incoming messages rate.sleep(); } (C)2013 Roi Yehoshua

30 #include "Stopper.h" int main(int argc, char **argv) { // Initiate new ROS node named "stopper" ros::init(argc, argv, "stopper"); // Create new stopper object Stopper stopper; // Start the movement stopper.startMoving(); return 0; }; #include "Stopper.h" int main(int argc, char **argv) { // Initiate new ROS node named "stopper" ros::init(argc, argv, "stopper"); // Create new stopper object Stopper stopper; // Start the movement stopper.startMoving(); return 0; }; (C)2013 Roi Yehoshua

Edit the following lines in CMakeLists.txt: 31(C)2013 Roi Yehoshua cmake_minimum_required(VERSION 2.8.3) project(my_stage) … ## Declare a cpp executable add_executable(stopper src/Stopper.cpp src/run_stopper.cpp) ## Specify libraries to link a library or executable target against target_link_libraries(stopper ${catkin_LIBRARIES}) cmake_minimum_required(VERSION 2.8.3) project(my_stage) … ## Declare a cpp executable add_executable(stopper src/Stopper.cpp src/run_stopper.cpp) ## Specify libraries to link a library or executable target against target_link_libraries(stopper ${catkin_LIBRARIES})

32(C)2013 Roi Yehoshua

33 Launch file for launching both the Stage simulator and the stopper node: To run the launch file use: $ roslaunch my_stage my_stage.launch (C)2013 Roi Yehoshua

34(C)2013 Roi Yehoshua

In your first assignment you will implement a simple walker algorithm much like a Roomba robot vaccum cleaner Read assignment details at (C)2013 Roi Yehoshua