URDF Workbench, robotics

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
sliptonic
Veteran
Posts: 3460
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: URDF Workbench, robotics

Post by sliptonic »

fosselius wrote:So i make progress i guess: https://youtu.be/56LOty4Yh1E
The new part structure makes my life very easy.
More stuff coming soon.

Any update? I've started playing with ROS and Moveit! and would love to be able to generate simple urdf models.
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: URDF Workbench, robotics

Post by fosselius »

Sadly not much, have been working on importing .stl or .obj files as links (structure, not things you click) and to do an "manual" assembly of the Inmoov hand.
like the one in my video but with more links/jonts. This is to verify that the concept holds and will highlight issues i might have overseen.

But as with many other developers, i have a daytime job and a family that needs attention now and then. Right now i have bought a new house (finally have room for my robotics lab with all the heavy machines) and are in the process of selling my old house as well as being stressed out at work and doing some serious overtime.

There will be updates, but i am not sure when. its a case of "when i got the time and is in the mood".

But knowing that there are some requests for this feature helps to motivates me, so it will probably come sooner because of your comment.
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: URDF Workbench, robotics

Post by fosselius »

here is an small update:
https://www.youtube.com/watch?v=BV_oCie ... e=youtu.be

its basically the same case as before but with links generated from a .stl file.

Now its time for making a nice GUI for importing/converting stl (i think this exists in the assembly2 workbench). And adding some slides to control the rotation of the joints as well.

It would also be nice to use another FreeCAD document as a link.
This will be awesome tool for me to evaluate degree of freedom while working on the models.

Then i think the export as URDF will be kind of straight forward.

oh, collision detection between links would be nice.. i see my scope is running away as usual..
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: URDF Workbench, robotics

Post by microelly2 »

Nice work and good to see that others work on this subject too. :)

I see a wide field of use cases of animation and robot control.
I still have not started working with 0.17
but there is already a lot of prototypes for animation features.
You write on collision detection - see my workbench to get some experience what can work on top of FreeCAD.

http://freecadbuch.de/doku.php?id=Animation%20Wokbench

the new Part design will simplify the layout of animated system, but the core questions still resist:
(usb) interface to the hardware
inverse kinematics
simulation with physical background
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: URDF Workbench, robotics

Post by fosselius »

another micro update:
https://youtu.be/1vc0z4KdCnQ

managed to squize in a few minutes of coding ;)
sirop
Posts: 1
Joined: Sat Nov 19, 2016 8:44 am

Re: URDF Workbench, robotics

Post by sirop »

fosselius wrote:another micro update:
https://youtu.be/1vc0z4KdCnQ

managed to squize in a few minutes of coding ;)
Hello.

Would it be impolite to ask about the progress?
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: URDF Workbench, robotics

Post by fosselius »

Not at all, quite dead for the moment, am afraid, did not come that far. I will probably pick it up a bit later again. Right now i am playing around with very simple robots in ROS/Rviz/Gazebo, will probably revisit this later on when i start playing around with more complex robots.
User avatar
fosselius
Posts: 381
Joined: Sat Apr 23, 2016 10:03 am
Contact:

Re: URDF Workbench, robotics

Post by fosselius »

And its time for a restart!

I was following this the other day:
http://gazebosim.org/tutorials?cat=guid ... =guided_i2

Look they are using FreeCAD!
There are only two issues:
  • Gazebo/SDF wants the models to have its model origo at the center of mass.
  • Gazebo/SDF uses meters, not millimeters.. so make a model 5mm and BOOM! you got a 5m part in gazebo.
In the guide above they center and scale the object by exporting a mesh from FreeCAD and load it in Blender.. WTF? so that had me going.

Now i have hacked together a "export script":

Code: Select all

print "Scaling mesh"
import Mesh,BuildRegularGeoms
mat=FreeCAD.Matrix()
mat.scale(0.001,0.001,0.001)
obj = App.ActiveDocument.Objects[0]
obj.Name
mesh=App.ActiveDocument.Objects[0].Mesh.copy()
mesh.transform(mat)
Mesh.show(mesh)
__objs__=[]
__objs__.append(FreeCAD.ActiveDocument.getObject("Mesh"))
Mesh.export(__objs__,u"/home/maiden/Projects/tinyArm/"+obj.Name+".stl")
print "Saved mesh to /home/maiden/Projects/tinyArm/"+obj.Name+".stl"
App.ActiveDocument.removeObject("Mesh")
And something for aligning the model according to center of mass:

Code: Select all

com = FreeCAD.getDocument("Unnamed1").getObject("Body").Shape.CenterOfMass
FreeCAD.getDocument("Unnamed1").getObject("Body").Placement = FreeCAD.getDocument("Unnamed1").getObject("Body").Placement.move(com*-1)
Now, this is just hacks/proof of concept. need to make them a bit less hard coded and more dynamic.

Things i want to add from here:

