Archive

Posts Tagged ‘XML’

Robot modelling formats for simulation

Several XML-based formats have surfaced over the years that can be used to describe a robot.

Apart from URDF (and SRDF) of ROS origin, the Gazebo simulator has been promoting SDF (an evolution of URDF with emphasis on physics simulation), while MJCF apart from being available as URDF extensions, also has its own format with an XML schema for validation and more advanced simulation features (e.g. tendons).

URDF (ROS)

http://wiki.ros.org/urdf

http://wiki.ros.org/urdf/XML

http://wiki.ros.org/urdf/XML/joint

http://wiki.ros.org/urdf/XML/link

Also related, units of measurement in ROS: http://www.ros.org/reps/rep-0103.html

SRDF format http://wiki.ros.org/srdf that is mentioned at http://wiki.ros.org/robot_model is also related (adds Semantics like kinematic chain definition etc). As explained there it is combined with URDF in describing a robot:

This does not replace URDF, and is not an extension of URDF.

This is a format for representing semantic information about the robot structure.

A URDF file must exist for this robot as well, where the joints and the links that are referenced are defined

SDF (Gazebo)

http://gazebosim.org/tutorials?tut=build_model

http://sdformat.org
http://sdformat.org/spec

https://bitbucket.org/osrf/gazebo_models/src (various SDF models in XML)

http://gazebosim.org/tutorials/?tut=ros_urdf (Converting from URDF to Gazebo)

http://gazebosim.org/tutorials?tut=simple_gripper (tutorial for simple gripper in SDF)

Gazebo seems to be using ODE (Open Dynamics Engine), so these are related too:

http://www.ode.org/ode-latest-userguide.html#sec_7_3_0 (see images for Joint types)

http://www.ode.org/ode-latest-userguide.html#sec_3_6_0 (ERP & CFM constraint parameters)

MJCF (MuJoCo)

http://www.mujoco.org/ (MuJoCo 1.50 was released on April 23, 2017. Student licenses are now free)

http://www.mujoco.org/book/

http://www.mujoco.org/book/modeling.html

http://www.mujoco.org/book/modeling.html#CURDF (MJCF is an advanced format but some of its functionality is also available as URDF extensions)

http://www.mujoco.org/book/computation.html#Constraint (MuJoCo has constraints like Connect/Weld/Joint/Tendon/Distance)

https://homes.cs.washington.edu/~todorov/papers/TodorovIROS12.pdf (see paragraph «B. Elements of a MuJoCo model»)

URDF to MJCF conversion is possible (related sample available for MuJoCo):

http://www.mujoco.org/forum/index.php?threads/urdf-mjcf-conversion.3429/

There is ongoing work at Bullet Physics engine to import MJCF, as mentioned at:

https://github.com/bulletphysics/bullet3/releases

Thus, they have collected various MJCF models (XML):

https://github.com/bulletphysics/bullet3/tree/master/data/mjcf

Advertisements

HowTo: format XML output of DataContractSerializer

based on the other samples posted at StackOverflow on how to format XML created by DataContractSerializer, that use XmlWriter, here’s a version (from ClipFlair source code) that works with streams (and Ionic.Zip library in specific).

It also shows how the code is when you don’t apply formatting (using conditional compilation).  Just comment out the #define (prefix it with //) to make it write unformatted XML.

 

#define WRITE_FORMATTED_XML

using System.Xml;

namespace ClipFlair.Windows
{

  public partial class BaseWindow : FloatingWindow
  {

    //...

    #if WRITE_FORMATTED_XML
    private static XmlWriterSettings XML_WRITER_SETTINGS = 
new XmlWriterSettings() { Indent=true, IndentChars=" "}; #endif //... public virtual void SaveOptions(ZipFile zip, string zipFolder = "")
//THIS IS THE CORE SAVING LOGIC { if (SavingOptions != null) SavingOptions(this, null); //notify any listeners View.Busy = true; try { ZipEntry optionsXML =
zip.AddEntry(zipFolder + "/" + View.GetType().FullName + ".options.xml", new WriteDelegate((entryName, stream) => { DataContractSerializer serializer =
new DataContractSerializer(View.GetType());
//assuming current View isn't null #if WRITE_FORMATTED_XML using (XmlWriter writer = XmlWriter.Create(stream, XML_WRITER_SETTINGS)) serializer.WriteObject(writer, View); #else serializer.WriteObject(stream, View); #endif })); } catch (Exception e) { MessageBox.Show("ClipFlair options save failed: " + e.Message); } finally { View.Busy = false; //in any case (error or not) clear the Busy flag } if (SavedOptions != null) SavedOptions(this, null); //notify any listeners } //... } }

Fix: The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’

I just had some big trouble troubleshooting the Visual Studio / XAML compiler error message:

The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’

It turned out this occurred because I had a Silverlight library with Assembly name X and default namespace X (at properties pane), but was using it from a demo project with Assembly name X (again!) and default namespace X.

If I removed the ";assembly=X" part from the XAML it worked fine, that is:

xmlns:my="clr-namespace:X"

Fixing the demo project to use Assembly name X.Demo and default namespace X.Demo (at its Properties pane), instead of having the same assembly name, now allows me to also use

xmlns:my="clr-namespace:X;assembly=X"

without problem.

Seems that when you have multiple assemblies with the same name in a project (wonder how the filesystem supports that), all of them are loaded fine and if they have classes with namespace X in them, the namespace gets classes from both assemblies (that’s why the xmlns without assembly=… works). When you specify assembly name in the XAML of a given project, it assumes you mean its own assembly, not any other referenced one with the same name.

BTW, at add references dialog I was using Projects option (to reference the output of other project in solution) and the project I was referencing was named X.Silverlight (can be named anything), I had not added reference the X assembly .dll file directly. Maybe that played its part too in the issue.

There may be other cases too that can cause this error to fire up, see:

http://social.msdn.microsoft.com/Forums/en/wpf/thread/56f933c8-a093-4c47-8e1a-cde4bb1864e9

%d bloggers like this: