def build_scene(): floor = agxCollide.Geometry(agxCollide.Box(10, 10, 0.1)) floor.setPosition(0, 0, -4) demoutils.sim().add(floor) # Create each and every one of the scenes create_hinge_scene() demoutils.app().getSceneDecorator().setEnableShadows(False) demoutils.app().setEnableDebugRenderer(True)
def display_forces(self, t): demoutils.app().getSceneDecorator().setText(6, "Target set point : {} M".format( self.pid.setpoint)) self.plot_setpoint.append(self.pid.setpoint) self.plot_time.append(t) if self.plot and not self.plotted: """plots stored values to csv file""" plot_setpoint = np.array(self.plot_setpoint) plot_time = np.array(self.plot_time) # pd.DataFrame(plot_setpoint).to_csv( # "C:/Users/Ishmael/PycharmProjects/pythonProject1/TowedRov-Sim/plotSetpoint.csv") # pd.DataFrame(plot_time).to_csv( # "C:/Users/Ishmael/PycharmProjects/pythonProject1/TowedRov-Sim/plotTime.csv") self.plotted = True
def contact( self, time: "agx::TimeStamp const &", geometryContact: "GeometryContact" ) -> "agxSDK::ContactEventListener::KeepContactPolicy": """ Args: time: geometryContact: Returns: """ for p in geometryContact.points(): d = p.getPoint()[2] x = p.getPoint()[0] y = p.getPoint()[1] """ send depth awayhere as D""" demoutils.app().getSceneDecorator().setText( 10, "depth to seafloor : {}".format(str(d), )) return True
def post(self, time: "agx::TimeStamp const &") -> "void": pos = self.rov.link1.getPosition() rot = self.rov.link1.getRotation() decorator = demoutils.app().getSceneDecorator() decorator.setText( 9, "pid : {}, wing: {}".format( self.pid.output, round(rad2deg(self.rov.left_wing_angle()), 2))) decorator.setText( 3, "Rov Position in Z direction : {} M".format(str(round(pos[2], 2)))) decorator.setText(4, "Pitch : {}".format(str(round(rot[0] * 100, 2)))) decorator.setText(5, "Roll : {}".format(str(round(rot[1] * 100, 2)))) x, y = int(WATER_LENGTH + pos[0]), int(pos[1]) decorator.setText( 7, "distance : {}M".format( str(round(self.rov.link1.getPosition()[0], 2))))
def display_forces(self, t): tot_contact_force = agx.Vec3() contacts = demoutils.sim().getSpace().getGeometryContacts() for contact in contacts: points = contact.points() for p in points: f = p.getForce() tot_contact_force = tot_contact_force + f demoutils.app().getSceneDecorator().setText(0, "Towed-Rov simulation") demoutils.app().getSceneDecorator().setText(1, "Thrust : {} kN".format( self.m_propulsion_force / 500)) # 2/1000 ( 2 because of the 2 propellers ) demoutils.app().getSceneDecorator().setText(2, "Speed in X direction : {} knots".format( str(round(self.m_body.getVelocity()[0] * 1.94384449, 2))))
def post(self, t): """ can send depth and everything form here aswell Args: t: """ pos = self.rov.link1.getPosition() rot = self.rov.link1.getRotation() decorator = demoutils.app().getSceneDecorator() decorator.setText(9, "pid : {}, wing: {}".format(str(self.pid.output), round( rad2deg(self.rov.left_wing_angle()), 2))) decorator.setText(3, "Rov Position in Z direction : {} M".format(str(round(pos[2], 2)))) decorator.setText(4, "Pitch : {}".format(str(round(rot[0] * 100, 2)))) decorator.setText(5, "Roll : {}".format(str(round(rot[1] * 100, 2)))) x, y = int(WATER_LENGTH + pos[0]), int(pos[1]) # print(int(pos[0]),int(pos[1]),int(pos[2])) decorator.setText(11, "seafloor actual : {}".format(str(round(self.depth.getHeight(x, y) - pos[2], 2)))) decorator.setText(7, "distance : {}M".format(str(WATER_LENGTH + round( self.rov.link1.getPosition()[0], 2))))
def post(self, t): demoutils.app().getSceneDecorator().setText( 8, "Depth under boat : {} m".format( str(round(self.get_depth_under_boat(), 2))))