1. Generate a "dummy SDF" with data from a FreeCAD document with one shape (pose, inertia, mesh)
2. Generate a "dummy SDF" with data from a FreeCAD document with several shapes
3. Create a visual "dummy object" in FreeCAD that links ShapeA and ShapeB at object location and exports as a joint to a SDF file
4. Create a python script to load the model in gazebo and controlling the joints from FreeCAD.
5. Build workbench around this.

Then it will be time to play around with some rapid robotic prototyping ;)

Example SDF:

Code: Select all

<?xml version="1.0" ?>
<sdf version="1.5">
<model name="baseBot">
  <!-- Give the base link a unique name -->
  <link name="base">

    <!-- Offset the base by half the lenght of the cylinder -->
    <pose>0 0 -0.005 0 0 0</pose>
    <inertial>
      <mass>1.2</mass>
      <inertia>
       <ixx>0.0010608477766732891</ixx>
       <iyy>-0.00023721360899498273</iyy>
       <izz>0.00024999999996488216</izz>
        <ixy>0</ixy>
        <ixz>0</ixz>
        <iyz>0</iyz>
      </inertia>
    </inertial>

    <collision name="base_collision">
      <geometry>
	     <mesh>
	       <!-- The URI should refer to the 3D mesh. The "model:"
		   URI scheme indicates that the we are referencing a Gazebo
		   model. -->
	       <uri>model://baseBot/meshes/plate.stl</uri>
	     </mesh>
      </geometry>
    </collision>

    <!-- The visual is mostly a copy of the collision -->
    <visual name="base_visual">
      <geometry>
	     <mesh>
	       <!-- The URI should refer to the 3D mesh. The "model:"
		   URI scheme indicates that the we are referencing a Gazebo
		   model. -->
	       <uri>model://baseBot/meshes/plate.stl</uri>
	     </mesh>
      </geometry>
    </visual>
  </link>

  <!-- Give the base link a unique name -->
  <link name="top">

    <!-- Vertically offset the top cylinder by the length of the bottom
        cylinder and half the length of this cylinder. -->
    <pose>0.00 0.00 0.005 0 0 0</pose>
   <inertial>
     <mass>0.1</mass>
     <inertia>
       <ixx>0.0010608477766732891</ixx>
       <iyy>-0.00023721360899498273</iyy>
       <izz>0.00024999999996488216</izz>
       <ixy>0</ixy>
       <ixz>0</ixz>
       <iyz>0</iyz>
     </inertia>
   </inertial>
    <collision name="top_collision">
      <geometry>
	     <mesh>
	       <uri>model://baseBot/meshes/holder.stl</uri>
	     </mesh>
      </geometry>
    </collision>

    <!-- The visual is mostly a copy of the collision -->
    <visual name="top_visual">
      <geometry>
	     <mesh>
	       <uri>model://baseBot/meshes/holder.stl</uri>
	     </mesh>
      </geometry>
    </visual>
  </link>

<!-- Each joint must have a unique name -->
<joint type="revolute" name="joint">

  <!-- Position the joint at the bottom of the top link -->
  <pose>0.00 0.00 -0.00048 0 0 0</pose>

  <!-- Use the base link as the parent of the joint -->
  <parent>base</parent>

  <!-- Use the top link as the child of the joint -->
  <child>top</child>

  <!-- The axis defines the joint's degree of freedom -->
  <axis>

    <!-- Revolve around the z-axis -->
    <xyz>0 0 1</xyz>

    <!-- Limit refers to the range of motion of the joint -->
    <limit>

      <!-- Use a very large number to indicate a continuous revolution -->
      <lower>-10000000000000000</lower>
      <upper>10000000000000000</upper>
    </limit>
  </axis>
</joint>
</model>
</sdf>
Last edited by fosselius on Sun May 14, 2017 9:32 pm, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: URDF Workbench, robotics

Post by Kunda1 »

I think Kurt would be interested in this
kkremitzki wrote:ping
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
galou_breizh
Posts: 437
Joined: Wed Sep 15, 2010 9:38 am

Re: URDF Workbench, robotics

Post by galou_breizh »

fosselius wrote: There are only two issues:
  • Gazebo/SDF wants the models to have its model origo at the center of mass.
  • Gazebo/SDF uses meters, not millimeters.. so make a model 5mm and BOOM! you got a 5m part in gazebo.
I don't think this is true.
  • The origin of your mesh will be (0, 0, 0) and the absolute position of your mesh in the file will determine the relative position between the appearance and the link's origin in the SDF file.
  • I wrote a patch a long time ago to add the unit into the file because this is part of the Collada standard but unfortunately can't find it any more right now. I'm not sure whether Blender or gazebo support this feature anyway.
As a side notice, there is a plugin for Blender to generate URDF files: https://github.com/rock-simulation/phobos.

I would be happy to test your scripts because I also use Gazebo regularly and was looking for some help in creating URDF/SDF files.

I think, however, that I long as we don't have any official way to define joints in FreeCAD, everthing you program now will have to be changed some day and I would not invest too much time in a perfect solution. A single mesh export will already be a useful script but I never tried any material management (for the computation of the inertia).
Post Reply