How to use ROS urdf package in Drake? - drake

I'm new to Drake.And I want to use my robot model which is a ROS urdf package converted from SolidWorks plugin.I've tried to use
builder = DiagramBuilder()
plant, scene_graph = AddMultibodySceneGraph(builder,0.0)
parser = Parser(plant)
pkg_map = parser.package_map()
pkg_map.AddPackageXml("myxmlfilepath")
robot_file = "my_urdf_file_path"
robot = parser.AddModelFromFile(robot_file, "robot")
But I got an errorRuntimeError:The WaveFront obj file has no faces in the last line.I try to use ROS to display and it works well. My urdf file has some .stl format mesh file for visual and collision. I see some comments here, so I guess Drake maybe can't deal with .stl in a default way so far.What should I do except manually converting .stl mesh file to .obj file? Thanks in Advance.

As you noted in your comment above, once you converted your STL file to an OBJ file, you were able to load your URDF file.
This is because Drake does not yet support loading STL (or DAE) meshes at runtime; they must be converted (either manually as you had done, or via the build system). For more info, please see:
https://github.com/RobotLocomotion/drake/issues/2941
In that issue, I've referenced your post as a motivator towards adding additional mesh support.
Thanks!

Related

retrieve_pdb_file from Bio.PDB.PDBList creates .ent files, not .pdb

I'm using Biopython to load structures into my code. I then change them into poses, via PyRosetta, because I want to align my theo structure to the PDB website structures. This is my code:
pdbl = PDBList()
native_pdb = pdbl.retrieve_pdb_file('%s' %protein, pdir='/my/directory/path/test_natives', file_format='pdb')
native_pose = pose_from_pdb(native_pdb)
but the retrieve_pdb_file creates .ent files and not pdb files. how do I fix this?
OR how do I load the known PDB structures in order to align them to theo structures and find the rmsd?
If PyRosetta only accepts files with the .pdb extension, simple renaming should do:
from pathlib import Path
native_pose = Path(native_pose)
native_pose.rename(native_pose.with_suffix('.pdb'))

How do I put custom image on 3D Sphere in ARCore

The following is my code for building a 3D Earth and showing it:
com.google.ar.sceneform.rendering.Texture.Builder builder= com.google.ar.sceneform.rendering.Texture.builder();
builder.setSource(context,R.drawable.earth);
builder.build().thenAccept(texture ->
MaterialFactory.makeOpaqueWithTexture(context, texture).
thenAccept(material -> {
earthSphereRenderable =
ShapeFactory.makeSphere(0.1f, new Vector3(0.0f, 0.0f, 0.0f), material);
Toast.makeText(context,"All done",Toast.LENGTH_SHORT).show();})
);
The Toast message is coming but I am not able to see any object. Please note that R.drawable.earth is the Earth.jpg file that I put in there, which I want to show in AR.
Here is where I am rendering it
cornerNode = new Node();
cornerNode.setParent(this);
cornerNode.setLocalPosition(localPosition);
cornerNode.setRenderable(earthSphereRenderable);
Moreover, if I replace makeOpaqueWithTexture with makeOpaqueWithColor and but color as Red then the whole thing is working fine (i.e. I can see the sphere)
What must I change here in order to be able to see the sphere with Earth's texture on it?
At this time Google Sceneform 1.8 supports 3D assets in the following formats: .obj, .glTF for which animations not supported) and .fbx with or without animations. Supported textures' formats are: .mtl, .bin, .png and .jpg.
To import a new 3D asset with textures follow these steps:
Verify that your project's app folder contains a sampledata folder. To create the folder, right-click on the app folder in the Project window, then select New > Sample Data Directory.
The sampledata folder is part of your Android Studio project, but its contents will not be included in your APK. Copy your 3D model source asset file (.obj, .fbx, or .gltf), and all of its dependencies in any of the following formats:
.mtl
.bin
.png
.jpg
into the sampledata folder.
Do not copy these source files into your project's assets or res folder, as this will cause them to be included in your APK unnecessarily. Right click the 3D model source asset and select Import Sceneform Asset to begin the import process.
The values are used by the sceneform.asset() entry in the app's build.gradle, and determine where the .sfa and .sfb – ascii and binary asset definition – files (as well as their corresponding texture files .sfm) will be generated in your project. If you're importing a model for the first time, use the default values.
Hope this helps.
Ok, I got the answer to this. It does not accept jpg files but it accepts png files. Weird stuff!

read haar cascade in distribute mode in hadoop

I am using OpenCV library for image detection in Hadoop using Spark framework.
I am able to run the spark program in local mode where Haar file is present in local file system.
But I am getting null pointer error for reading the Haar file in distributed mode Although I have copied haar file in all the cluster nodes and provided the absolute path in the code.
String fileloc ="/home/centos/haarcascade_frontalface_alt.xml"
CascadeClassifier faceDetector = new CascadeClassifier(fileloc);
Error:
Caused by: java.lang.NullPointerException
at javax.xml.bind.DatatypeConverterImpl.guessLength(DatatypeConverterImpl.java:658)
at javax.xml.bind.DatatypeConverterImpl._parseBase64Binary(DatatypeConverterImpl.java:696)
at javax.xml.bind.DatatypeConverterImpl.parseBase64Binary(DatatypeConverterImpl.java:438)
at javax.xml.bind.DatatypeConverter.parseBase64Binary(DatatypeConverter.java:342)
at com.lb.customlogic.impl.CustomLogicImpl.process(CustomLogicImpl.java:82)
... 20 more
I have tried with prefix extensions file://, file:/ and file:/// but those are not working out for me.
Do I need to add anything extra in the prefix to get the file read during execution of the program ?
Since Opencv has no support for Hadoop, I think I can't provide the HDFS shared location path for haar file.
This issue is resolved after adding --files parameter in spark-submit.
haar file is distributed across all the nodes. we just need to provide file name in source code:
String fileloc ="haarcascade_frontalface_alt.xml"
CascadeClassifier faceDetector = new CascadeClassifier(fileloc);

