[docs]classBasicTest:def__init__(self):# necessary to simualate normal ASself.steering_control_engage_pub=rospy.Publisher('/mission_machine/steering_control_engage',SteeringControlEngage,queue_size=10,latch=True)self.velocity_torque_switch_pub=rospy.Publisher('/mission_machine/use_velocity',VelocityTorqueSwitch,queue_size=10,latch=True)# get parameters self.test=BasicTestEnum(rospy.get_param('/basic_tests/test'))# which test should be executedself.velocity=rospy.get_param('/basic_tests/velocity')self.steering_frequency=rospy.get_param('/basic_tests/steering_frequency')self.max_angle=rospy.get_param('/basic_tests/max_angle')self.brake_pressure=rospy.get_param('/basic_tests/brake_pressure')self.torque=rospy.get_param('/basic_tests/torque')self.steering_wheel_offset=rospy.get_param('/vehicle/steering_wheel_angle_offset')self.actc_step_angle=0self.current_brake_pressure=0self.current_velocity=self.velocity# necessary for EBS test for easier managing of inverterself.ebs_target_velocity_reached=False# subscribe to AS stateself.as_state=AutonomousSystemStateEnum(0)rospy.Subscriber('/can/per/as_state',AutonomousSystemState,self.as_state_callback)# velocity or torqueself.velocity_pub=rospy.Publisher('/control/velocity/request',Velocity,queue_size=10,latch=True)self.torque_pub=rospy.Publisher('/control/torque/request',Torque,queue_size=10,latch=True)# steering wheel angleself.start_time=Noneself.steering_pub=rospy.Publisher('/control/steering_wheel_angle/request',SteeringWheelAngle,queue_size=10)# service brakeself.service_brake_pub=rospy.Publisher('/control/service_brake/request',BrakePressure,queue_size=10,latch=True)# necessary for actc testsself.actual_velocity=0self.wheel_radius=rospy.get_param('/vehicle/wheel_radius')self.gear_ratio=rospy.get_param('/vehicle/rear_gear_ratio')wheelspeed_sub=rospy.Subscriber('/can/log/wheelspeed/rear',Wheelspeed,self.rear_wheelspeed_callback,queue_size=10)rospy.on_shutdown(self.deactivate_steering)self.run()
[docs]defrun(self):# choose between torque and velocityuse_velocity=self.test!=BasicTestEnum.TORQUEself.publish_velocity_torque_switch(use_velocity)self.publish_steering_angle(0)# wait until driving is reachedwhilenotrospy.is_shutdown():ifself.as_state==AutonomousSystemStateEnum.DRIVING:break# enable steering and choose between torque and velocityself.publish_steering_control_engage(steering_engage=True)ifuse_velocity:self.publish_velocity(0)else:self.publish_torque(0)# lower service brake pressureself.release_brakes(use_velocity)# run logic for testrospy.loginfo(f'[Basic Test] {self.test.name}')ifself.test==BasicTestEnum.EBS:self.publish_velocity_torque_switch(use_velocity=False)self.publish_torque(0)run_method=self.ebselifself.test==BasicTestEnum.ACTC_STEP:run_method=self.actc_stepelifself.test==BasicTestEnum.ACTC_SINUS:run_method=self.actc_sinuselifself.test==BasicTestEnum.SERVICE_BRAKE:run_method=self.service_brakeelifself.test==BasicTestEnum.TORQUE:run_method=self.torque_controlrate=rospy.Rate(50)rospy.loginfo('[Basic Test] Go!')whilenotrospy.is_shutdown():run_method()rate.sleep()rospy.loginfo('[Basic Test] Stop!')