2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PC使ったRaspberry Pi開発手順

Last updated at Posted at 2019-07-26

なるべくGUIをRaspberry Piに入れたくない.
クロスコンパイルの環境構築もしたくない.
でも開発は,使い慣れたエディタでやりたい.

そしてどうせgitで管理している.

で,以下のような開発を行っているので,一応紹介.

cloud_pc_raspberrypi.png

前提

  • PC(Ubuntu Desktop)上のホームディレクトリに関する情報
    • サーバ名
      • home
    • ユーザ名
      • user1
    • プログラムのあるディレクトリ
      • /home/user1/ros2/test_program

準備

raspberry pi上

raspberry piにログインし以下を実行.

$ ssh-keygen

~/.ssh/id_rsa.pubをPCにコピー.ファイルコピーでもいいし,中身を表示(cat ~/.ssh/id_rsa.pub)し,文字列をコピーして貼り付けてもいい.

PC上

上記のraspberry pi上のid_rsa.pubの中身をPC上の~/.ssh/authorized_keysに追加.ファイルがなければ作成.

文字列をコピーした場合,エディタなどで最後に追加.ファイルをコピーした場合はid_rsa.pubのある場所で以下を実行.

$ cat id_rsa.pub >> ~/.ssh/authorized_keys

最初のclone

PC上でプログラム作成.それをraspberry pi上でclone.
以下はraspberry pi上で実行.

$ git clone ssh://user1@home/home/user1/ros2/test_program

構文は以下のとおり

git clone ssh://[ユーザ名]@[コンピュータ名][対象ディレクトリを絶対パスで指定]

運用

単純運用

PC上で編集

  1. PC上で作業
  2. PC上でgit commit -a -m "message"
  3. Raspberry pi上でgit pull
  4. Raspberry pi上でビルド・実行・テスト
  5. 問題なければPC上でgithub, gitlabにpush

Raspberry Pi上で編集

  1. Raspberry pi上で作業
  2. Raspberry pi上でgit commit -a -m "message"
  3. Raspberry pi上でビルド・実行・テスト
  4. 問題なければRaspberry pi上でgit push
  5. 一段落ついていたらPC上でgithub, gitlabにpush

branchの活用

PC上でbranchをきって開発する場合の手順.Raspberry pi上ではmain(必要に応じてbranchきっても良し).
例としてPC上のbranch名はdevelop-user1とする.

準備

  1. PC上でブランチ作成
    • git switch -c develop-user1

PC上で編集

  1. PCのdevelop-user1ブランチ上で作業
  2. PC上でgit commit -a -m "message"
  3. Raspberry pi上でgit pull origin develop-user1:main
  4. Raspberry pi上でビルド・実行・テスト
  5. 問題なければPC上でgithub, gitlabにpush
  6. 問題がある or 一段落ついていないならば1.に戻り作業.一段落ついてれば次の7.へ
  7. PC上のdevelop-user1をmainに反映
    • git merge main
      • コンフリクトがあれば修正
    • git switch main
    • git merge develop-user1
      • コンフリクトがあれば修正
  8. 一段落ついていたらPC上でgithub, gitlabにpush

欠点

commitしてraspberry pi上にてpullするので,commit間隔が短くなる.もしくはraspberry pi上でビルドするまでビルドに成功したか否かが分からないので,ビルド不成功のものもcommitしてしまう.

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?