Skip to content

pfoeの実装#226

Open
sabakan495 wants to merge 1 commit into
deployfrom
feat/PFoE
Open

pfoeの実装#226
sabakan495 wants to merge 1 commit into
deployfrom
feat/PFoE

Conversation

@sabakan495
Copy link
Copy Markdown

教師走行で記録した「映像+操作の時系列(エピソード)」を覚えておき、本番走行中に「今カメラに映ってる景色は、記録のどのコマに一番似てるか」をパーティクルフィルタで推定して、そのコマの操作(joy値)を出力する。
学習(ニューラルネットの重み更新)はしない。記録との照合だけで動く方式。


self.zed_camera.retrieve_image(self.zed_image, sl.VIEW.LEFT)
image = self.zed_image.get_data()
resized_image = cv2.resize(image, (224, 224))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

224x224で画像を使うなら800x600を圧縮するのではなく真ん中でクロップした方が画像が横に潰れなくて良いのではないでしょうか

Comment on lines +112 to +113
left_stick = msg.axes[0]
right_stick = msg.axes[4]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

左スティックが前後の値、右スティックが左右の値をとることを想定しているなら、
left_stick = msg.axes[1]
right_stick = msg.axes[2]
が正しいと思います。

left_stick = msg.axes[0]
right_stick = msg.axes[4]

self.joy_value = np.arctan2(right_stick, left_stick)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

left_stick(並進速度)は記録し始めてからは基本倒しっぱなしで情報があまりないと思うので
self.joy_value = right_stick
のようにして1つにするのはどうでしょうか
left_stickが使わなそうでしたら上のとこも消してください。

Comment on lines +117 to +152
def timer_callback(self)->None:
if self.is_paused:
return

current_time = time.time()

if self.sdk_flag_:
image = self._capture_data_from_zed()
if image is None or self.joy_value is None:
return

if self.last_sample_time is None or current_time - self.last_sample_time >= SAMPLE_INTERVAL:
get_image_tensor = self.feature_extractor.extract(image).astype(np.float32)
row = np.concatenate([
get_image_tensor,
np.array([self.joy_value], dtype=np.float32)
])
self.bin_file.write(row.tobytes())
self.log_writer.writerow([self.row_count, self.joy_value])
self.row_count += 1
self.last_sample_time = current_time

else:
if self.latest_image is None or self.joy_value is None:
return
if self.last_sample_time is None or current_time - self.last_sample_time >= SAMPLE_INTERVAL:
cv_image = self.bridge.imgmsg_to_cv2(self.latest_image, desired_encoding='rgb8')
get_image_tensor = self.feature_extractor.extract(cv_image).astype(np.float32)
row = np.concatenate([
get_image_tensor,
np.array([self.joy_value], dtype=np.float32)
])
self.bin_file.write(row.tobytes())
self.log_writer.writerow([self.row_count, self.joy_value])
self.row_count += 1
self.last_sample_time = current_time
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

timer_callbackとサンプルタイムが同じだと画像を10hzで撮ったあとの特徴量の抽出までが間に合わないと思います。
特徴量の抽出がどれくらいかかるのか分かりませんがサンプルタイムを大きくするか特徴量の抽出はデータを取った後にするのがいいと思います。

param.requires_grad = False

self.transform = transforms.Compose([
transforms.Resize((224, 224)),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

二重でリサイズされてます。
要らないと思います。

Comment on lines +13 to +14
weights = models.EfficientNet_B0_Weights.IMAGENET1K_V1
backbone = models.efficientnet_b0(weights=weights)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ネットで一度インストールするよりかは事前に重みファイルをディレクトリの中に置いておいてそれを使った方が安心安全だと思います。

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