class HighPrecisionControl_v1(IAction):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    高精度控制
    '''
    raise ClosedError("Code content is not open-source!")
Esempio n. 2
0
 def get_center_lane_param(self):
     '''
     得到车道中心线的拟合参数
     20m,间隔2m采样,然后拟合这些点!
     :return 4长度向量c3, c2, c1, c0
     '''
     raise ClosedError("Code content is not open-source!")
Esempio n. 3
0
 def get_left_right_center_lane(self):
     '''
     # TODO:所有的车道的点应当是以车辆坐标转换后进行拟合!
     获得车道线信息
     从车辆的起点开始,间隔2m向后获得点,总共50个点,同时绘制出来!
     '''
     raise ClosedError("Code content is not open-source!")
Esempio n. 4
0
 def train(self, state_batch, action_batch):
     '''
     :param state_batch: state数据集,shape需要为None, + state shape, 如(1,7)
     :param action_batch: action数据集,shape需要为None, + action shape, 如(1,2)
     :return:
     '''
     raise ClosedError("Code content is not open-source!")
class ContinuousSteeringVelocityBrakeAction_v1(IAction):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    浮点数action,油门和转向和刹车
    '''
    raise ClosedError("Code content is not open-source!")
class CenterLaneThreeTimesPolyFitParamState_v1(IState):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    # 车道线3次拟合参数state
    '''

    raise ClosedError("Code content is not open-source!")
class CarState_v2(IState):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    车辆的速度,加速度标量,和速度,加速度向量的xy,注意速度加速度都是相对于车辆坐标系
    '''

    raise ClosedError("Code content is not open-source!")
class MoveTargetAndCarState_v1(IState):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    用Target waypoint和车辆当前的速度等信息作为state
    '''

    raise ClosedError("Code content is not open-source!")
class SafeDriveStepsVelocityAndDistanceToCenterLaneReward_v1(IReward):
    '''
    每一步使用速度+,和距离车道线距离-为reward
    每一步积累速度的reward,然后只在最后一步done的时候给出总reward,当然也要加上速度和车道线距离reward分量

    '''

    raise ClosedError("Code content is not open-source!")
class VelocityDistanceToLaneReward(IReward):
    Author = "BaoChuan Wang"
    AllowImport = False
    """
    任何时候每一步给出速度+和到车道线距离-的reward
    """

    raise ClosedError("Code content is not open-source!")
Esempio n. 11
0
 def reset(mySelf):
     '''
     这个方法相当于重载了env中的reset
     本类的self变成mySelf
     而env就变为self,这样里面的代码接近env自己的reset方法,便于识别
     因为python中函数是对象,所以直接复制实现重载
     '''
     raise ClosedError("Code content is not open-source!")
class SafeDriveDistanceSpeedAndDistanceToLaneCost(IReward):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    最后一步加上总距离cost,其他情况下使用到车道线距离和速度的cost
    '''

    raise ClosedError("Code content is not open-source!")
class FinalStepDriveDistanceAverageSpeedAverageDistanceToLaneCost_v2(IReward):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    适用于Env_laneFollow
    和v1的区别是加大了速度和车道线的贡献,v1是稳定训练的,但是最后车速很慢
    '''

    raise ClosedError("Code content is not open-source!")
class LowVelAndFarFromLaneDoneAfterNSteps_v1(IDone):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    结束的条件:
    1.至少进行某个step后低于某个速度done
    2.距离车道线太远done(使用车道线的c0参数即可)
    '''
    raise ClosedError("Code content is not open-source!")
class SoftLowVelocityFarFromLaneThroughRedLightDone(IDone):
    '''
    结束的条件:
    1.除了在等红绿灯且为红灯,其他任何时候,连续一定步数速度都低于某个值
    2.任何时候,距离车道线太远
    3.闯红灯(距离面前的status为红的灯的车前进方向的距离小于某个值,这个值需要设置好!)

    '''
    raise ClosedError("Code content is not open-source!")
