def robot_to_sdf(robot, name="test_bot", plugin_controller=None): model = builder.sdf_robot(robot=robot, controller_plugin=plugin_controller, update_rate=UPDATE_RATE, name=name) model_sdf = SDF() model_sdf.add_element(model) return model_sdf
def robot_to_sdf(robot, name="test_bot", plugin_controller=None): model = builder.sdf_robot( robot=robot, controller_plugin=plugin_controller, update_rate=UPDATE_RATE, name=name) model_sdf = SDF() model_sdf.add_element(model) return model_sdf
def get_analysis_robot(robot, builder): """ Creates an SDF model suitable for analysis from a robot object and a builder. :param robot: :type robot: Robot :param builder: :type builder: BodyBuilder :return: """ model = builder.sdf_robot(robot=robot, controller_plugin=None, name="analyze_bot", analyzer_mode=True) model.remove_elements_of_type(Sensor, recursive=True) sdf = SDF() sdf.add_element(model) return sdf
def get_analysis_robot(robot, builder): """ Creates an SDF model suitable for analysis from a robot object and a builder. :param robot: :type robot: Robot :param builder: :type builder: BodyBuilder :return: """ model = builder.sdf_robot( robot=robot, controller_plugin=None, name="analyze_bot", analyzer_mode=True) model.remove_elements_of_type(Sensor, recursive=True) sdf = SDF() sdf.add_element(model) return sdf
def to_sdfbot(robot, name, builder, conf, battery_charge=None): """ :param robot: :param name: :param builder: :param conf: Config :param battery_charge: :return: """ battery = None if battery_charge is None else BasicBattery(battery_charge) brain_conf = None if not hasattr(conf, 'brain_conf') else conf.brain_conf model = builder.sdf_robot(robot=robot, controller_plugin="libRobotControlPlugin.so", update_rate=conf.controller_update_rate, name=name, battery=battery, brain_conf=brain_conf) apply_surface_parameters(model, conf.world_step_size) sdf = SDF() sdf.add_element(model) return sdf
async def run(): world = await World.create() if world: print("Connected to the simulator world.") model = Model( name='sdf_model', static=True, ) model.set_position(position=Vector3(0, 0, 1)) link = Link('sdf_link') link.make_sphere( mass=10e10, radius=0.5, ) link.make_color(0.7, 0.2, 0.0, 1.0) model.add_element(link) sdf_model = SDF(elements=[model]) await world.insert_model(sdf_model) await world.pause(True) while True: await asyncio.sleep(10.0)
id: Wheel type: Wheel params: red: 0.0 green: 1.0 blue: 0.0 5: id: Wheel2 type: Wheel params: red: 0.0 green: 1.0 blue: 0.0 brain: params: Wheel-out-0: type: Oscillator period: 3 Wheel2-out-0: type: Oscillator period: 3 ''' bot = yaml_to_proto(body_spec, brain_spec, bot_yaml) builder = RobotBuilder(BodyBuilder(body_spec), NeuralNetBuilder(brain_spec)) model = builder.sdf_robot(bot, "libRobotControlPlugin.so") model.translate(Vector3(0, 0, 0.5)) sdf = SDF() sdf.add_element(model) logger.info(str(sdf))
id: Wheel type: Wheel params: red: 0.0 green: 1.0 blue: 0.0 5: id: Wheel2 type: Wheel params: red: 0.0 green: 1.0 blue: 0.0 brain: params: Wheel-out-0: type: Oscillator period: 3 Wheel2-out-0: type: Oscillator period: 3 ''' bot = yaml_to_proto(body_spec, brain_spec, bot_yaml) builder = RobotBuilder(BodyBuilder(body_spec), NeuralNetBuilder(brain_spec)) model = builder.sdf_robot(bot, "libRobotControlPlugin.so") model.translate(Vector3(0, 0, 0.5)) sdf = SDF() sdf.add_element(model) print(str(sdf))
friction=0.01, friction2=0.01, slip1=1.0, slip2=1.0 ) contact = "<contact>" \ "<ode>" \ "<kd>%s</kd>" \ "<kp>%s</kp>" \ "</ode>" \ "</contact>" % ( nf(constants.SURFACE_KD), nf(constants.SURFACE_KP) ) surf.add_element(friction) surf.add_element(contact) col.add_element(surf) vis = Visual("bc_vis", mesh.copy()) self.link = Link("bc_link", elements=[col, vis]) # By default the model has 0.5 * scale * MESH_HEIGHT below # and above the surface. Translate such that we have exactly # the desired height instead. self.link.translate(Vector3(0, 0, self.height - (0.5 * scaled_height))) self.add_element(self.link) if __name__ == '__main__': sdf = SDF(elements=[BirthClinic()]) logger.info(sdf)