How to use execute_control method in autotest

Best Python code snippet using autotest_python

Test2FalconsControl.py

Source:Test2FalconsControl.py Github

copy

Full Screen

...22 '''23 def __init__(self):24 self.logging = None25 26 def execute_control(self, s):27 s = str(s)28 print("execute_control %s" % s)29 if s.startswith("activate"):30 w = s.split()31 s = "activate " + w[1][4] + w[2]32 simCommand(s)33 def initialize_simulator(self, myteam = "teamA"):34 print("initialize_simulator")35 simInit()36 time.sleep(3)37 def shutdown_simulator(self):38 print("shutdown_simulator")39 simStop()40 time.sleep(3)...

Full Screen

Full Screen

world_rccar.py

Source:world_rccar.py Github

copy

Full Screen

...33 rostype = rostopic.get_topic_class(topic, blocking=False)[0]34 if rostype:35 ros_utils.Subscriber(topic, rostype, callback=self._bag_callback, callback_args=(topic,))36 def reset(self, back_up, itr=None, cond=None, rep=None, record=True):37# self._agent.execute_control(None) # stop the car38 assert(itr is not None and cond is not None and rep is not None)39 # TODO add sim backup40 ### back car up straight and slow41 if back_up:42 sample = Sample(meta_data=params, T=2)43 sample.set_U([np.random.uniform(*self.wp['back_up']['cmd_steer'])], t=0, sub_control='cmd_steer')44 sample.set_U([self.wp['back_up']['cmd_vel']], t=0, sub_control='cmd_vel')45 u = sample.get_U(t=0)46 if self._agent.sim:47 if self._agent.sim_coll and self._agent.sim_last_coll:48 self._logger.info('Resetting the car')49 self._agent.execute_control(None, reset=True)50 elif self._agent.sim_coll:51 # TODO add backup logic for not sim52 self._logger.info('Backing the car up')53 for _ in xrange(int(self.wp['back_up']['duration'] / params['dt'])): 54 self._agent.execute_control(u)55 if self._agent.sim_coll:56 break57 for _ in xrange(int(1.0 / params['dt'])):58 self._agent.execute_control(None)59 else:60 self._logger.info('Backing the car up')61 start = time.time()62 while time.time() - start < self.wp['back_up']['duration']:63 self._agent.execute_control(u)64 self._agent.execute_control(None)65 time.sleep(1.0)66 else:67 self._agent.execute_control(None, reset=True)68 ### TODO add a flag69 self._ros_reset_pub.publish(std_msgs.msg.Empty())70 ### record71 if record:72 self._start_record_bag(itr, cond, rep)73 74 if not self._agent.sim:75 ### reset indicators76 self._ros_collision.get()77 self.num_collisions = 078 def is_collision(self, sample, t=None):79 #return False80 if self._agent.sim:81 return self._agent.sim_coll82 else:83 return self._ros_collision.get() is not None84 def update_visualization(self, history_sample, planned_sample, t):85 pass86 def get_image(self, sample):87 return None88 def get_info(self):89 self._stop_record_bag()90 ### reset indicators91 self._ros_collision.get()92 return dict()93 ###########94 ### ROS ###95 ###########96 def _start_record_bag(self, itr, cond, rep):97 self.bag = rosbag.Bag(self.bag_file_func(itr, cond, rep), 'w')98 def _bag_callback(self, msg, args):99 topic = args[0]100 with self.bag_lock:101 if self.bag:102 self.bag.write(topic, msg)103 def _stop_record_bag(self):104 if self.bag is None:105 return106 with self.bag_lock:107 bag = self.bag108 self.bag = None109 # bag.reindex()110 bag.close()111 def _ros_collision_callback(self, msg):112 ### immediately stop the car if it's the first collision113 if self._agent.sim_coll:114 if self.num_collisions == 0:115 self._agent.execute_control(None)...

Full Screen

Full Screen

ackermann_control.py

Source:ackermann_control.py Github

copy

Full Screen

...32 model_state.twist.linear.x = vx33 model_state.twist.linear.y = vy34 model_state.twist.angular.z = vs35 self.set_model_state(model_state=model_state)36 def execute_control(self, lin_v, ang_v, time=1):37 while time > 0:38 msg = AckermannDrive()39 msg.speed = lin_v40 msg.steering_angle_velocity = ang_v41 self.ctrl.publish(msg)42 time -= 143 sleep(.2)44 def get_new_state(self, state):45 while True:46 self.set_state(state.X, state.Y, state.theta, state.vx, state.vy, state.vs)47 linVel, steerVel, time = SE2.get_random_control()48 self.execute_control(linVel, steerVel)49 orient = self.get_model_state(model_name="ackermann_vehicle").pose.orientation50 angles = tf.transformations.euler_from_quaternion([orient.x, orient.y, orient.z, orient.w])51 #print angles52 if angles[0] < 2*3.14 and angles[0] > 0:53 break54 '''55 else:56 print 'redoing'57 '''58 new_state = self.get_model_state(model_name="ackermann_vehicle")59 new_pose, new_twist = new_state.pose, new_state.twist60 quat = tf.transformations.random_quaternion()61 quat[0] = new_pose.orientation.x62 quat[1] = new_pose.orientation.y63 quat[2] = new_pose.orientation.z64 quat[3] = new_pose.orientation.w65 s = tf.transformations.euler_from_quaternion(quat)[2]66 x = new_pose.position.x67 y = new_pose.position.y68 self.set_state(state.X, state.Y, state.theta, state.vx, state.vy, state.vs)69 return SE2(x,y,s)70 def interpolate(self, state):71 '''Create smooth transition graphic to impress myself'''72 model_state_resp = self.get_model_state(model_name="ackermann_vehicle")73if __name__ == "__main__":74 mouseBot = AckermannControl()75 mouseBot.execute_control(50, 50)76 sleep(2)77 mouseBot.set_state(3, -5, 0)78 for i in range(1000):79 linVel, steerVel, time = SE2.get_random_control()80 print vel[0], vel[1]81 mouseBot.control(linVel, steerVel, time)82 sleep(2)83 print mouseBot.get_model_state(model_name="ackermann_vehicle")...

Full Screen

Full Screen

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 autotest 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