def init_values(self): rospy.wait_for_service('/gazebo/reset_simulation') try: #reset_proxy.call() self.reset_proxy() except (rospy.ServiceException, e): print("/gazebo/reset_simulation service call failed") self._time_step = Float64(0.001) self._max_update_rate = Float64(1000.0) self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = 0.0 self._ode_config = ODEPhysics() self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 50 self._ode_config.sor_pgs_w = 1.3 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.001 self._ode_config.contact_max_correcting_vel = 0.0 self._ode_config.cfm = 0.0 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20 self.update_gravity_call()
def init_physics_parameters(self): """ We initialise the physics parameters of the simulation, like gravity, friction coeficients and so on. """ self._time_step = Float64(0.001) self._max_update_rate = Float64(1000.0) self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = -9.81 self._ode_config = ODEPhysics() self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 50 self._ode_config.sor_pgs_w = 1.3 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.001 self._ode_config.contact_max_correcting_vel = 0.0 self._ode_config.cfm = 0.0 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20 self.update_gravity_call()
def init_values(self): print "Starting init Grav" self._time_step = Float64(0.001) self._max_update_rate = Float64(1000.0) self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = 0.0 self._ode_config = ODEPhysics() self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 50 self._ode_config.sor_pgs_w = 1.3 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.001 self._ode_config.contact_max_correcting_vel = 0.0 self._ode_config.cfm = 0.0 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20 self.update_gravity_call()
def gazeboPhysicsSet(time_step_value=0.001, max_update_rate_value=1000): # Set as Default Gazebo Property gravity_value = Vector3(x=0, y=0, z=-9.81) ODE_value = ODEPhysics(auto_disable_bodies=False, sor_pgs_precon_iters=0, sor_pgs_iters=50, sor_pgs_w=1.3, sor_pgs_rms_error_tol=0, contact_surface_layer=0.001, contact_max_correcting_vel=100.0, cfm=0.0, erp=0.2, max_contacts=20) rospy.wait_for_service('/gazebo/set_physics_properties') try: set_physics_properties = rospy.ServiceProxy( '/gazebo/set_physics_properties', SetPhysicsProperties) service_result = set_physics_properties( max_update_rate=max_update_rate_value, time_step=time_step_value, gravity=gravity_value, ode_config=ODE_value) if (service_result): print('Physics properties is set as coded!') else: print('Service Does not Called!') except rospy.ServiceException as exc: print("Service did not process request: " + str(exc))
def init_values(self, speed=1000, z_gravity=-9.81, time_step=0.001): """ rospy.wait_for_service('/gazebo/reset_simulation') try: # reset_proxy.call() self.reset_simulation_proxy() except rospy.ServiceException, e: print ("/gazebo/reset_simulation service call failed") """ """ We initialise the physics parameters of the simulation, like gravity, friction coeficients and so on. """ self._time_step = Float64(time_step) # self._time_step = Float64(0.01) self._max_update_rate = Float64(speed) self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = z_gravity self._ode_config = ODEPhysics() self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 50 self._ode_config.sor_pgs_w = 1.3 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.001 self._ode_config.contact_max_correcting_vel = 0.0 self._ode_config.cfm = 0.0 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20 self.update_gravity_call()
def init_physics_parameters(self): """ We initialise the physics parameters of the simulation, like gravity, friction coeficients and so on. """ self._time_step = 0.001 # Setting this to zero will force gazebo to update # as fast as it can while keeping realism # default is 1000 self._max_update_rate = 0. self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = -9.81 self._ode_config = ODEPhysics() self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 50 self._ode_config.sor_pgs_w = 1.3 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.001 self._ode_config.contact_max_correcting_vel = 0.0 self._ode_config.cfm = 0.0 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20 self.update_gravity_call()
def init_physics_parameters(self): ''' We initialise the physics parameters of the simulation, like gravity, friction coeficients and so on. NOTE: this parameters are the same that turtlebot3 Gazebo simulations use ''' self._time_step = Float64(0.001) self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = -9.81 self._ode_config = ODEPhysics( ) #TODO: these properties can be got by calling /gazebo/get_physics_properties service. Check that these values are equal than default one self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 150 self._ode_config.sor_pgs_w = 1.4 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.01 self._ode_config.contact_max_correcting_vel = 2000.0 self._ode_config.cfm = 1e-5 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20
def change_gravity(x, y, z): gravity = Vector3() gravity.x = x gravity.y = y gravity.z = z set_gravity = rospy.ServiceProxy('/gazebo/set_physics_properties', SetPhysicsProperties) set_gravity(physics().time_step, physics().max_update_rate, gravity, ODEPhysics())
def set_gazebo_physics(self): rospy.wait_for_service('/gazebo/set_physics_properties') set_physics = rospy.ServiceProxy('/gazebo/set_physics_properties', SetPhysicsProperties) time_step = 0.001 max_update_rate = self.real_time_factor * 1000 gravity = Vector3(0, 0, -9.8) #Args order = ['auto_disable_bodies', 'sor_pgs_precon_iters', 'sor_pgs_iters', 'sor_pgs_w', 'sor_pgs_rms_error_tol', 'contact_surface_layer', 'contact_max_correcting_vel', 'cfm', 'erp', 'max_contacts'] ode_config = ODEPhysics(False, 0, 50, 1.3, 0.0, 0.001, 100.0, 0.0, 0.2, 20) try: resp = set_physics(time_step, max_update_rate, gravity, ode_config) print("Physics Set :", resp.success) except rospy.ServiceException as exc: print("Service did not process request: " + str(exc))
class GravityControl(object): def __init__(self): self.unpause = rospy.ServiceProxy('/gazebo/unpause_physics', Empty) self.pause = rospy.ServiceProxy('/gazebo/pause_physics', Empty) self.reset_proxy = rospy.ServiceProxy('/gazebo/reset_simulation', Empty) service_name = '/gazebo/set_physics_properties' rospy.loginfo("Waiting for service " + str(service_name)) rospy.wait_for_service(service_name) rospy.loginfo("Service Found " + str(service_name)) self.set_physics = rospy.ServiceProxy(service_name, SetPhysicsProperties) self.init_values() def init_values(self): rospy.wait_for_service('/gazebo/reset_simulation') try: # reset_proxy.call() self.reset_proxy() except rospy.ServiceException, e: print ("/gazebo/reset_simulation service call failed") self._time_step = Float64(0.001) self._max_update_rate = Float64(1000.0) self._gravity = Vector3() self._gravity.x = 0.0 self._gravity.y = 0.0 self._gravity.z = 0.0 self._ode_config = ODEPhysics() self._ode_config.auto_disable_bodies = False self._ode_config.sor_pgs_precon_iters = 0 self._ode_config.sor_pgs_iters = 50 self._ode_config.sor_pgs_w = 1.3 self._ode_config.sor_pgs_rms_error_tol = 0.0 self._ode_config.contact_surface_layer = 0.001 self._ode_config.contact_max_correcting_vel = 0.0 self._ode_config.cfm = 0.0 self._ode_config.erp = 0.2 self._ode_config.max_contacts = 20 self.update_gravity_call()
rospy.loginfo("Waiting for service to be available...") rospy.wait_for_service('/gazebo/set_physics_properties') rospy.loginfo("Additional sleep...") rospy.sleep(wait_time) rospy.loginfo("Setting physics properties...") srv = rospy.ServiceProxy("/gazebo/set_physics_properties", SetPhysicsProperties) time_step = 0.001 max_update_rate = 1000.0 gravity = Vector3() gravity.x = 0 gravity.y = 0 gravity.z = 9.8 ode_config = ODEPhysics() ode_config.auto_disable_bodies = False ode_config.sor_pgs_precon_iters = 0 ode_config.sor_pgs_w = 1.3 ode_config.sor_pgs_rms_error_tol = 0.0 ode_config.contact_surface_layer = 0.001 ode_config.contact_max_correcting_vel = 100.0 ode_config.cfm = 0.0 ode_config.erp = 0.2 ode_config.max_contacts = 20 srv(time_step, max_update_rate, gravity, ode_config) all_points = [] # spin and write out a file
#!/usr/bin/env python from gazebo_msgs.msg import ODEPhysics from geometry_msgs.msg import Vector3 from gazebo_msgs.srv import SetPhysicsProperties from std_msgs.msg import Float64 import rospy set_gravity = rospy.ServiceProxy('/gazebo/set_physics_properties', SetPhysicsProperties) time_step = Float64(0.004) # default: 0.001 max_update_rate = Float64(250.0) # default: 1000.0 gravity = Vector3() gravity.x = 0.0 gravity.y = 0.0 gravity.z = -9.8 ode_config = ODEPhysics() ode_config.auto_disable_bodies = False ode_config.sor_pgs_precon_iters = 0 ode_config.sor_pgs_iters = 50 ode_config.sor_pgs_w = 1.3 ode_config.sor_pgs_rms_error_tol = 0.0 ode_config.contact_surface_layer = 0.001 ode_config.contact_max_correcting_vel = 50.0 # default: 100.0 ode_config.cfm = 0.0 ode_config.erp = 0.2 ode_config.max_contacts = 20 print "Changing gazebo properties." set_gravity(time_step.data, max_update_rate.data, gravity, ode_config)
import rospy from std_srvs.srv import Empty from gazebo_msgs.msg import ODEPhysics from gazebo_msgs.srv import SetPhysicsProperties, SetPhysicsPropertiesRequest from std_msgs.msg import Float64 from geometry_msgs.msg import Vector3 from simulation_handler import SimulationHandler GAZEBO_SERVICES_MAP = { 'reset': ['/gazebo/reset_world', Empty], 'pause': ['/gazebo/pause_physics', Empty], 'unpause': ['/gazebo/unpause_physics', Empty], 'set_physics': ['/gazebo/set_physics_properties', SetPhysicsProperties] } ODE_PHYSICS_DEFAULT = ODEPhysics() ODE_PHYSICS_DEFAULT.auto_disable_bodies = False ODE_PHYSICS_DEFAULT.sor_pgs_precon_iters = 0 ODE_PHYSICS_DEFAULT.sor_pgs_iters = 50 ODE_PHYSICS_DEFAULT.sor_pgs_w = 1.3 ODE_PHYSICS_DEFAULT.sor_pgs_rms_error_tol = 0.0 ODE_PHYSICS_DEFAULT.contact_surface_layer = 0.001 ODE_PHYSICS_DEFAULT.contact_max_correcting_vel = 0.0 ODE_PHYSICS_DEFAULT.cfm = 0.0 ODE_PHYSICS_DEFAULT.erp = 0.2 ODE_PHYSICS_DEFAULT.max_contacts = 20 class GazeboHandler(SimulationHandler): """ The simulation handler for performing pause, unpause, spawn, etc operations