Add head and test head rotation

This commit is contained in:
Aditya Vasantharao 2021-01-29 19:44:20 -05:00
parent af30bade76
commit cb4313a237
3 changed files with 39 additions and 37 deletions

View File

@ -4,29 +4,25 @@
# from controller import Robot, Motor, DistanceSensor
from controller import Robot
# create the Robot instance.
robot = Robot()
# get the time step of the current world.
timestep = int(robot.getBasicTimeStep())
def main():
# create the Robot instance.
print("Initializing world...")
robot = Robot()
# You should insert a getDevice-like function in order to get the
# instance of a device of the robot. Something like:
# motor = robot.getMotor('motorname')
# ds = robot.getDistanceSensor('dsname')
# ds.enable(timestep)
head_motor = robot.getDevice("neck_pitch")
head_motor.setVelocity(1)
# Main loop:
# - perform simulation steps until Webots is stopping the controller
while robot.step(timestep) != -1:
# Read the sensors:
# Enter here functions to read sensor data, like:
# val = ds.getValue()
# get the time step of the current world.
timestep = int(robot.getBasicTimeStep())
# Process sensor data here.
# Main loop:
# - perform simulation steps until Webots is stopping the controller
while robot.step(timestep) != -1:
head_motor.setPosition(6)
# Enter here functions to send actuator commands, like:
# motor.setPosition(10.0)
pass
# Enter here exit cleanup code.
# Enter here exit cleanup code.
if __name__ == '__main__':
main()

View File

@ -1,9 +1,9 @@
Webots Project File version R2021a
perspectives: 000000ff00000000fd00000003000000000000000000000000fc0100000002fc00000000ffffffff0000000000fffffffc0200000001fb00000012005300630065006e0065005400720065006501000000000000039f0000000000000000fb0000001a0044006f00630075006d0065006e0074006100740069006f006e0000000000ffffffff0000006900ffffff000000010000023a00000395fc0200000001fb0000001400540065007800740045006400690074006f00720100000015000003950000004100ffffff000000030000078000000039fc0100000002fb0000000e0043006f006e0073006f006c00650100000000000007400000000000000000fb0000001a0043006f006e0073006f006c00650041006c006c0041006c006c0100000000000007800000006900ffffff000005440000039500000004000000040000000100000008fc00000000
simulationViewPerspectives: 000000ff00000001000000020000016c000004a00100000002010000000101
sceneTreePerspectives: 000000ff0000000100000002000000c0000001120100000002010000000201
perspectives: 000000ff00000000fd00000003000000000000000000000000fc0100000002fc00000000ffffffff0000000000fffffffc0200000001fb00000012005300630065006e0065005400720065006501000000000000039f0000000000000000fb0000001a0044006f00630075006d0065006e0074006100740069006f006e0000000000ffffffff0000006900ffffff000000010000023a000003b6fc0200000002fb0000001400540065007800740045006400690074006f0072010000001a0000023d0000008700fffffffb0000001a0043006f006e0073006f006c00650041006c006c0041006c006c0100000259000001770000003900ffffff0000000300000780000001e8fc0100000001fb0000000e0043006f006e0073006f006c0065010000000000000740000000000000000000000544000003b600000004000000040000000100000008fc00000000
simulationViewPerspectives: 000000ff00000001000000020000016c000003d60100000002010000000101
sceneTreePerspectives: 000000ff0000000100000002000000c0000000fa0100000002010000000201
maximizedDockId: -1
centralWidgetVisible: 1
orthographicViewHeight: 1
textFiles: -1
textFiles: 0 "controllers/olympian/olympian.py"
consoles: Console:All:All

View File

@ -3,8 +3,8 @@ WorldInfo {
coordinateSystem "NUE"
}
Viewpoint {
orientation -0.7623894855422976 0.6273329238621066 0.1587944425134923 0.327301231606098
position 1.0070228999748558 2.3086338771870616 3.1708017471662577
orientation -0.7241113403564003 0.6708542148873753 0.16005433182235554 0.3286771770738909
position 0.9187932527597619 1.807787251982618 3.3212186235849788
}
TexturedBackground {
}
@ -32,9 +32,10 @@ Robot {
}
BallJoint {
jointParameters BallJointParameters {
anchor 0 1.77 0
anchor 0 1.775 0
}
jointParameters2 JointParameters {
axis 1 0 0
}
jointParameters3 JointParameters {
}
@ -56,19 +57,22 @@ Robot {
}
]
endPoint Solid {
translation 0 1.77 0
translation 0 1.775 0
children [
Shape {
DEF head Shape {
appearance PBRAppearance {
roughness 1
metalness 0
}
geometry Cylinder {
height 0.25
radius 0.2
geometry Sphere {
radius 0.125
}
}
]
name "solid(2)"
boundingObject USE head
physics Physics {
}
}
}
HingeJoint {
@ -102,6 +106,7 @@ Robot {
}
HingeJoint {
jointParameters HingeJointParameters {
axis 0 0 1
anchor -0.375 1.55 0
}
device [
@ -125,4 +130,5 @@ Robot {
boundingObject USE Body
physics Physics {
}
controller "olympian"
}