Commit 7b359e48 authored by Séverin Lemaignan's avatar Séverin Lemaignan
Browse files

WIP on the example script

parent 7e0801f6
#! /usr/bin/env morseexec
""" Basic MORSE simulation scene for <robopilot-sim> environment
Feel free to edit this template as you like!
""" Early prototype of a MORSE-based simulation for ROBOPILOT
"""
from morse.builder import *
from robopilotsim.builder.robots import Van, Vehicle
from robopilotsim.builder.actuators import Pathfollower
# add a new van robot in the simulation
# add a new ROBOPILOT van robot in the simulation
# the Van type (and sensors & actuators) is defined in src/builder/robots/van.py
van = Van()
# The list of the main methods to manipulate your components
# is here: http://www.openrobots.org/morse/doc/stable/user/builder_overview.html
van.translate(-28.0, -48.0, 0.0)
van.rotate(0.0, 0.0, 3.5)
# Add a motion controller
# Check here the other available actuators:
# http://www.openrobots.org/morse/doc/stable/components_library.html#actuators
#
# 'morse add actuator <name> robopilot-sim' can help you with the creation of a custom
# actuator.
motion = MotionVW()
van.append(motion)
bike=Vehicle(type="bike")
bike.translate(-55.308, -53.882, 0.03)
car=Vehicle(type="car")
car.translate(-58.85, -48.627, 0.03)
# create a new pathfollower actuator
#pathfollower = Pathfollower()
#pathfollower.properties(Path="path1")
#van.append(pathfollower)
### Add other objects in the simulation
# the type 'Vehicle' is specific to this simulation. See src/builder/robots/vehicle.py
bike=Vehicle(type="bike", color=(0.9,0.2,0))
bike.translate(-103.02, -48.03, 0.0)
bike.rotate(0, 0, -0.3)
# Add a keyboard controller to move the robot with arrow keys.
keyboard = Keyboard()
van.append(keyboard)
keyboard.properties(ControlType = 'Position')
car1=Vehicle(type="car", color=(0.3,0.4,0.1))
car1.translate(-58.85, -48.627, 0.0)
car1.rotate(0, 0, -3.1)
pose = Pose()
van.append(pose)
car2=Vehicle(type="car", color=(0.,0.4,0.7))
car2.translate(-54.68, -38.574, 0.0)
car2.rotate(0, 0, -1.38)
van.add_default_interface('socket')
## !! Controllers (ie, 'agents') for these vehicles are found in scripts/
## these controllers are in effect external clients to the simulator.
### Configure the general simulation environment
env = Environment('data/robopilotsim/env/bristol.blend', fastmode = False)
env.set_camera_location([-12.7, -27.6, 205.2])
env.set_camera_rotation([0, 0, 0])
#env.set_camera_location([32.7, -38.4, 27.7])
#env.set_camera_rotation([1.24, 0, 1.73])
env.set_camera_location([32.7, -38.4, 27.7])
env.set_camera_rotation([1.24, 0, 1.73])
env.set_camera_clip(0.5,600)
env.set_camera_focal_length(20) #mm
env.set_camera_speed(10)
env.set_camera_speed(50)
env.set_material_mode("MULTITEXTURE")
env.set_viewport("SOLID")
env.fullscreen()
......@@ -31,6 +31,18 @@ class Van(GroundRobot):
# Sensors
###################################
self.camera = SemanticCamera()
self.camera.translate(1.55, 0, 1.53)
self.camera.rotate(0,0,0)
self.camera.properties(relative=True) # returns the coordinates of seen objects in the camera's frame
self.camera.properties(cam_far=100) # max visibility distance
self.append(self.camera)
self.pose = Pose()
self.append(self.pose)
####################################
## For prototyping purposes, use sockets.
# ros, yarp, text-based logging... are also available
van.add_default_interface('socket')
......@@ -4,37 +4,35 @@ class Vehicle(GroundRobot):
"""
Vehicles (cars, bikes) to animate the simulated environment
"""
def __init__(self,type="car", color=(0.2, 0.5, 0.6), name = None, debug = True):
def __init__(self,type, color=(0.2, 0.5, 0.6), name = None, debug = False):
# vehicle.blend is located in the data/robots directory
GroundRobot.__init__(self, filename='data/robopilotsim/props/%s.blend' % type,
name=name)
self.properties(classpath = "robopilotsim.robots.vehicle.Vehicle")
self.properties(Object=True) # mark these entities as 'Objects', ie, visible entities for the semantic camera
###################################
# Actuators
###################################
# (v,w) motion controller
# Check here the other available actuators:
# http://www.openrobots.org/morse/doc/stable/components_library.html#actuators
self.motion = Waypoint()
self.motion.properties(ControlType="Position", ObstacleAvoidance=False)
self.append(self.motion)
# Optionally allow to move the robot with the keyboard
if debug:
keyboard = Keyboard()
keyboard.properties(ControlType = 'Position')
self.append(keyboard)
#self.teleport = Teleport()
#self.append(self.teleport)
# WIP on a 'pathfollower' actuator that would make a vehicle simply follows an arbitrary Blender path
#pathfollower = Pathfollower()
#pathfollower.properties(Path="path1")
#van.append(pathfollower)
###################################
# Sensors
###################################
self.pose = Pose()
self.append(self.pose)
#self.pose = Pose()
#self.append(self.pose)
self.add_default_interface('socket')
### Change the main color of the mesh, by accessing Blender's materials
mesh_obj = None
for c in self._bpy_object.children:
if c.name.endswith("_mesh"):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment