PyBullet 실습 이어서~

pybullet_simplecar.py


# venv가 activate된 상태에서
$ cd SpotMicroJetson/Simulation/pybullet_tutorial

$ pip install pybullet

$ python pybullet_simplecar.py

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a375f67b-a751-4334-842b-39caec0e8cf7/Untitled.png

Road-Balance/SpotMicroJetson

Revolute joint

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2b8ea54f-a5b7-4fa8-b0d0-e154ccaead7d/Untitled.png

car = p.loadURDF('simplecar.urdf', [0, 0, 0.1])
number_of_joints = p.getNumJoints(car)
for joint_number in range(number_of_joints):
    # This prints out all the information returned by getJointInfo().
    # Try it out
    info = p.getJointInfo(car, joint_number)
    print(info[0], ": ", info[1])

plane = p.loadURDF('plane.urdf')

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a375f67b-a751-4334-842b-39caec0e8cf7/Untitled.png

wheel_indices = [1, 3, 4, 5]
hinge_indices = [0, 2]

while True:
    user_angle = p.readUserDebugParameter(angle)
    user_throttle = p.readUserDebugParameter(throttle)
    for joint_index in wheel_indices:
        # This allows us to change the velocity, position, 
        # or apply a torque to a joint. 
        # This is the main method used to control robots. 
        # It takes both a robot ID and a joint ID
        p.setJointMotorControl2(car, joint_index,
                                p.VELOCITY_CONTROL,
                                targetVelocity=user_throttle)
    for joint_index in hinge_indices:
        p.setJointMotorControl2(car, joint_index,
                                p.POSITION_CONTROL, 
                                targetPosition=user_angle)
    p.stepSimulation()

p.disconnect(physicsClient)

추가 자료

How to create new environments for Gym

openai/gym

PyBullet Quickstart Guide

spotmicroai.py 간단 리뷰