Muminul Haque Raihan Ответов: 0

Как я могу разработать скрипт V2V или connected vehicle на Python


Я пытаюсь разработать следующую логику в Python, может ли кто-нибудь помочь мне со скриптом? Спасибо.
Explanation Logic: When vehicle type 102 will start driving in lane 1, it will send a continuous message from its position to 300m distance to Vehicle type 101, and vehicle type 101 will change its position from lane 1 to lane 2. If vehicle type 102 does not come, vehicle type 101 will drive on lane 1 as usual (no need to lane change). 


Что я уже пробовал:

def Initialization():
    global distDistr
    global Vehicle_Type_V2V_no_message
    global Vehicle_Type_V2V_HasCurrentMessage
    global speed_incident
    global lane
    global link
    global Vehicle_location
    global msg_types

    distDistr = '300'
    Vehicle_Type_V2V_no_message = '101'
    Vehicle_Type_V2V_HasCurrentMessage = '102'
    speed_incident = 'maximum'
    lane = '1'
    link = '1'
    position = '20'
    msg_types = 'lane change'
def send(agent, recipient_id=-101, msg_type='lane change', payload='null'):
    if (msg_type == 'lane change') & (payload == 'null'):
        payload = {
            'location': agent.position(),
            'link': agent.link,
            'lane':agent.lane,
        }

    result = {
        'recipient_id':  recipient_id,
        'msg_type':      msg_type,
        'payload':       payload,
    }
    return result
def receive(agent, sender_id, msg_type, payload):
    if msg_type == 'lane change': 
        location = payload['location']
        link = payload['link']
        lane = payload['lane']
        dist = agent._dist(agent.position(),payload['location'])
        logger.debug("Car # " + str(agent.id) + " received lane change message from Agent # " + str(sender_id) + " which is "+str(dist)+" 300 meters away")
        if link == '1' & Vehicle_location == '20' & Vehicle_Type_V2V_HasCurrentMessage == '102':
    logger.debug("Car # " + str(Vehicle_Type_V2V_no_message) + " preparing for lane change on link " + str(link_1) + " which is "+str(dist)+" 300 meters away")
    if lane = 1 or lane < 2:
        des_lane = 2
    else:
        des_lane = 1
    self.vissim.SetAttValue('DesLane',des_lane)
        result = {
        'sender_id':  sender_id,
        'msg_type':   msg_type,
        'payload':    payload,
    }
    return result

0 Ответов