From DSCL

ME530707 2017 EduMIP ROS

Jump to: navigation, search

The EduMIP Mobile Robot: Running the EduMIP as a ROS Node http://dscl.lcsr.jhu.edu/ME530707_2017_EduMIP_ROS

530.707 Robot Systems Programming

Course Homepage: http://dscl.lcsr.jhu.edu/ME530707_2017

Rosorg-logo.png


Introduction

This page has notes on installing and running the The Robot Operating System (ROS) on the EduMIP mobile robot. The EduMiP is a self-balancing robot built around the BeagleBone Black embedded microprocessor board and the Beaglebone Black Robotics Cape developed by James Strawson and Professor Thomas Bewley of the Coordinated Robotics Laboratory at UCSD and their collaborators. Professor Bewley uses this robot in his course ​ MAE144 - Embedded Control & Robotics at the UCSD Department of Mechanical and Aerospace Engineering.

Here is a link to some images of the EduMIP on the Strawson Design EduMIP Github repository: https://github.com/StrawsonDesign/EduMiP/blob/master/Pictures

Ingrediants

Here are the ingredients:

  • Beaglebone Black (BBB): The Beaglebone Black is a low-cost, community-supported development platform for developers and hobbyists with an 1GHz AM335x 1GHz ARM® Cortex CPU, 512MB DDR3 RAM, and 4GB 8-bit eMMC on-board flash storage.
  • Robotics Cape (BBB-RC): The Beaglebone Black Robotics Cape (also see the Strawson Design web page) is an I/O board for the Beaglebone Black that provides several sensors and rich hardware support including the following:
    • Sensors:
      • 9-Axis IMU
      • Barometer
    • I/O
      • 3 Quadrature encoder counting channels
      • 4 H-bridge motor controllers
      • 8 Servo/ESC outputs
      • Standard DSM RC radio interface
      • I2C UART SPI ADC PWM GPIO
  • EduMIP Kit: Kit comprises of the DC motors, gearboxes, encoders, wheels, plastic injection-molded plastic parts, wiring, and fasteners to turn the BBB and BBB-RC into a mobile robot.
  • Debian Jessie Linux for ARM: The BBB-RC C software library for the BBB is available for Debian Jessie release of Linux for ARM processors. Stable images are available here, and the most recent builds are available here.

