Skip to content

Commit

Permalink
[core/wheeled_robot] Don't attach caster_wheel in "get_wheels"
Browse files Browse the repository at this point in the history
It makes no sense at all from a semantic point of view. Attach it in the
build_vehicle method ...
  • Loading branch information
Arnaud Degroote committed Feb 11, 2016
1 parent 0145280 commit 708f8dd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/morse/core/wheeled_robot.py
Expand Up @@ -84,11 +84,6 @@ def get_wheels(self):

logger.debug("get_wheels %s" % self._wheels)

# Add a free rotating wheel if indicated in the robot
if caster_wheel_name and caster_wheel_name != 'None':
wheel = scene.objects[caster_wheel_name]
wheel_position = mathutils.Vector(wheel.worldPosition)
self.attach_wheel_to_body(wheel, self.bge_object, wheel_position)

def get_track_width(self):
# get lateral positions of the wheels
Expand Down Expand Up @@ -208,13 +203,19 @@ def build_model_without_suspension(self):
self._wheels[index], self.bge_object,
self._wheel_positions[index])

# Add a free rotating wheel if indicated in the robot
scene = blenderapi.scene()
caster_wheel_name = self.bge_object.get('CasterWheelName', None)
if caster_wheel_name and caster_wheel_name != 'None':
wheel = scene.objects[caster_wheel_name]
self.attach_wheel_to_body(wheel, self.bge_object, wheel.worldPosition)

def attach_wheel_to_body(self, wheel, parent, wheel_pos):
""" Attaches the wheel to the given parent using a 6DOF constraint
Set the wheel positions relative to the robot in case the
chassis was moved by the builder script or manually in blender
"""

result = parent.getVectTo(wheel)
## result is a unit vector (result[2]) and a length(result[0])
## multiply them together to get the complete vector
Expand Down

0 comments on commit 708f8dd

Please sign in to comment.