Debian Installation

Installation

(Tested on Stretch)

install_ros.sh

 #!/usr/bin/env bash


DISTRO=vivid  ## the basic tools from ROS's Ubuntu Vivid Distribution
              ## also work with Debian Stretch


## http://wiki.ros.org/jade/Installation/Ubuntu#Installation.2BAC8-Ubuntu.2BAC8-Sources.Setup_your_sources.list

sudo -E apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu $DISTRO main\" > /etc/apt/sources.list.d/ros-latest.list"

sudo apt-get update
sudo apt-get install cmake python-nose libgtest-dev ## needed to work on Beaglebone Black

## http://wiki.ros.org/jade/Installation/Source
sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential

sudo -E rosdep init
rosdep update

mkdir ~/ros_catkin_ws
cd    ~/ros_catkin_ws

rosinstall_generator ros_comm --rosdistro jade --deps --wet-only --tar > jade-ros_comm-wet.rosinstall
wstool init -j8 src jade-ros_comm-wet.rosinstall

sudo apt-get install -y libboost-all-dev python-empy libconsole-bridge-dev libtinyxml-dev liblz4-dev libbz2-dev
./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release

sudo apt-get install python-netifaces

Workspace sample

To test your setup... the following script creates a workspace in ~/catkin_tmp and compiles and runs the example code from ROS/Tutorials/WritingPublisherSubscriber(c++)

create_workspace.sh

 #!/usr/bin/env bash

WORKSPACE_PATH=~/catkin_tmp

## Source
. ~/ros_catkin_ws/install_isolated/setup.bash


## Create catkin workspace
mkdir -p $WORKSPACE_PATH/src
cd       $WORKSPACE_PATH/src
catkin_init_workspace

cd       $WORKSPACE_PATH/
catkin_make

.        $WORKSPACE_PATH/devel/setup.bash





cd       $WORKSPACE_PATH/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp

cd       $WORKSPACE_PATH/
catkin_make

.        $WORKSPACE_PATH/devel/setup.bash





# escaping:
# note in the HEREDOC below, \\ means \ in the output!!
#                            \$ means $ in the output!!
#                            \` means ` in the output!!
cat <<EOF    > $WORKSPACE_PATH/src/beginner_tutorials/CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)

## Declare ROS messages and services
#add_message_files(FILES Num.msg)
#add_service_files(FILES AddTwoInts.srv)

## Generate added messages and services
generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package()

## Build talker and listener
include_directories(include \${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
target_link_libraries(talker \${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener src/listener.cpp)
target_link_libraries(listener \${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)
EOF


cat <<EOF    > $WORKSPACE_PATH/src/beginner_tutorials/src/talker.cpp
#include "ros/ros.h"
#include "std_msgs/String.h"

#include <sstream>

int main(int argc, char **argv)
{
  ros::init(argc, argv, "talker");

  ros::NodeHandle n;

  ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);

  ros::Rate loop_rate(10);

  int count = 0;
  while (ros::ok())
    {
      std_msgs::String msg;

      std::stringstream ss;
      ss << "hello world " << count;
      msg.data = ss.str();

      ROS_INFO("%s", msg.data.c_str());

      chatter_pub.publish(msg);

      ros::spinOnce();

      loop_rate.sleep();
      ++count;
    }
  return 0;
}
EOF

cat <<EOF    > $WORKSPACE_PATH/src/beginner_tutorials/src/listener.cpp
#include "ros/ros.h"
#include "std_msgs/String.h"

void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
  ROS_INFO("I heard: [%s]", msg->data.c_str());
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "listener");

  ros::NodeHandle n;

  ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);

  ros::spin();

  return 0;
}
EOF







cd       $WORKSPACE_PATH
catkin_make

.        $WORKSPACE_PATH/devel/setup.bash


roscore &
PID_roscore=$!

sleep 2  ## wait for roscore to start

echo
echo " ####### "
echo "Hit enter to run talker and listener nodes from 2 seconds"
read

rosrun beginner_tutorials talker   &
PID_talker=$!

rosrun beginner_tutorials listener &
PID_listener=$!


sleep 2  ## run for a short while

kill $PID_listener
kill $PID_talker
kill $PID_roscore

Wiki: Debian/Installation/Source (last edited 2017-04-14 21:26:48 by DHood)