sumo traci 函数解析(一)

获得车辆状态函数(Vehicle Value Retrieval)

本次函数五个一组进行注释,最后附上代码结果,尽量为大家展示带参数的函数正确格式。主要为大家省去翻译文档的麻烦,且正确使用函数。

1

print(traci.vehicle.getIDList())#获得正在运行的车辆ID
print(traci.vehicle.getIDCount())#获得该时刻车辆总数
print(traci.vehicle.getSpeed('bike0'))#获得该时刻车辆速度
print(traci.vehicle.getLateralSpeed('bike0'))#获得该时刻车辆横向速度的
print(traci.vehicle.getAcceleration('bike0'))#获得该时刻车辆加速度
('bike0', 'bike1', 'bike2', 'bike3', 'bus0', 'bus1', 'bus2', 'bus3', 'moto1', 'moto2', 'moto3', 'truck1', 'truck2', 'truck3', 'truck4', 'truck5', 'truck6', 'veh0', 'veh1', 'veh10', 'veh3', 'veh4', 'veh5', 'veh6', 'veh7', 'veh8', 'veh9')
27
5.481349706235859
0.0
0.2691567166708406

2

   print(traci.vehicle.getPosition('bike0'))#获得此时刻车辆的最后位置
   print(traci.vehicle.getPosition3D('bike0'))#获得此时刻车辆的最后位置(三维)
   print(traci.vehicle.getRoadID('bike0'))#获得此时刻车辆的最后所处道路
   print(traci.vehicle.getLaneID('bike0'))#获得此时刻车辆的最后所处车道
   print(traci.vehicle.getAngle('bike0'))#返回指定车辆在最后时刻中的角度
(8975.175871435666, 8443.129104682062)
(8975.175871435666, 8443.129104682062, 0.0)
-202626040#1
-202626040#1_0
88.30247635735724

3

print(traci.vehicle.getLaneIndex('bike0'))  # 返回指定车辆在最后一步所处的车道索引
print(traci.vehicle.getTypeID('bike0'))  # 获得此时刻车辆的类型
print(traci.vehicle.getRouteID('bike0'))  # 获得此时刻车辆的规划路线
print(traci.vehicle.getRouteIndex('bike0'))  # 返回车辆路线内当前边缘的索引,如果车辆尚未离开则返回-1
print(traci.vehicle.getRoute('bike0'))  # 返回车辆路线组成的边缘的id
0
bike_bicycle
!bike0!var#1
0
('-202626040#1',)

4

print(traci.vehicle.getColor('bike0'))  # 获得此时刻车辆的颜色
print(traci.vehicle.getLanePosition('bike0'))  # 车辆在车道上的位置(前保险杠到车道起点的距离,单位[m]);
print(traci.vehicle.getDistance('bike0'))  # 车开过的距离
print(traci.vehicle.getSignals('bike0'))  # 对车辆信号状态进行编码的整数,有关更多信息,请参阅Tra CI/车辆信号。
print(traci.vehicle.getRoutingMode('bike0'))  # 编码当前路由模式的整数

(255, 255, 0, 255)
43.55287852695005
41.85287852695005
0
0

5

            print(traci.vehicle.getTaxiFleet(-1))  # 返回具有给定模式的所有出租车的列表:(-1:所有,0:空,1:皮卡,2:已占用,3:皮卡+已占用)print(traci.vehicle.getCO2Emission('bike0'))  # 车辆在该时间步内的CO2排放量,单位为mg/s,得到每一步的值乘以步长;
            print(traci.vehicle.getCOEmission('bike0'))  #车辆在此时间步内的CO排放量(mg/s),得到每一步的值与步长相乘
            print(traci.vehicle.getHCEmission('bike0'))  # 该时间步内车辆HC排放量(mg/s),一步值与步长相乘得到
            print(traci.vehicle.getPMxEmission('bike0'))  # 车辆在该时间步长的PMx排放量(mg/s),得到一步的值乘以步长
()
13955.8819865914
23.465781843722876
5.918578416908347
2.55823616758279

6

            print(traci.vehicle.getNOxEmission('bus0'))  # 车辆在此时间步内的NOx排放量(mg/s),得到每一步的值与步长相乘
            print(traci.vehicle.getFuelConsumption('bus0'))  # 车辆在该时间步长的耗油量ml/s,得到每一步的值乘以步长;
            print(traci.vehicle.getNoiseEmission('bus0'))  # 车辆在dBA中产生的噪声
            print(traci.vehicle.getElectricityConsumption('bus0'))  # 计算该时间步内车辆耗电量Wh/s,得到每一步的值与步长相乘
            print(traci.vehicle.getBestLanes('bus0'))  # 对于当前边缘上的每一条车道,将返回该车道在没有变道的情况下被跟随的车道序列,以及关于变道可取性的信息(见下文)
109.16316697483072
4416.945991935694
75.66300467207088
0.0
(('42499661#0_0', 120.46, 0.0, 0, True, ('42499661#0_0',)),)