difficulty using saxon in java code for .sch to .xsl conversion

I’m trying to use schematron validation using saxon.
Firstly, i want to compile .sch file into .xsl . Later , i want to validate an .xml file with firstly produced .xsl file.
I found command line usage of saxon like below. And i used successfully them.
But i need to make these actions with java code.
I tryed some codes like below , but i did not guess how to put sch extensined file as a parameter (edefter_yevmiye.sch) and iso_svrl_for_xslt2.xsl into the code.
I searched the internet but i did not find enough information.
Is there a sample java code for converting .sch to .xsl or could you guide me please?
My java code
**Compiling .sch to .xsl**
net.sf.saxon.s9api.Processor processor1 = new net.sf.saxon.s9api.Processor(false);
net.sf.saxon.s9api.XsltCompiler xsltCompiler1 = processor1.newXsltCompiler();
xsltCompiler1.setXsltLanguageVersion("2.0");
xsltCompiler1.setSchemaAware(true);
net.sf.saxon.s9api.XsltExecutable xsltExecutable1 = xsltCompiler1.compile(new StreamSource(new FileInputStream(new File("File1.xsl"))));
net.sf.saxon.s9api.XsltTransformer xsltTransformer1 = xsltExecutable1.load();
xsltTransformer1.setSource(new StreamSource(new FileInputStream(new
File("File2.sch"))));
**Validation**
net.sf.saxon.s9api.Processor processor2 = new net.sf.saxon.s9api.Processor(false);
net.sf.saxon.s9api.XsltCompiler xsltCompiler2 = processor2.newXsltCompiler();
xsltCompiler2.setXsltLanguageVersion("2.0");
xsltCompiler2.setSchemaAware(true);
net.sf.saxon.s9api.XsltExecutable xsltExecutable2 = xsltCompiler2.compile(new StreamSource(new
FileInputStream(new File(“File1.xslt"))));
net.sf.saxon.s9api.XsltTransformer xsltTransformer2 = xsltExecutable2.load();
xsltTransformer2.setSource(new StreamSource(new FileInputStream(new
File("src.xml"))));
net.sf.saxon.s9api.Destination dest2 = new Serializer(System.out);
xsltTransformer2.setDestination(dest2);
xsltTransformer1.setDestination(xsltTransformer2);
xsltTransformer1.transform();
Command line usage
Compiling:
java -jar saxon9he.jar -o:output.xsl -s:some.sch iso_svrl_for_xslt2.xsl
Validation:
java -jar saxon9he.jar -o:warnings.xml -s:some.xml output.xsl
You're using your second transformation as the destination for the first, but that means that the output of the first transformation is used as the source document for the second, whereas you want to use it, I think, as the stylesheet for the second transformation.
The simplest way to do this is probably to set an XdmDestination for the first transformation, and then with this destination object, do destination.getXdmNode().asSource() to get the input to the compile() method for the second transformation.

How to write a simple .txt content processor in XNA?

I don't really understand how Content importer/processor works in XNA.
I need to read a text file (Content/levels/level1.txt) of the form:
x x
x x
x x
where x's are just integers, into an int[,] array.
Any tips on writting a SIMPLE .txt importer??? By searching google/msdn I only found .x/.fbx file importer examples. And they seem too complicated.
Do you actually need to process the text file? If not, then you can probably skip most of the content pipeline.
Something like:
string filename = "Content/TextFiles/sometext.txt";
string path = Path.Combine(StorageContainer.TitleLocation, filename);
string lineOfText;
StreamReader sr = new StreamReader(path);
while ((lineOfText = sr.ReadLine()) != null)
{
// do something
}
Also, be sure to set the "Build Action" to "None" and the "Copy to Output Directory" to "Copy if newer" on the text files you've added. This tells the content pipeline not to compile the text file but rather copy it to the output directory for use as is.
I got this (more or less) from the RacingGame sample provided by Microsoft. It foregoes much of the content pipeline and simply loads and processes text files (XML) for much of its level data.
XNA 4.0 uses
System.IO.Stream stream = TitleContainer.OpenStream("tilename.txt");
See http://msdn.microsoft.com/en-us/library/bb199094.aspx and also http://blogs.msdn.com/b/shawnhar/archive/2010/12/09/reading-files-in-xna-game-studio-4-0.aspx
There doesn't seem to be a lot of info out there, but this blog post does indicate how you can load .txt files through code using XNA.
Hopefully this can help you get the file into memory, from there it should be straightforward to parse it in any way you like.
XNA 3.0 - Reading Text Files on the Xbox
http://www.ziggyware.com/readarticle.php?article_id=69 is probably a good place to start. It covers creating a basic content processor.

Resources