Last active
October 27, 2019 21:02
-
-
Save bderose/bc33ab34440b56f67a03aa0ea1030355 to your computer and use it in GitHub Desktop.
Example DNaaS API calls and workflow in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net.Http; | |
using System.Text; | |
using Newtonsoft.Json; | |
class Dnaas { | |
private static readonly HttpClient client = new HttpClient { | |
BaseAddress = new Uri("http://automation.berkeley.edu/dex-net-api/"), | |
}; | |
static void Main(string[] args) { | |
var jsonParams = JsonConvert.SerializeObject(new { | |
metric = "robust_ferrari_canny", | |
gripper = new { | |
fingertip_x = 0.01, | |
fingertip_y = 0.01, | |
gripper_offset = 0.01, | |
palm_depth = 0.05, | |
width = 0.08 | |
} | |
}); | |
var jsonContent = new StringContent(jsonParams, Encoding.UTF8, "application/json"); | |
var meshContent = new ByteArrayContent(File.ReadAllBytes("/path/to/your/mesh.obj")); | |
var form = new MultipartFormDataContent(); | |
form.Add(meshContent, "file", "file"); | |
form.Add(jsonContent, "params", "params"); | |
var response = client.PostAsync("upload-mesh", form) | |
.GetAwaiter() | |
.GetResult(); | |
response.EnsureSuccessStatusCode(); | |
var result = response.Content.ReadAsStringAsync().Result; | |
Console.WriteLine(result); | |
} | |
} |
@DiegoVil sounds like you got things working. Glad to help.
@wderose : Yes , its working now...
One more question: I have gone through the paper but I have a doubt.... in the poses that you calculate where is the origin ? in the center of mass of the object? how can I know where is located the basis of coordinates?
The stable pose-associated grasp is relative to the object. We assume the mesh is watertight, so it should be the CoM of the object. In order to use grasp configuration, you may still need to apply a transformation to grasp pose. The quaternion is wxyz.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is with your example and sample, same error...maybe I am doing something wrong..I am using this:
<?xml version="1.0" encoding="utf-8"?> <configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
EDIT: After several clicks.... I have this output:
{
"state": "sampling grasps"
}
{
"percent done": 0.13,
"state": "collision checking"
}
The thread 0x2368 has exited with code 0 (0x0).
{
"percent done": 0.3175438596491228,
"state": "collision checking for stable poses"
}
{
"percent done": 0.010526315789473684,
"state": "computing metrics"
}
{
"percent done": 0.22105263157894736,
"state": "computing metrics"
}
{
"percent done": 0.4,
"state": "computing metrics"
}
{
"percent done": 0.6210526315789474,
"state": "computing metrics"
}
{
"percent done": 0.8421052631578947,
"state": "computing metrics"
}
{
"state": "done"
}
{
"state": "done"
}
{
"state": "done"
}
EDIT 2:
Adding this lines to your code works perfectly!
BTW: Beautiful project