class FinalStepDriveDistanceAverageSpeedAverageDistanceToLaneCost_v1(IReward):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    适用于Env_laneFollow
    最后一步给出安全行驶距离+,平均速度+,以及平均到车道线的距离-的总和cost
    '''

    raise ClosedError("Code content is not open-source!")
class OnlyCarToTargetWaypointDistanceRatioReward_v1(IReward):
    Author = "BaoChuan Wang"
    AllowImport = False
    '''
    没有必要设置太多的reward参数,让模型自己去学习,
    比如车到pathway线段的垂直距离,可以不用设置,因为能够达到waypoint终点的不会太过离谱
    另外在is done中可以设置越快达到终点,reward越高!
    '''

    raise ClosedError("Code content is not open-source!")
class CarToPathAndTargetWaypointDistanceReward_v1(IReward):
    Author = "BaoChuan Wang"
    AllowImport = False
    '''
    用车辆到pathway线段的垂直距离
    增加车辆到终点距离
    注意:对于速度的reward不要太高,否则模型可能一直选择加速
    '''

    raise ClosedError("Code content is not open-source!")
class EqualPriorProbaDistributionSimpleSteeringAction_v1(IAction):
    Author = "BaoChuan Wang"
    AllowImport = False
    '''
    设置好相等先验概率分布的action能够有助于训练的加速!
    
    等先验概率分布的action
    SimpleSteeringAction_v1的问题在于,大部分action都应该是0,也就是加速,action的先验分布不平均
    现在设置分布均匀的action,通过模型后求得state下的条件概率
    '''
    raise ClosedError("Code content is not open-source!")
class TrafficLightState_v1(IState):
    Author = "BaoChuan Wang"
    AllowImport = False
    '''
    输出:第一个为0,代表没有红灯(或者绿灯),第一个为1,代表红灯或者黄灯
    第二个为到交通灯的距离,超出100时为0
    否则为距离/100
    注意:实测为绿灯时,即使距离交通灯很近,distance也为None
    '''

    raise ClosedError("Code content is not open-source!")
class DistanceToTargetLowestStepAndLowVelDone_v1(IDone):
    Author = "BaoChuan Wang"
    AllowImport = False
    '''
    比起一般的done的True和False,这个条件匹配于Env_waypointTarget
    done为True时,还需要分成功和失败,因为成功是设置下一个路径点,失败是重新训练
    1.至少进行某个step后低速done,视为fail
    2.超过路径点而没有到达路径点done,fail
    2.到达路径点done,success
    done过后修改reward
    '''
    raise ClosedError("Code content is not open-source!")
class SafeDriveDistanceCost(IReward):
    Author = "BaoChuan Wang"
    AllowImport = True
    Archive = True
    '''
    在max distance行驶了多少相对距离作为cost

    每一步加上速度,然后只在最后一步done的时候给出总reward,其他状态给出0的reward
    用它减去max distance,使其变为负,然后除以max distance,注意超过max distance会有问题
    '''

    raise ClosedError("Code content is not open-source!")
class CarToPathDistanceDeltaReward_v1(IReward):
    Author = "BaoChuan Wang"
    AllowImport = True
    '''
    适用于Env_waypointsTarget,用前后的变化量作为rewards的计算依据
    分别是
    action前后车辆到车道线垂直距离的delta
    action前后车辆方向角和way方向角差的delta
    action前后速度的delta
    
    重要!如果采用这种方法,需要确保数值是连续的,因为这里的假设条件是上面用于计算delta的指标都是连续的
     这样才能反映action对delta的影响,如果数值不完全对action连续,则会出现action外的情况影响rewards
     常见的就是waypoints随着车辆的变动而变动
     如果这种变动是增益的,或者幅度小的,可以忽略,
     具体的例子:车辆前进,waypoints更新后(waypoints总是车辆前面5m的点,每隔2.5m更新),夹角突然变小,如果转弯垂直距离会突然变大
    '''

    raise ClosedError("Code content is not open-source!")
Esempio n. 24
0
 def __init__(self,
              # 为了兼容之前的代码增加的replace(这里应该是将env作为无默认值的参数)
              env_replace=None,
              # 给env加的参数,dict
              kwargs_for_env=None,
              input_placeholder=None,
              output_graph=None,
              # 注意优化的sess要和RL的模型在同一个sess,否则不会修改到权重
              tf_sess=None,
              action_space_size=None,
              lr=0.00001,
              # 给agent action添加的噪声量,便于RL学习纠正行为,噪声不会进入训练集,只会反映在控制中
              variance_for_each_action=(0.,0.),
              # 只测试carla的agent,不建立tf计算图和优化!
              debug_for_agent=False,
              # 当操作一定步数过后,重新生成agent来控制车辆!主要是避免agent一直卡住,同时切换位置使数据集范围更广
              steps_for_carla_agent_reset=1200,
              # 是否无视信号灯
              ignore_traffic_light=True,
              # 数据收集
              data_collector=None,):
     raise ClosedError("Code content is not open-source!")
Esempio n. 25
0
 def step(mySelf):
     # 这里重载env中的step方法,注意原来step中必要的内容要保留
     raise ClosedError("Code content is not open-source!")
class SimpleSteeringAction_v1(IAction):
    Author = "BaoChuan Wang"
    AllowImport = True

    raise ClosedError("Code content is not open-source!")
class SafeDriveDistanceReward_v1(IReward):
    '''
    每一步加上速度,然后只在最后一步done的时候给出总reward,其他状态给出0的reward
    '''

    raise ClosedError("Code content is not open-source!")
Esempio n. 28
0
 def __get_bounding_box(self, obstacle):
     # 图像旋转矩阵,将远小近大的图片转成平面用于判断,视觉给出
     raise ClosedError("Code content is not open-source!")
Esempio n. 29
0
 def get_esr_tracks_and_obstacles(self):
     '''
     因为这里面两者代码很像,所以写在一起,但障碍物主要是车辆
     '''
     raise ClosedError("Code content is not open-source!")