Git Product home page Git Product logo

Comments (13)

cdfreeman-google avatar cdfreeman-google commented on May 3, 2024 11

Hello! This is actually something I'm putting together right now. It should land in the next couple of days, with similar feature coverage to our MuJoCo converter. I'll add a comment here when it's ready for action.

from brax.

cdfreeman-google avatar cdfreeman-google commented on May 3, 2024 3

Alright, we've just uploaded a VERY rudimentary URDF loader. Feel free to ping this thread with further feature requests.

We don't yet support objs, but I suspect we'll eventually get around to adding mesh colliders, which will make it a bit easier.

from brax.

 avatar commented on May 3, 2024

Will this include obj-support?

from brax.

flobotics avatar flobotics commented on May 3, 2024

@cdfreeman-google i tested the urdf_converter.py and it doesnt work with my urdf, because my config of a joint had another ordering. I put into https://github.com/google/brax/blob/main/brax/tools/urdf.py in the line 127 this code and then it worked with my urdf file.

for j in joint:
        if j.tag == "child":
            child = j.get('link')
            print(f"child-name >{child}<")
        if j.tag == "parent":
            parent = j.get('link')
            print(f"parent-name >{parent}<")
      
      #parent = joint[0].get('link')
      #child = joint[1].get('link')

hint for beginners:

Inside brax/tools you can run

python3 urdf_converter.py --help

And converting a urdf.xml file to brax config use:

python3 urdf_converter.py --xml_model_path=/home/ros2/Documents/myRobot.urdf.xml --config_path=/home/ros2/Documents/myRobot.txt

thanks for that tool

from brax.

flobotics avatar flobotics commented on May 3, 2024

i found out that it does not add capsule etc. to colliders{} . So i changed line 171 in https://github.com/google/brax/blob/main/brax/tools/urdf.py to

#colliders = self.links[node].findall('collision')
    colliders = self.links[node]

from brax.

flobotics avatar flobotics commented on May 3, 2024

i got it, it uses the geometry inside the collision elements, my problem was i only got visual elements in my urdf file.

So to add "something" to see in brax, you need to specify collision with geometry elements inside your urdf.

from brax.

cdfreeman-google avatar cdfreeman-google commented on May 3, 2024

Ah yes, we don't have a difference between visuals and colliders, where urdf lets you set each separately. To be safe, I parsed the collider element because that's what matters most for simulation fidelity.

from brax.

plancherb1 avatar plancherb1 commented on May 3, 2024

Quick question -- is it possible to provide a state/velocity in minimal coordinates (aka joint angles and velocities)?

Also any idea why after importing a URDF the default position/velocity seems to be NaNs? Some code below:

# import URDF
URDF_FILE_DATA = files.upload()
brax_urdf_obj = urdf.UrdfConverter(list(URDF_FILE_DATA.values())[0], add_collision_pairs=False)
# set up CONFIG
_CONFIG = brax_urdf_obj.config
_CONFIG.bodies[0].frozen.all = True # fixed base
_CONFIG.gravity.z = -9.8 # set gravity
_CONFIG.collide_include.add() # ignore collisions
# set simulation config params
_CONFIG.dt = 0.1
_CONFIG.substeps: 10
# construct a system
sys = brax.System(_CONFIG)
qp = sys.default_qp() # THIS PRODUCES NaNs
# simulate
qp, _ = sys.step(qp, []) # GET A DIVIDE BY ZERO ERROR

from brax.

erwincoumans avatar erwincoumans commented on May 3, 2024

is it possible to provide a state/velocity in minimal coordinates (aka joint angles and velocities)?

Yes, you can use default angles in the config file. For example:


defaults {
  qps {
    name: "chassis"
    pos {
      x: 0, z: 2.5
    }
  }
  
} 
defaults { 
  angles { 
    name: "RL_lower_leg_2_upper_leg_joint" 
    angle: { x: -35 } 
  } 
  angles { 
    name: "RR_lower_leg_2_upper_leg_joint" 
    angle: { x: -35 } 
  } 
  angles { 
    name: "FL_lower_leg_2_upper_leg_joint" 
    angle: { x: -35 } 
  } 
  angles { 
    name: "FR_lower_leg_2_upper_leg_joint" 
    angle: { x: -35 } 
  } 

  
  }

from brax.

 avatar commented on May 3, 2024

Hi, is obj import functioning now? Regards

from brax.

limbryan avatar limbryan commented on May 3, 2024

Hi, was experimenting with the URDF converter. When converting box shapes for the collisions, the URDF format seems to specify the full dimensions of the box (http://wiki.ros.org/urdf/XML/link), while the brax config uses halfsize for the box shapes. I added a /2 to line 99 of the code as follows to fix this and tested that it comes up correctly rather than the original code for the converter:

return config_pb2.Collider(
      box=config_pb2.Collider.Box(halfsize=_vec(size/2)),
      rotation=_vec(euler.quat2euler(rot, 'rxyz'), scale=180 / np.pi),
      position=_vec(pos))

from brax.

cdfreeman-google avatar cdfreeman-google commented on May 3, 2024

@limbryan great catch! Should be fixed in the next push we make.

from brax.

erwincoumans avatar erwincoumans commented on May 3, 2024

Since we have basic URDF conversion in Brax, closing for now. If there are specific features missing, please create a new issue (and attach zipped urdf file etc).

from brax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.