Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

各naviモードインスタンスの初期化処理をpuperun.__init__内で統一 #58

Merged
merged 6 commits into from
Jan 10, 2022

Conversation

EndoNrak
Copy link
Owner

@EndoNrak EndoNrak commented Jan 6, 2022

もとはselectModeCallBackのたびにnaviModeインスタンスを初期化してたけど、
最初に一回だけでいいことに気が付いた
各naviModeの初期化もpuperunのself.__init__内で呼べばいいのかも

@EndoNrak EndoNrak marked this pull request as draft January 6, 2022 13:46
@EndoNrak
Copy link
Owner Author

Waypointの初期化にサイドの判定が必要

やること

  1. 初期化の実行時に自機のサイドを判定する
  2. サイドによってpoints_depending_on_scoreを変換(https://github.com/EndoNrak/burger_war_dev/pull/57#discussion_r779184103)

@EndoNrak
Copy link
Owner Author

1.初期化の実行時に自機のサイドを判定する

terminalからなら
rosparam get /send_id_to_judge/sideで取得可能
rospyからは
rospy.get_param('send_id_to_judge/side')

Copy link
Owner Author

@EndoNrak EndoNrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

サイド判定のリファクタリングやった

if self.warState.my_side == 'b':
for i, point in enumerate(self.points_depending_on_score):
self.side = rospy.get_param('/send_id_to_judge/side')
self.change_points_depending_on_score_with_side(self.side)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sideの判定はwarstateのコールバックではなくて、初期化時にrospy.get_paramで取得することにした

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'/send_id_to_judge/side'setup_sim.shの中で定義されていて、対戦開始時には確実にrosparamに設定されていると考えられるため、初期化時に一回rospy.get_paramをすれば取得できると判断した。


def warStateCallBack(self, data):
self.warState = data
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warStateCallBack自体はほかのメソッドでself.warStateの更新を期待しているので残す必要がある

#initialize navis
self.navi_basic = NaviBasic()
self.navi_attack = NaviAttack2()
self.navi = self.navi_basic
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

各naviモードの初期化は最初に行う

def change_points_depending_on_score_with_side(self, side):
if side not in ['r', 'b']:
raise ValueError("'side' param must be in ['r', 'b'], given: {}\n\
please confirm with 'rosparam get /send_id_to_judge/side'".format(side))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

将来的にサイドの設定を積極的に変更するときに、
'b'のつもりが'B'とかにして、意図したとおりに設定できていないという事態を認知できるようにValueErrorを作った

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.side=Noneにするとちゃんとエラーを吐いた

Traceback (most recent call last):
  File "/home/developer/catkin_ws/src/burger_war_dev/burger_war_dev/scripts/pupeRun.py", line 83, in <module>
    bot = PupeBot('Puperun')
  File "/home/developer/catkin_ws/src/burger_war_dev/burger_war_dev/scripts/pupeRun.py", line 27, in __init__
    self.navi_basic = NaviBasic()
  File "/home/developer/catkin_ws/src/burger_war_dev/burger_war_dev/scripts/navi/naviBasic.py", line 39, in __init__
    self.waypoints = Waypoint(self.path_waypoints, self.path_waypoints_depending_on_score)
  File "/home/developer/catkin_ws/src/burger_war_dev/burger_war_dev/scripts/navi/waypoint.py", line 41, in __init__
    self.change_points_depending_on_score_with_side(None)
  File "/home/developer/catkin_ws/src/burger_war_dev/burger_war_dev/scripts/navi/waypoint.py", line 47, in change_points_depending_on_score_with_side
    please confirm with 'rosparam get /send_id_to_judge/side'".format(side))
ValueError: 'side' param must be in ['r', 'b'], given: None
            please confirm with 'rosparam get /send_id_to_judge/side'
[pupeRun-1] process has died [pid 28700, exit code 1, cmd /home/developer/catkin_ws/src/burger_war_dev/burger_war_dev/scripts/pupeRun.py __name:=pupeRun __log:=/home/developer/.ros/log/cb3cb072-71d4-11ec-b1c1-be596e283c47/pupeRun-1.log].
log file: /home/developer/.ros/log/cb3cb072-71d4-11ec-b1c1-be596e283c47/pupeRun-1*.log

@EndoNrak
Copy link
Owner Author

一応確認しておきたい事項

naviモードインスタンスの初期化タイミングが変わったので、モードが切り替わった時に正常に動作しているかを確認しておきたい
特にattack→basicの時にどうなる

@EndoNrak
Copy link
Owner Author

一応確認しておきたい事項

naviモードインスタンスの初期化タイミングが変わったので、モードが切り替わった時に正常に動作しているかを確認しておきたい 特にattack→basicの時にちゃんとnavigationに復帰するかが気になる

@mashioka
俺の環境、real time factorが0.1下回って10 minくらいかかるから、検証してくれん????

please confirm with 'rosparam get /send_id_to_judge/side'".format(side))
if side == "b":
# blue side の場合は,180度ひっくり返す
for i, _ in enumerate(self.points_depending_on_score):
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enumerateの第二返り値は今回ひつようないので_にしてメモリを節約

Copy link
Collaborator

@ikemuuu ikemuuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print 復活させてくれたら,あとは大丈夫やと思う.
あえて,次サイドrやのに,ひっくり返す処理入れたら,奪い返しに行くマーカを180度反転してたので,bサイドのときの処理も問題ないはず.

Comment on lines -43 to -46
def warStateCallBack(self, data):
self.warState = data
print('get data!')
print(self.warState.enem_get_wall_marker_no)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

イケムラデバック用に,ここのprint残しといてくれん??笑

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printするのってself.warState.enem_get_wall_marker_noだけでいい?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それで大丈夫!

@EndoNrak EndoNrak marked this pull request as ready for review January 10, 2022 08:37
def warStateCallBack(self, data):
self.warState = data
print('get enem_get_wall_marker_no data!')
print(self.warState.enem_get_wall_marker_no)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EndoNrak EndoNrak changed the title puperun内で各naviモードの初期化を最初に一回だけにする puperun内で各naviモードの初期化処理をpuperun.__init__内で統一 Jan 10, 2022
@EndoNrak EndoNrak changed the title puperun内で各naviモードの初期化処理をpuperun.__init__内で統一 各naviモードインスタンスの初期化処理をpuperun.__init__内で統一 Jan 10, 2022
@EndoNrak EndoNrak merged commit a88515a into main Jan 10, 2022
@EndoNrak EndoNrak deleted the fix-puperun branch January 10, 2022 08:51
@EndoNrak
Copy link
Owner Author

一応確認しておきたい事項

naviモードインスタンスの初期化タイミングが変わったので、モードが切り替わった時に正常に動作しているかを確認しておきたい 特にattack→basicの時にどうなる

検証してくれた
#59 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants