-
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
Changes from 5 commits
4b91e18
06b0059
24275a3
3d571e6
293a121
e4bfba7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ class Waypoint: | |
|
||
next_lap_flag = False | ||
count_waypoint = 0 | ||
waypoint_reverse_flag_for_blue = True | ||
|
||
def __init__(self, path_waypoints, path_waypoints_depending_on_score): | ||
|
||
|
@@ -30,33 +29,32 @@ def __init__(self, path_waypoints, path_waypoints_depending_on_score): | |
lines = csv.reader(f) | ||
for l in lines: | ||
point = [float(i) for i in l] | ||
# print(point) | ||
self.points.append(point[0:3]) | ||
|
||
with open(path_waypoints_depending_on_score) as f_score: | ||
lines_score = csv.reader(f_score) | ||
for l_score in lines_score: | ||
point_depending_on_score = [float(i_score) for i_score in l_score] | ||
# print(point) | ||
self.points_depending_on_score.append(point_depending_on_score[0:3]) | ||
|
||
def warStateCallBack(self, data): | ||
self.warState = data | ||
print('get data!') | ||
print(self.warState.enem_get_wall_marker_no) | ||
|
||
if Waypoint.waypoint_reverse_flag_for_blue: | ||
# blue side の場合は,180度ひっくり返す | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. 将来的にサイドの設定を積極的に変更するときに、 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
elif 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 commentThe reason will be displayed to describe this comment to others. Learn more. enumerateの第二返り値は今回ひつようないので |
||
self.points_depending_on_score[i][0] *= -1 | ||
self.points_depending_on_score[i][1] *= -1 | ||
self.points_depending_on_score[i][2] -= 3.141592654 | ||
|
||
print('my side:', self.warState.my_side) | ||
print(self.points_depending_on_score) | ||
Waypoint.waypoint_reverse_flag_for_blue = False | ||
|
||
def warStateCallBack(self, data): | ||
self.warState = data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warStateCallBack自体はほかのメソッドでself.warStateの更新を期待しているので残す必要がある |
||
|
||
def get_next_waypoint(self): | ||
print(self.warState.enem_get_wall_marker_flag) | ||
Waypoint.count_waypoint = Waypoint.count_waypoint + 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,13 @@ def __init__(self, bot_name="NoName"): | |
# mode | ||
self.mode = ActMode.basic | ||
self.mode_prev = ActMode.basic | ||
self.navi = NaviBasic() | ||
self.modeDecider = ModeDecider() | ||
|
||
#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 commentThe reason will be displayed to describe this comment to others. Learn more. 各naviモードの初期化は最初に行う |
||
|
||
# subscriber | ||
self.imgInfo_sub = rospy.Subscriber('img_info', ImgInfo, self.imgInfoCallBack) | ||
self.imgInfo = ImgInfo() | ||
|
@@ -59,11 +63,10 @@ def selectModeCallBack(self, state): | |
print(self.mode, self.mode_prev) | ||
if self.mode != self.mode_prev: | ||
if self.mode==ActMode.basic: | ||
self.navi = NaviBasic() | ||
self.navi = self.navi_basic | ||
elif self.mode==ActMode.attack: | ||
# self.navi = NaviAttack() | ||
print("select attack mode") | ||
self.navi = NaviAttack2() | ||
self.navi = self.navi_attack | ||
|
||
self.mode_prev = self.mode | ||
|
||
|
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.
それで大丈夫!