-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
Waypointの初期化にサイドの判定が必要 やること
|
terminalからなら |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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で取得することにした
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将来的にサイドの設定を積極的に変更するときに、
'b'のつもりが'B'とかにして、意図したとおりに設定できていないという事態を認知できるようにValueErrorを作った
There was a problem hiding this comment.
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
一応確認しておきたい事項naviモードインスタンスの初期化タイミングが変わったので、モードが切り替わった時に正常に動作しているかを確認しておきたい |
@mashioka |
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enumerateの第二返り値は今回ひつようないので_
にしてメモリを節約
There was a problem hiding this 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サイドのときの処理も問題ないはず.
def warStateCallBack(self, data): | ||
self.warState = data | ||
print('get data!') | ||
print(self.warState.enem_get_wall_marker_no) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
イケムラデバック用に,ここのprint残しといてくれん??笑
There was a problem hiding this comment.
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
だけでいい?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
それで大丈夫!
def warStateCallBack(self, data): | ||
self.warState = data | ||
print('get enem_get_wall_marker_no data!') | ||
print(self.warState.enem_get_wall_marker_no) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
検証してくれた |
もとはselectModeCallBackのたびにnaviModeインスタンスを初期化してたけど、
最初に一回だけでいいことに気が付いた
各naviModeの初期化もpuperunのself.__init__内で呼べばいいのかも