Conversation
| def main(): | ||
| game = Game(parse().__dict__) | ||
| game.clone_repository() | ||
| game.catkin_build() |
There was a problem hiding this comment.
catkin_buildしたときに同じ名前のpackageがあるとエラーが発生する
raise RuntimeError('\n'.join(duplicates))
RuntimeError: Multiple packages found with the same name "burger_navigation":
- EndoNrak-burger_war_dev/burger_navigation
- burger_war_dev/burger_navigation
Multiple packages found with the same name "burger_war_dev":
- EndoNrak-burger_war_dev/burger_war_dev
- burger_war_dev/burger_war_dev
パッケージ名にもprefixをつける必要がありそう
There was a problem hiding this comment.
各パッケージフォルダのpackge.xml内で決まってるっぽい
| </include> | ||
| <!--blue side bot--> | ||
| <arg name="blue_bot_launch" default="$(find burger_war)/launch/sim_level_1_cheese.launch" /> | ||
| <group ns="enemy_bot"> |
There was a problem hiding this comment.
name_spaceをenemy_botにすることでtopicを名前空間分けできる
There was a problem hiding this comment.
name_spaceをenemy_botにすることでtopicを名前空間分けできる
cheeseとかteriyakiには<arg name=“namespace” >があるので良いが、your_burger.launchにはないので、エラーの原因になる
your_burger.launchを調べて、なければ追加する必要がありそう
|
|
||
| <!--red side bot--> | ||
| <arg name="red_bot_launch" default="$(find burger_war)/launch/sim_level_1_cheese.launch" /> | ||
| <include file="$(arg red_bot_launch)"> |
There was a problem hiding this comment.
red_bot_launchにlaunchファイルへのパスを指定することで任意のlaunchファイルを設定できるようにした
|
package名に"-"が入るのはillegalらしい。。。 |
|
https://wiki.ros.org/Names underscoresは"burger_war_dev"とかでも使ってるので避けたい! |
|
| for c in cmakelists: | ||
| pkg_name_mg.rename_pkg_name_in_cmakelists(c) | ||
| for y in launchs: | ||
| pkg_name_mg.rename_pkg_name_in_launch(y) |
There was a problem hiding this comment.
.launchファイルの中身の$(find {package})を$(find {user}___{package})に書き換えている
| def start(self): | ||
| move_to_catkin_ws() | ||
| os.chdir("src/burger_war_dev/commands") | ||
| cmd = "roslaunch game-start.launch red_bot_launch:={} blue_bot_launch:={}".format(self.red_launch, self.blue_launch) |
There was a problem hiding this comment.
set_launch_filesで指定した.launchファイルの絶対パスをblue_bot_launchおよびred_bot_launchに渡している
| Otherwise, gets the burger_war_dev code from github like 'git clone https://gihub.com/EndoNrak/burger_war_dev.git' and launch it") | ||
| parser.add_argument("-red", type=str) | ||
| parser.add_argument("-blue", type=str, default="cheese") | ||
| args = parser.parse_args() |
There was a problem hiding this comment.
このpythonファイルが実行される際に付与される-redと-blueオプションを解析している
| # "burger_war_dev" -> "" | ||
| def get_user_from_user_pkg(self, user_pkg): | ||
| result = [""] + user_pkg.split("___") | ||
| result = result[-2] |
There was a problem hiding this comment.
変数user_pkgが'burger_war_dev'などの
___prefixを持たない場合にはresultは["", ""] 、
___prefixを持つ場合には["", user, pkg]になる。
このやり方微妙すぎる
userにたまたま___が含まれている場合にはバグの原因になる
| user = result if result not in ["burger_war_dev", "burger_war_kit"] else "" | ||
| return user | ||
|
|
||
| def rename_pkg_name_in_file(self, path, pattern): |
There was a problem hiding this comment.
ファイルの中身を書き換える関数の抽象化されたversion
.tempファイルに書き込んでいき、最後にremove, renameして入れ替えている
| self.rename_pkg_name_in_file(path, pattern) | ||
|
|
||
| def rename_pkg_name_in_launch(self, path): | ||
| pattern = r'\(find (.+)\)' |
There was a problem hiding this comment.
(find {package})にマッチングするようにしている
| match_str = match.group(1) | ||
| __pkg_name = [""] + match_str.split("___") | ||
| pkg_name = __pkg_name[-1] | ||
| line = line.replace(match_str, self.get_user_pkg(user, pkg_name), 1) |
There was a problem hiding this comment.
(find package)/launch/package.launch" のような場合に、二個目のpackageまで書き換えないように
第三引数に1を指定している
|
|
||
| def get_launchs(): | ||
| move_to_catkin_ws() | ||
| launch_files = glob.glob('src/*/*/launch/*.launch') |
There was a problem hiding this comment.
launchファイルは全て検索している。
python2系では**を使った再帰的な検索ができないので、このマッチングにマッチしない場所にある.launchファイルは見逃すことになる
| <?xml version="1.0"?> | ||
| <launch> | ||
| <arg name="side" default="r"/> <!-- "b" = blue side, "r" = red side --> | ||
| <arg name="name_space" default=""/> |
There was a problem hiding this comment.
game_start.launchでname_spaceをenemy_botにしたいときがあるので追加した
|
@ikemuuu |
ちなみに |
これ,実行までの手順教えてくれん?? |
|
発見済みの残課題
|
#72