How to use cmd_stop method in localstack

Best Python code snippet using localstack_python

modeThreads.py

Source: modeThreads.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3Created on Sat Dec 07 11:28:11 20194@author: Anaïs, Nicolas5"""6import time7import can8from threading import Thread, Lock9import sharedRessources as R10MOT=0x010 #identifiant commande moteur CAN11CMD_STOP = 0x0012CMD_V_BACK = 35 + 0x8013CMD_V_MIN = 5014CMD_V_SLOW = 65 + 0x8015CMD_V_TURBO = 75 + 0x8016CMD_O_LEFT = 0x8017CMD_O_RIGHT = 100 + 0x8018CMD_O_MIN = 5019#for auto only20REAL_SIGN_WIDTH = 0.20 #nb à déterminer en cm21FOCAL = 34222#thread emergency+modeThread23"""24emergencyOn = False25lockEmergencyOn = Lock()26"""27class ModeThread(Thread):28 def __init__(self, bus,intModeL):29 Thread.__init__(self)30 self.bus = bus31 self.intModeL = intModeL32 33 def sendMesgToMot(self,cmdV,cmdO):34 msg = can.Message(arbitration_id=MOT,data=[cmdV, cmdV, cmdO,0,0,0,0,0],extended_id=False)35 time.sleep(0.01)36 self.bus.send(msg)37 38 39class ModeAutoThread (ModeThread):40 def __init__(self, bus):41 ModeThread.__init__(self,bus,2)42 43 def run(self):44 self.sendMesgToMot(CMD_V_SLOW,CMD_STOP) 45 currentModeL=self.intModeL46 counterStopOn = False47 finalValueStopCounter = 048 counterStop=049 50 while (currentModeL==self.intModeL):51 # Emergency stop block52 R.lockEmergencyOn.acquire()53 stateEmergency = R.emergencyOn54 R.lockEmergencyOn.release()55 56 if(stateEmergency):57 R.modeLock.acquire()58 mode = "assist"59 R.modeLock.release()60 61 # Stop sign block62 63 if(counterStopOn):64 if(counterStop<finalValueStopCounter):65 counterStop+=0.166 else:67 self.sendMesgToMot(CMD_STOP,CMD_STOP) 68 time.sleep(4)69 self.sendMesgToMot(CMD_V_SLOW,CMD_STOP) 70 counterStop=071 finalValueStopCounter=072 counterStopOn = False73 74 else: 75 R.lockWidthStop.acquire() 76 widthStopSign = R.widthStop 77 R.lockWidthStop.release()78 if(widthStopSign):79 toSignDistance = (REAL_SIGN_WIDTH*FOCAL)/​widthStopSign80 R.lockWheelSpeed.acquire()81 speedC= R.wheelSpeed82 R.lockWheelSpeed.release()83 if speedC >= 0.14 :84 finalValueStopCounter = (toSignDistance /​ speedC)-3 #calcul du temps à attendre, 1.2 => 100 pour la vitesse avant -1 pour la reconnaissance85 counterStopOn=True86 87 88 R.lockModeLaunched.acquire()89 currentModeL = R.modeLaunched90 R.lockModeLaunched.release()91 time.sleep(0.1)92 93 self.sendMesgToMot(CMD_STOP,CMD_STOP) 94 95class ModeAssistThread (ModeThread):96 def __init__(self, bus):97 ModeThread.__init__(self,bus,1)98 99 def run(self):100 self.sendMesgToMot(CMD_STOP,CMD_STOP) 101 currentModeL=self.intModeL102 cmdV = CMD_STOP103 cmdO = CMD_STOP104 R.turboLock.acquire()105 R.turbo ="off"106 R.turboLock.release()107 R.joystickLock.acquire()108 R.joystick = "none"109 R.joystickLock.release()110 R.stateLock.acquire()111 R.state = "off"112 R.stateLock.release()113 114 while (currentModeL==self.intModeL):115 R.stateLock.acquire() 116 currentState = R.state 117 R.stateLock.release()118 if(currentState=="on"):119 R.joystickLock.acquire() 120 currentJoystick = R.joystick 121 R.joystickLock.release()122 if(currentJoystick =="none"):123 cmdO = CMD_O_MIN124 cmdV = CMD_V_MIN 125 elif(currentJoystick=="right"):126 cmdO = CMD_O_RIGHT127 cmdV= CMD_V_MIN 128 elif(currentJoystick=="left"):129 cmdO = CMD_O_LEFT130 cmdV = CMD_V_MIN 131 elif(currentJoystick=="front"):132 R.turboLock.acquire() 133 currentTurbo = R.turbo 134 R.turboLock.release()135 if(currentTurbo=="on"):136 cmdV=CMD_V_TURBO137 else:138 cmdV= CMD_V_SLOW139 cmdO = CMD_O_MIN 140 141 elif(currentJoystick=="front&right"):142 cmdO = CMD_O_RIGHT143 cmdV= CMD_V_SLOW144 elif(currentJoystick=="front&left"):145 cmdO = CMD_O_LEFT146 cmdV= CMD_V_SLOW147 148 elif(currentJoystick=="back"):149 cmdO = CMD_O_MIN150 cmdV= CMD_V_BACK151 152 elif(currentJoystick=="back&right"):153 cmdO = CMD_O_RIGHT154 cmdV= CMD_V_BACK155 156 elif(currentJoystick=="back&left"):157 cmdO = CMD_O_LEFT158 cmdV= CMD_V_BACK159 self.sendMesgToMot(cmdV,cmdO)160 161 162 else:163 self.sendMesgToMot(CMD_STOP,CMD_STOP)164 165 166 R.lockModeLaunched.acquire()167 currentModeL = R.modeLaunched168 R.lockModeLaunched.release()169 time.sleep(0.1)170 ...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful