Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hummer robot body axis alignment and scale usage #819

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified data/robots/hummer.blend
Binary file not shown.
34 changes: 18 additions & 16 deletions src/morse/robots/hummer.py
Expand Up @@ -24,6 +24,8 @@ class Hummer(morse.core.robot.Robot):
affects steering wheel's ability to turn the vehicle.\
A value of ``0`` gives very low acceleration. Higher \
values permit a higher acceleration. ")
add_property('scale', 1.0, 'scale', 'double',
"pass scale of the robot to have correct wheel locations")

def __init__(self, obj, parent=None):
# Call the constructor of the parent class
Expand Down Expand Up @@ -54,9 +56,9 @@ def __init__(self, obj, parent=None):
self.vehicle = PhysicsConstraints.getVehicleConstraint(obj['cid'])

# Wheel location from vehicle center
wx = 1.3
wy = 1.6
wz = -.5
wx = 1.6 * self.scale
wy = 1.3 * self.scale
wz = -.5 * self.scale

#wheelAttachDirLocal:
#Direction the suspension is pointing
Expand All @@ -65,18 +67,18 @@ def __init__(self, obj, parent=None):
#wheelAxleLocal:
#Determines the rotational angle where the
#wheel is mounted.
wheelAxleLocal = [-1, 0, 0]
wheelAxleLocal = [0, 1, 0]

#suspensionRestLength:
#The length of the suspension when it's fully
#extended:
suspensionRestLength = .3
suspensionRestLength = .3 * self.scale

#wheelRadius:
#Radius of the Physics Wheel.
#Turn on Game:Show Physics Visualization to see
#a purple line representing the wheel radius.
wheelRadius = .5
wheelRadius = .5 * self.scale

#hasSteering:
#Determines whether or not the coming wheel
Expand All @@ -94,15 +96,15 @@ def __init__(self, obj, parent=None):
#on the vehicle's Center
wheelAttachPosLocal = [wx, wy, wz]

#creates the first wheel using all of the variables
#creates the first (left) wheel using all of the variables
#created above:
self.vehicle.addWheel(wheel1, wheelAttachPosLocal, wheelAttachDirLocal,
wheelAxleLocal, suspensionRestLength,
wheelRadius, hasSteering)

#Positions this wheel on the opposite side of the car by using a
#Positions this wheel (right) on the opposite side of the car by using a
#negative values for the x position.
wheelAttachPosLocal = [-wx, wy, wz]
wheelAttachPosLocal = [wx, -wy, wz]

#creates the second wheel:
self.vehicle.addWheel(wheel2, wheelAttachPosLocal, wheelAttachDirLocal,
Expand All @@ -118,19 +120,19 @@ def __init__(self, obj, parent=None):
hasSteering = 0

# Adjust the location the rear wheels are attached.
wx = 1.3
wy = 2.3
wx = 2.3 * self.scale
wy = 1.3 * self.scale

# Set the wheelAttachPosLocal to the new location for rear wheels:
# -y moves the position toward the back of the car
wheelAttachPosLocal = [wx, -wy, wz]
wheelAttachPosLocal = [-wx, wy, wz]

#Creates the 3rd wheel (first rear wheel)
#Creates the 3rd wheel (first/left rear wheel)
self.vehicle.addWheel(wheel3, wheelAttachPosLocal, wheelAttachDirLocal,
wheelAxleLocal, suspensionRestLength,
wheelRadius, hasSteering)

#Adjust the attach position for the next wheel:
#Adjust the attach position for the next/right wheel:
# changed to -x to place the wheel on the opposite side of the car
# the same distance away from the vehicle's center
wheelAttachPosLocal = [-wx, -wy, wz]
Expand All @@ -140,7 +142,7 @@ def __init__(self, obj, parent=None):
wheelAxleLocal, suspensionRestLength,
wheelRadius, hasSteering)

#The Rolling Influence:
#The Rolling Influence:
#How easy it will be for the vehicle to roll over while turning:
#0 = Little to no rolling over
# .1 and higher easier to roll over
Expand Down Expand Up @@ -205,4 +207,4 @@ def default_action(self):
# This section runs continuously after the initial set up:
# Updating Speed, Friction, Braking, Suspension, etc:
#
pass
pass