User Tools

Site Tools


tutorials:advanced:ros_tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tutorials:advanced:ros_tutorial [2016/06/17 08:57]
wingcloud created
tutorials:advanced:ros_tutorial [2021/04/01 13:52] (current)
Line 1: Line 1:
-FIXME **This page is not fully translated, yet. Please help completing the translation.**\\ //(remove this paragraph once the translation is finished)// 
- 
 <markdown> <markdown>
 ROS Tutorial ROS Tutorial
-================+===============================================================================
  
-##開発環境+## Build Environment
 - Ubuntu - Ubuntu
 - ROS indigo - ROS indigo
 - python 2.7 - python 2.7
  
-##ROSのインストール 
-公式の日本語のROSページである[こちら](http://wiki.ros.org/ja)を参考にROSの開発環境をUbuntuのパソコンに構築します。 
  
-##ワークスペースの作成 +## Install ROS 
-ROSを利用して開発を行うために、作業用ディレクトリを作成し、catkinコマンドで作業用ディレクトリを初期化します。+Please check [this page](http://wiki.ros.org/Documentation) and install ROS to your PC that is installed ubuntu. 
 + 
 +### Create a Workspace 
 +Please create a working directory to develop with ROS. 
 +After that, initialize the working directory environment as follows:
  
 ```bash ```bash
Line 20: Line 20:
 $ cd ~/catkin_ws/src $ cd ~/catkin_ws/src
 $ catkin_init_workspace $ catkin_init_workspace
-``` 
- 
-```bash 
 $ cd ~/catkin_ws $ cd ~/catkin_ws
 $ catkin_make $ catkin_make
 ``` ```
  
-ROSを利用できる環境にするためsetup.bashを読み込みます。+There is a setup script to initialize the environment. 
 +Please enter command below.
  
 ```bash ```bash
 $ source ~/catkin_ws/devel/setup.bash $ source ~/catkin_ws/devel/setup.bash
 ``` ```
-この作業は毎回必要となるため、「~/.bashrc」の以下の部分をエディタなどで+ 
 +This process needs at first time whenever use ROS. Thus, I recommend to add script to **.bashrc** file.
  
 ```bash ```bash
Line 38: Line 37:
 source ~/catkin_ws/devel/setup.bash source ~/catkin_ws/devel/setup.bash
 ``` ```
-を修正し、追加することでその作業を省略できます。 
  
-##パッケージの作成 +### Create a Package 
-ディレクトリを移動して、パッケージを作成します。+Please change directory and create a package.
  
 ```bash ```bash
Line 48: Line 46:
  
 ```bash ```bash
-$ catkin_create_pkg <自作のパッケージ名> rospy roscpp std_msgs+$ catkin_create_pkg <YOUR_PACKAGE_NAME> rospy roscpp std_msgs
 ``` ```
-ここでもう一度catkin_makeを行います。+ 
 +And then, run `catkin_make` again.
  
 ```bash ```bash
Line 57: Line 56:
 $ source ~/catkin_ws/devel/setup.bash $ source ~/catkin_ws/devel/setup.bash
 ``` ```
-これで自作のパッケージを利用することができます。 
-確認のため 
  
-```bash +Now, your package can be available. 
-catkin_ws$ roscd <自作のパッケージ名> +Please check it with following command:
-``` +
-をすると+
  
 ```bash ```bash
-catkin_ws/src/<自作のパッケージ名>$+catkin_ws$ roscd <YOUR_PACKAGE_NAME> 
 +catkin_ws/src/<YOUR_PACKAGE_NAME>$
 ``` ```
-と移動できれば成功です。 
  
-##PLEN2に接続する +If you can do it, creating a package is succeeded. 
-PLEN2はアクセスポイントになっています。PLEN2にはそれぞれ異なるアクセスポイントの名前と同じパスワードが設定されています。+ 
 + 
 +## Connect to PLEN2 
 +Since time of the shipment, PLEN2 has been access point mode (You could connect PLEN2 as WiFi). 
 +Also PLEN2 has been set different SSID and common password.
  
-```bash 
-ssid:PLEN2dev<MACアドレス> 
-password:plenproject 
 ``` ```
 +SSID: PLEN2dev<PLEN2_MAC_ADDRESS>
 +Password: plenproject
 +```
 +
  
-##ROSの環境変数の設定 +## Setting Up ROS Environment 
-PLEN2に接続できたらifconfigコマンドを利用してPCに割り振られたIPアドレスを調べ、以下の様にROSの環境変数の設定を行います。+After connect your PC to PLEN2, please check IP address of your PC with `ifconfig` command. 
 +Then, change ROS environment parameters as follows:
  
 ```bash ```bash
-export ROS_IP=<割り振られたIPアドレス+export ROS_IP=<PC_IP_ADDRESS
-export ROS_HOSTNAME=<割り振られたIPアドレス>+export ROS_HOSTNAME=<PC_IP_ADDRESS>
 export ROS_MASTER_URI=http://192.168.42.1:11311 export ROS_MASTER_URI=http://192.168.42.1:11311
 ``` ```
-この設定を行うことで異なるパソコン間でROSを利用することが可能となります。 
  
-##PLEN2の目を点滅させる +Now, your PC can communicate other ROS setuped devices.
-それでは簡単にPLEN2の目を点滅させてみます。言語はPythonを利用します。まずPythonのプログラムを保存するためにscriptsディレクトリを作成します。+
  
-```bash 
-$ mkdir scripts 
-$ cd scripts 
  
-``` +## Blink LED of PLEN2's Eyes 
-以下のプログラムをpythonファイルとして保存します。+Let you blink LED of PLEN2's eyes. 
 +Please create following sample program.
  
 ```python ```python
 #!/usr/bin/env python #!/usr/bin/env python
 +# -*- coding: utf-8 -*-
  
 import rospy import rospy
Line 106: Line 104:
  
 def talker(): def talker():
-    rospy.init_node('PCnode', anonymous=True) +    rospy.init_node('PCNode', anonymous=True)
-    pub = rospy.Publisher('PcToControl', String, queue_size=10) +
-    rate = rospy.Rate(1) +
-    hello_str = String() +
-    hello_str.data ="gpio,w,off" +
-    while not rospy.is_shutdown():+
  
-        if ("onin hello_str.data): +    p = rospy.Publisher('PcToControl', String, queue_size=10) 
-            hello_str.data = "gpio,w,off" +    r = rospy.Rate(1) 
-        elif ("offin hello_str.data): + 
-            hello_str.data = "gpio,w,on"+    led_command = String() 
 +    led_command.data = 'gpio,w,off' 
 + 
 +    while ( not rospy.is_shutdown() ): 
 +        if ( 'onin led_command.data ): 
 +            led_command.data = 'gpio,w,off
 + 
 +        elif ( 'offin led_command.data ): 
 +            led_command.data = 'gpio,w,on
 + 
 +        rospy.loginfo('%s', led_command.data) 
 + 
 +        p.publish(led_command) 
 +        r.sleep()
  
-        rospy.loginfo("%s",hello_str.data) 
-        pub.publish(hello_str) 
-        rate.sleep() 
  
 if __name__ == '__main__': if __name__ == '__main__':
     try:     try:
         talker()         talker()
 +
     except rospy.ROSInterruptException:     except rospy.ROSInterruptException:
         pass         pass
- 
 ``` ```
-このプログラムはPLEN2の目を一秒ごとに点滅させるものです。「PcToControl」という名前で「Topic」に「Publish」するとPLEN2はそのTopicを読んでくれます。 + 
-最後に+This script blink PLEN2's eye at every seconds. 
 +PLEN2 subscribe topic which name is **PcToControl**. 
 + 
 +You need to run following command to be availabel the python script:
  
 ```bash ```bash
-$ chmod 755 <保存したpythonファイル+$ chmod 755 <CREATED_SCRIPT_NAME
-$ python <保存したpythonファイル>+$ python <CREATED_SCRIPT_NAME>
 ``` ```
-で実行することができます。 
  
-他にもPublishする内容を変更することでPLEN2を動かしたりすることが可能です。例えば、スロット4のモーションを再生したい場合は+In addition, You could control PLEN2 with command below. [See also...](http://plen.jp/playground/wiki/specifications/protocol)
  
 ``` ```
-serial,w,$PM04+serial,w,<ANY_PROTOCOL_OF_PLEN2>
 ``` ```
-としてPublishすることでPLEN2を動かすことができます。 
  
 +For example, if you would like to play the motion that is placed slot 4, send command below:
 +
 +```
 +serial,w,$pm04
 +```
 </markdown> </markdown>
tutorials/advanced/ros_tutorial.1466153872.txt.gz · Last modified: 2021/04/01 13:52 (external edit)