第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Python if 語(yǔ)句:Unndent 不匹配任何外部縮進(jìn)級(jí)別

Python if 語(yǔ)句:Unndent 不匹配任何外部縮進(jìn)級(jí)別

藍(lán)山帝景 2022-04-23 17:21:28
我有以下 Python 代碼def reward_function(params):        import math        # Read input variables        waypoints = params['waypoints']        closest_waypoints = params['closest_waypoints']        heading = params['heading']        # Initialize the reward with typical value         reward = 1.0        # Calculate the direction of the center line based on the closest waypoints        next_point = waypoints[closest_waypoints[1]]        prev_point = waypoints[closest_waypoints[0]]        # Calculate the direction in radius, arctan2(dy, dx), the result is (-pi, pi) in radians        track_direction = math.atan2(next_point[1] - prev_point[1], next_point[0] - prev_point[0])         # Convert to degree        track_direction = math.degrees(track_direction)        # Calculate the difference between the track direction and the heading direction of the car        direction_diff = abs(track_direction - heading)    if direction_diff > 180: # This line gives me the ERROR        direction_diff = 360 - direction_diff        # Penalize the reward if the difference is too large        DIRECTION_THRESHOLD = 10.0        if direction_diff > DIRECTION_THRESHOLD:        reward *= 0.5        return reward我嘗試了幾個(gè)不同的編輯器,但無(wú)法解決這個(gè)縮進(jìn)問(wèn)題。任何指針都非常受歡迎。
查看完整描述

1 回答

?
墨色風(fēng)雨

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊

不要使用 8 個(gè)空格(2 個(gè)制表符),使用 4 個(gè)(1 個(gè)制表符):


def reward_function(params):

    import math

    # Read input variables

    waypoints = params['waypoints']

    closest_waypoints = params['closest_waypoints']

    heading = params['heading']

    # Initialize the reward with typical value 

    reward = 1.0

    # Calculate the direction of the center line based on the closest waypoints

    next_point = waypoints[closest_waypoints[1]]

    prev_point = waypoints[closest_waypoints[0]]

    # Calculate the direction in radius, arctan2(dy, dx), the result is (-pi, pi) in radians

    track_direction = math.atan2(next_point[1] - prev_point[1], next_point[0] - prev_point[0]) 

    # Convert to degree

    track_direction = math.degrees(track_direction)

    # Calculate the difference between the track direction and the heading direction of the car

    direction_diff = abs(track_direction - heading)

    if direction_diff > 180: # This line gives me the ERROR

        direction_diff = 360 - direction_diff

        # Penalize the reward if the difference is too large

        DIRECTION_THRESHOLD = 10.0

        if direction_diff > DIRECTION_THRESHOLD:

            reward *= 0.5

            return reward


查看完整回答
反對(duì) 回復(fù) 2022-04-23
  • 1 回答
  • 0 關(guān)注
  • 193 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)