Assembling and Testing the EduMIP Kit (part of 530.707 Assignment #3)

Assemble and Test Your EduMIP as follows. Use care. Be gentle.

  1. Assemble EduMIP: Follow the EduMIP assembly instructions available here: https://jh.box.com/v/530-707-Dropbox
  2. Some Additional Notes:
    • Additional documentation is available here https://github.com/StrawsonDesign/EduMiP
    • DON'T CROSS THE +5V and +9V STREAMS:The BBB has a barrel power connector for +5V. The robotics cape has an identical ballel power connector for +9V. Yikes!
      • Do not plug a +9V power supply directly into the +5V power connector on the BBB - the results will be a dead BBB.
      • The EduMIP kit contains plugs to block off the +5V power connector on the BBB - install one of them in the +5V BBB power connector to discourage you from over-volting the BBB.
    • UNPLUG when not in use: When you are not using the EduMIP or charging the battery:
      1. Unplug the 12V charge cable from the EduMIP
      2. Unplug the battery from the Robotics Cape before transporting the robot.
      3. Store the EduMIP in its robot house.
    • Avoid FOD (Foreign Object Damage):
      • Robots Like Their House:When transporting your EduMIP, put it in its EduMIP house (a.k.a. ziplock food container) to prevent damage to your MIP.
      • Do not put any loose items that conduct electricity into your EduMIP house. Items such as screwdrivers, loose screws, and loose wires can cause short circuits that will damage your EduMIP.
    • DON'T DAMAGE THE MOTOR and ENCODER CONNECTORS:The connectors on the robotics cape for the encoders and the motors are very tiny and fragile. You must use great care in mating the encoder and motor cables to these connectors. The encoder and motor wires in a recent kit were just barely long enough to connect the M1/E2 motor/encoder. See your TA for guidance in connecting the motor and encoder cables.
    • Loose Switches Sink Ships: Carefully check the physical integrity of the robotics cape power, reset, pause, and mode switches. If they are not soldered onto the board securely, see your TA for help in resoldering them.
    • Missing Screws: A recent kit was missing the two 4-40 (thread pitch) 3/8" (length) phillips-head screws for mounting wheels to motors - see your TA for extras if your are missing any parts.

Setting Up Your Beaglebone Black Wireless Board for Your EduMIP (part of 530.707 Assignment #3

Set up your BeagleBone Black Wireless Board for use in your EduMIP as follows. Note that burning the 32GB Linux image into the Micro-SD takes 1.5-2.5 hours.

  1. Test your BeagleBone Black Wireless Board: Before assembling the edumip, test your beaglebone black wireless - it comes with Debian Jessie installed on its on-board 4GB flash disk.
    • CAUTION: When testing the BBBW power it only via the USB cable. DO NOT plug the 9V AC adapter provided in the EduMIP Kit into the 5V power connector of the BBBW.
    1. Follow the instructions here: https://beagleboard.org/getting-started
    2. Once you install the appropriate drivers or udev rules on your host PC, it will establish an Ethernet connection to the BBB via the USB connection via virtual Ethernet adapter usb0. Your host PC will be at ip address 192.167.7.1, and the BBB will be at 192.168.7.2. SSH to from the host PC to the BBB with "ssh debian@192.168.7.2". The default password for root is "temppwd".
    3. Whenever you are done working with the BBBW and ready to power it off, don't just unplug it - run the command "sudo poweroff" to shut down Linux and power off the board. Once all the LEDs on the board are dark, then it is OK to unplug the USB cable.
  2. Install and Test a 32GB Debian Linux Image with ROS and support for the Robotics Cape on your BBBW: The 4GB flash disk built into the BBBW is too small to support a full ROS source installation, you we will run the BBBW from a 32GB Micro-SD card instead. We have created a 32GB Debian Jesse image that has ROS kinetic and support for the Robotics Cape pre-installed. Your EduMIP kit has a blank 32GB Micro-SD card.
    1. Doanload the Image: Download the compressed 32GB Debian Jesse image that has ROS kinetic and support for the Robotics Cape pre-installed - the compressed 32GB image is about 4GB. Get it here: https://jh.box.com/v/530-707-Dropbox You do not need to decompress this image.
    2. Download Etcher: Download and install Etcher on your computer from https://etcher.io --- Etcher is a program for burning disk images onto SD cards.
    3. Burn the 32GB disk image onto the provided micro-SD card. Etcher understands compressed disk images, you do not need to decompress the 32GB disk image.
    4. Burn, Baby, Burn!! Burn the Linux image onto the Micro-SD card with your PC or with a PC in the Wyman 140 Lab. Burning the full 32GB image typically takes 1.5 -2.5 hours depending on your PC and SD card adapter.
      • Many notebook computers have native SD and/or Micro-SD card slots. The micro-SD cards provided with your EduMIP comes with a Micro-SD-to-SD card adapter.
      • We have 5 USB-to-Micro-SD card burners available for you to use in Wyman 140. You can burn with your PC or with a lab PC.
      • The Thinkpad Yoga computers in Wyman 140 have native Micro-SD slots.
      • If you are unsure of how to burn the micro-SD image, come to TA office hours.
    5. GENTLY Install the Micro-SD Card:Install the Micro-SD card in the Micro-SD card slot of the BBBW. DO NOT FORCE IT, IT TAKES JUST A GENTLE TOUCH TO INSTALL.
    6. Boot your BBBW from the 32GB Micro-SD card image by plugging it into your PC with a USB cable.
      1. If the Micro-SD card contains a bootable image, then the BBBW will boot from it instead of from its on-bpard Flash disk.
      2. SSH into the BBBW ("ssh debian@192.168.7.2") and verify that you are in fact running the 32GB image. The command "df -h" should show 20GB of free space, and the command "htop" should show a 1GB swap file active.
  3. Test EduMIP: Test your EduMIP as follows:
    1. Test Encoders:Run "rc_test_encoders" and rotate the wheels a bit - you should see encoders E2 and E3 displaying changing encoder counts.
    2. Test Motors:Run "rc_test_motors -d 0.1" to --- when you pick up the EduMIP the two wheels should rotate in opposite directions.
    3. Calibrate Gyros:Place your EduMIP on the table, motionless, and run "rc_calibrate_gyro" and follow the instructions. This calibration program writes the gyro calibration file /var/lib/roboticscape/mag.cal
    4. Test Gyros: Run "rc_test_imu" and verify that the "Gyro XYZ (rad/s)" data is zero (or nearly zero).
    5. Calibrate Magnetometer: Run "rc_calibrate_mag" and follow the instructions - you will be asked to pick up the EduMIP in your hand and rotate ("spin") it into all orientations. This calibration program writes the magnetometer calibration file /var/lib/roboticscape/gyro.cal
    6. Test Magnetometers: Run "rc_test_imu" and verify that the "Mag Field XYZ(uT)" data is non-zero. The Earth's magnetic field vector magnitude in Baltimore is about 52uT, but for now don't worry if your magnetometer seems a bit off.
    7. Test Balancing the EduMIP: Test the reference balance program by logging in as root and running the command "rc_balance", and standing the robot up. Your robot should balance in place.
  4. Test ROS on the BBBW
    1. Check your .bashrc file. At the end if the file it should have the following commands in the following order:
      1. First, the command "source /opt/ros/kinetic/setup.bash" to setup ROS environment variables.
      2. Second, the command "source ~/catkin_ws/devel/setup.bash" to add your local catkin workspace to the ROS environment (this is called "worspace overlay).
    2. run the command "source .bashrc" to set up your ROS environment variables. Check them with the command "printenv | grep ROS".
    3. Verify that you can run "roscore" and other ROS utilities.
    4. Verify that you can run "catkin_make" in the BBBW ROS workspace.
    5. The image is provided
  5. Test ROS EduMIP Balance Program:
    1. First you must assemble and test the EduMIP as described in the Section entitled Assembling_and_Testing_the_EduMIP_Kit
    2. If you have not done so already, calibrate the EduMIP's gyro with the command "rc_calibrate_gyro" while the robot is sitting motionless on a table.
    3. Log in to your EduMIP as "root"
    4. Configure WiFi on your EduMIP: Configure your WiFi so that you can clone ROS packages from our git repository. Follow the instructions here ME530707_2017_EduMIP_ROS#WiFi_.28BBB_Wireless_and_BBB_Classic_.2B_USB_WiFi_Adapter
    5. Clone the following ROS packages into the src directory of your EduMIP's catkin workspace (should be /root/catkin_ws/src).
      • The edumip_msg package defines the custom message type edumip_msf/EduMipState for the EduMIP. This package contains no source code, just a message definition and associated CMakeLists.txt and package.xml. If your computer is to access this message type, you should clone the project to your PC as well. This package is architecture-independent. This package can be git cloned from this public URL: https://git.lcsr.jhu.edu/lwhitco1/edumip_msgs.git
      • The edumip_ros_balance package contains a C++ ROS node edumip_ros_node.cpp which is a ROS-ified version of the rc_balance program. This package will ONLY compile on under ARM Debian Jesse with the Robotics Cape drivers installed. The disck image we provided for you already has the Robotics Cape drivers and ROS installed. This package can be git cloned from this public URL: https://git.lcsr.jhu.edu/lwhitco1/edumip_balance_ros.git
    6. Build these two packages with the command catkin_make" in the top directory of your catkin workspace.
    7. Test to verify that ROS is now aware of the custom messages defines in the edumip_msgs package with the command: rosmsg show edumip_msgs/EduMipState.
    8. Open three remote ssh sessions on the EduMIP, all as root.
      1. First, in the first shell run "roscore" in one shell.
      2. Second, in the second shell run "rosrun edumip_balance_ros edumip_balance_ros"
      3. Third, in the third shell look at the ros topics and echo the topic /edumip/state.
      4. Stand up your robot, it should balance.
  6. POWERING OFF THE BBBW SAFELY: When you are done and ready to power down the BBBW, don't just unplug it - run the command "sudo poweroff" to shut down Linux and power off the board. Once all the LEDs on the board are dark, then it is OK to unplug the USB cable.

Some Useful Linux Notes for the BBB and BBBW

  1. The editors emacs and nano are already installed on the BBB linux image provided for this class.
  2. The linux "locate" utility is not installed by default, but you can install it with "sudo apt-get install locate", and initializing the locate database with the command "sudo updatedb" (takes a few minutes).
  3. The NTP time server is installed on the BBB linux image provided for this class, but it will only sync if the BBB has a route to the internet, for example when your WIFi link is on. The USB network connection to your PC does not route to the internet by default. You can check ntp status with the command "ntpq -p".

Notes on Setting up the BeagleBone Black (BBB) and Beaglebone Black Wireles (BBBW) with Debian and ROS

(These are here for reference only, and should not be required steps to completing assignment 3).

Connect from your host PC to the BBB via USB

  • Follow the instructions here: https://beagleboard.org/getting-started
  • Once you install the appropriate drivers or udev rules on your host PC, it will establish an Ethernet connection to the BBB via the USB connection via virtual Ethernet adapter usb0. Your host PC will be at ip address 192.167.7.1, and the BBB will be at 192.168.7.2. SSH to from the host PC to the BBB with "ssh debian@192.168.7.2". The default password for root is "temppwd".

Beaglebone Black vs Beaglebone Black Wireless

The EduMIP works with both.

  • Beaglebone Black (the original "Classic" Beaglebone): The Beaglebone (https://beagleboard.org/black) has an on-board USB-2 master port and an on-board Ethernet NIC, but no native WiFi support. It can use a USB WiFi adapter.
  • Beaglebone Black Wireless:The recently released Beaglebone Black Wireless (https://beagleboard.org/black-wireless) has an on-board USB-2 master port and an on-board WiFi adapter, but no native on-board Ethernet port.

Establish an Ethernet connection with DNS and a route to the outside world

Hard-wired Ethernet (BBB Classic)

Connect your BBB to an *open* router with DHCP/DNS services and edit /etc/network/interfaces as follows:

auto eth0

iface eth0 inet dhcp

Note that the BBB comes loaded with editors including "nano", "vi", and "vim".

WiFi (BBB Wireless and BBB Classic + USB WiFi Adapter

  • WiFi in a Jiffy: Follow the instructions for connmanctl listed in the comments of the file /etc/network/interfaces. Use the command cat /etc/network/interfaces to read the comments.
  • NOTE: The utility connmanctl does not support enterprise networks such as "hopkins", but it does support WPA/WPA2 networks such as the "turtlebot" WiFi network in the Wyman 14 lab, whose WiFi password will be given in class.
  • NOTE: Upon boot the BBBW WiFi adapter does not always come up properly. If you do not see "wlan0" in the ifconfig output, try manually enabling the BBBW wlan0 interfce with the command "ifconfig wlan0 up". Then you should be able to see wlab0 in the output of the "ifconfig" command.
  • ifconfig: Use the command "ifconfig" to see all configured network interfaces (Ethernet, WiFi, USB, etc) on your machine.
  • iwconfig: Use the command "iwconfig" to see all configured WiFi network interfaces on your machine.
  • Who am I? The easiest way to determine the IP address (or addresses) of a Linux machine is to log into it and use the command "ifconfig".
  • WiFi Groundhog Day! Unfortunately, at present the BBBW does not remember WiFi settings

Update your BBB Debian Distribution

On the BBB run the Linux commands "sudo apt update" and "sudo apt dist-upgrade"

FYI on a recently purchased BBB Wireless was loaded with the 4.4.30 kernel, "uname -a" returned "Linux beaglebone 4.4.30-ti-r64 #1 SMP Fri Nov 4 21:23:33 UTC 2016 armv7l GNU/Linux"

Installing the Robotics Cape Software on the BBB

  • Installation from Debian Repositories: On the BBB run the command "apt-get install roboticscape". When prompted for "Which program to run on boot?" Select "blink" or "nothing", you can change this later. It will tell you that it is enabling battery_monitor service and roboticscape service, then remind you to configure your robtoics cape software with the Linux commands
    • "sudo systemctl enable roboticscape"
    • "sudo /usr/bin/configure_robotics_dt.sh"
  • Installation from Source

You will want to install a copy of the robotics cape source and example code on your BBB. It is available here: https://github.com/StrawsonDesign/Robotics_Cape_Installer. To install a copy in your home directory:

Now you can browse the robotics cape source code and follow the instructions to compile and install the robotics cape library and example programs.

Notes on Installing ROS on the BBB

The ROS Kinetic repos for the ARM processor are not fully complete, so we will have to do a source installation for now.

  • Setup your repos and keys as per http://wiki.ros.org/kinetic/Installation/Debian
  • "sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'"
    • "sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116"
  • Install ROS Core from source following the instructions here: http://wiki.ros.org/kinetic/Installation/Source
    • Install build tools and initialize rosdep
      • "sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential"
      • "rosdep init"
      • "resdep update"
    • Make a place to build ROS and cd to it:
      • "mkdir -p ros_catkin_ws"
      • "cd ros_catkin_ws"
    • Install source code and initialize the build system with:
      • "rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall"
      • "wstool init -j8 src kinetic-ros_comm-wet.rosinstall"
    • Install all dependencies: "rosdep install --from-paths src --ignore-src --rosdistro kinetic -y"
    • Build and Install ROS core
    • Build with "./src/catkin/bin/catkin_make_isolated --install --install-space /opt/ros/kinetic -DCMAKE_BUILD_TYPE=Release." --- Note that "--install-space /opt/ros/kinetic" places the installed version in /opt/ros/kenetic. The build will take several hours.
    • Install ROS Core with "./src/catkin/bin/catkin_make_isolated --install"
    • Test ROS on the BBB
      • run the command "source /opt/ros/kinetic/setup.bash" and add it to the end of your ~/.bashrc
      • Check for ROS environment variables setup by /opt/ros/kinetic/setup.bash with the command "printenv | grep ROS"
      • Run a basic ros command such as "roscore". In another window try "rostopic list".
      • Note that this basic ROS core is bare-bones, it only contains standard messages as specified in "/opt/ros/kinetic/include/std_msgs/", it does not contain higher level messages such as geometry_msgs or sensor_msgs, and it does not contain high-level utilities such as RVIZ, Gazebo, rqt_graph, etc.
This page was last modified on 27 February 2017, at 18:26.