7

            print(traci.vehicle.getStopState('bus0'))  # 获得停车位的数量
            print(traci.vehicle.isAtBusStop('bus0'))  # 返回车辆是否停在公共汽车站;
            print(traci.vehicle.isAtContainerStop('bus0'))  # 返回车辆是否停在货柜站
            print(traci.vehicle.isStopped('bus0'))  # 是否是停止泊车
            print(traci.vehicle.isStoppedParking('bus0'))  # 返回车辆是否在停车(暗示停止)print(traci.vehicle.isStoppedTriggered('bus0'))#返回车辆是否停止并等待人员或集装箱

0
False
False
False
False
False

8

            print(traci.vehicle.getLength('bus0'))  # 返回车辆的长度
            print(traci.vehicle.getMaxSpeed('bus0'))  # 返回车辆的最大速度
            print(traci.vehicle.getAccel('bus0'))  #返回该车辆的最大加速可能性
            print(traci.vehicle.getDecel('bus0'))  # 返回该车辆的最大减速可能性
            print(traci.vehicle.getTau('bus0'))  # 返回驾驶员期望的车辆时距
0.5
1.0
0.0
bus
HBEFA3/Bus

9

            print(traci.vehicle.getShapeClass('bus0'))  # 返回此交通工具的类型
            print(traci.vehicle.getMinGap('bus0'))  # 返回这辆车的偏移量(如果停下来,与前车的距离)
            print(traci.vehicle.getWidth('bus0'))  #返回该载体的宽度
            print(traci.vehicle.getHeight('bus0'))  # 返回这个载具的高度
            print(traci.vehicle.getPersonCapacity('bus0'))  # 返回可乘坐该车辆的总人数

bus
2.5
2.5
3.4
85

7

			print(traci.vehicle.getWaitingTime('bus0'))  # 返回车辆连续停留的时间[s](不包括自动停车)
            print(traci.vehicle.getAccumulatedWaitingTime('bus0'))  # 返回上一个默认长度为100秒的时间间隔内的累计等待时间[s](长度可以根据每个选项配置——给主应用程序的等待时间-内存)
            print(traci.vehicle.getNextTLS("bus0"))  #返回即将到来的红绿灯,以及距离和状态
            #print(traci.vehicle.getNextStops('bike0'))  # 返回即将到来的停止的列表,每一个都是复合的(车道ID,结束Pos, ID,标志,持续时间,直到)。如果设置标志1(到达停止),则duration对剩余的持续时间进行编码。负值表示在停车后被阻止重新进入车流
            print(traci.vehicle.getPersonIDList('bus0'))  # 返回人员列表,其中包括使用属性“person Number”定义的人员,以及乘坐该车辆的对象
0.0
0.0
()
()

8

            print(traci.vehicle.getSpeedMode('bus0'))  # 检索如何处理由speed (0x40)slow (0x14)设置的值。
            print(traci.vehicle.getLaneChangeMode('bus0'))  # 获取有关一般情况下如何变道以及Tra CI如何执行变道请求的信息。
            print(traci.vehicle.getSlope("bus0"))  # 以度为单位检索当前车辆位置的坡度
            print(traci.vehicle.getAllowedSpeed('bike0'))  # 返回人员总数,其中包括使用属性'person number '定义的人员以及-乘坐该车辆的对象。
            print(traci.vehicle.getLine('bus0'))  # 返回该车辆的通过边缘的id。
31
1621
0.0
5.555555555555555


9

            print(traci.vehicle.getSpeedWithoutTraCI('bus0'))  # 如果没有给出影响速度的命令(如设置速度或减慢速度),则返回车辆将行驶的速度。
            print(traci.vehicle.isRouteValid('bus0'))  # 返回当前车辆路线是否为给定车辆的车辆类别所连接。
            print(traci.vehicle.getLateralLanePosition("bus0"))  # 返回车辆在其当前车道上的横向位置,单位为m
            print(traci.vehicle.getMaxSpeedLat('bike0'))  # 返回单位为s的车辆的当前动作步长。
            print(traci.vehicle.getMinGapLat('bus0'))  # 以50km/h的速度返回车辆的期望横向间隙,单位为m
13.467704705530778
True
0.0
1.0
0.6

10

            print(traci.vehicle.getLateralAlignment('bus0'))  # 如果没有给出影响速度的命令(如设置速度或减慢速度),则返回车辆将行驶的速度。
            print(traci.vehicle.getParameter("bus0",'vehID') ) # 返回给定字符串参数的值。
            print(traci.vehicle.getActionStepLength("bus0"))  # 返回单位为s的车辆的当前动作步长。
            print(traci.vehicle.getLastActionTime('bike0'))  # 返回s中最后一个操作步骤的时间。
            print(traci.vehicle.getStops('bus0'))  # 返回下一个或最后一个n个Stop Data对象的列表。
            print(traci.vehicle.getTimeLoss('bus0'))  # 返回车辆在s内的累计时间损失

center

1.0
10.0
()
0.29891376076070714
  • 5
    点赞
  • 64
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值