<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Robotic Simulations and learning  with Python - Medium]]></title>
        <description><![CDATA[In this publication we will design our robots from scratch, create URDF files, make robot learn to do tasks independently with simulations in python and we can also transfer these learned behavior to real time. - Medium]]></description>
        <link>https://medium.com/robotic-simulations-and-learning-with-python?source=rss----a8e0487fdb6f---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Robotic Simulations and learning  with Python - Medium</title>
            <link>https://medium.com/robotic-simulations-and-learning-with-python?source=rss----a8e0487fdb6f---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:45:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/robotic-simulations-and-learning-with-python" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[First simulation]]></title>
            <link>https://medium.com/robotic-simulations-and-learning-with-python/first-simulation-1ca39807435d?source=rss----a8e0487fdb6f---4</link>
            <guid isPermaLink="false">https://medium.com/p/1ca39807435d</guid>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vishal_Kumar]]></dc:creator>
            <pubDate>Wed, 30 Sep 2020 11:01:14 GMT</pubDate>
            <atom:updated>2020-09-30T11:01:14.582Z</atom:updated>
            <content:encoded><![CDATA[<p>In this story we will be simulating our first robot with Bullet physics engine with PyBullet library and using the programming language Python, yeah Python, as the popularity and versatility of this language sooner we will be programming extra-terrestrial habitats with this… just a random thought 😈</p><p>Anyhow, Bullet physics engine is a piece of awesome software written in c, c++ and is used by many game development software’s, simulation software’s, researchers and lot more. In laymen terms a physics engine gives you power to create your own universe (in software form only don’t get excited 😃) you will be having control of each and every aspect of the environment like you want gravity to be +9.8 instead of -9.8 you got it, you like winds you can have them any time you want and in any direction you want basically you can set all parameters as your needs.</p><h3><strong>Installation and running for first time</strong></h3><p>For now you need only PyBullet library to install open your terminal and type</p><pre><strong>pip install PyBullet</strong></pre><p>for Ubuntu installation is as simple as this, for windows you may have to install VS C++ development package if you haven’t installed it earlier. Now lets run the first simulation, code explanation will be in code snippet.</p><pre># Importing required libraries PyBullet and time</pre><pre><strong>import pybullet as sim<br>import time</strong></pre><pre># Connecting to GUI of PyBullet there is a terminal based simulation # support also but we dont want that</pre><pre><strong>physicsclient = sim.connect(p.GUI)</strong></pre><pre>#Setting gravity to -9.8 in z direction i.e. downwards</pre><pre><strong>sim.setGravity(0, 0, -9.8)</strong></pre><pre># Running simulation indefinitely if physicsclient != 0 otherwise it # wont run</pre><pre><strong>while physicsclient == 0:<br>    sim.stepSimulation()<br>    time.sleep(0.01)<br></strong># This will make our simulation run indefinetly or until you are connected.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9VbYussKO3dr0YhzEgxrug.png" /><figcaption>Output of above code snippet</figcaption></figure><p>You can rotate the environment by holding <strong>ctrl + rightMouseButton </strong>and dragging your mouse and holding <strong>ctrl </strong>and <strong>scrolling through mouse wheel </strong>let you zoom in and zoom out in the scene, lets load our robot and see, code explanation is with comets in code. PyBullet has two modes for running and stepping simulation, first one is like similar to pause and play and second one is to run in real time. In first mode commands will update only when you wish to by running <strong>sim.stepSimulation(), </strong>whereas in second mode the<strong> </strong>commands will update in real time like in the sequential manner in which your code is written. Here in this series we will use the second mode in which the real time simulation takes place below code snippet explains it all.</p><pre># Importing PyBullet and time modules<br><strong>import pybullet as sim<br>import time</strong></pre><pre># Connecting to the GUI (Graphical User Interface) of the pybullet.<br><br><strong>physicsclient = sim.connect(p.GUI)</strong></pre><pre># Setting gravity to 9.8 m/s in -z direction<br># Coordinate system used is (x, y, z)<br># setRealTimeSimulation will enable the second mode of running<br># simulation.</pre><pre><strong>sim.setGravity(0, 0, -9.8)<br>sim.setRealTimeSimulation(True, physicsclient)</strong></pre><pre># Enter path to your urdf file</pre><pre><strong>path = &quot;path to your URDF file&quot;</strong></pre><pre># Loading the URDF file of robot<br><strong>armID = sim.loadURDF(path, useFixedBase=True, basePosition=[0, 0,0])</strong></pre><pre><strong>time.sleep(5)<br></strong># Running simulation for 5 seconds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*el87Qn6SaFKVzYkUyskc_g.png" /><figcaption>Collage of screenshots of the simulation</figcaption></figure><p>In above image we can see that the body of robot is swinging around and bumped into its own body 😆 this is because we haven&#39;t set any joint positions and motor parameters to act on the body, don&#39;t worry we will do that in next step.</p><pre><strong>import pybullet as sim<br>import time</strong></pre><pre><strong>physicsclient = sim.connect(p.GUI)<br>sim.setGravity(0, 0, -9.8)<br>sim.setRealTimeSimulation(True, physicsclient)</strong></pre><pre><strong>path = &quot;path to your URDF file&quot;<br>armID = sim.loadURDF(path, useFixedBase=True, basePosition=[0, 0,0])</strong></pre><pre># Now we will get number of joints in our robot by function<br><strong>joints = sim.getNumJoints(armID)</strong></pre><pre># setting all joints to position 0<br># parameters in function are<br># 1 bodyID=armID<br># 2 jointNumber=range(6) i.e. [0, 1, 2, 3, 4, 5]<br># 3 controlType=sim.POSITION_CONTROL i.e. position control for joint<br># 4 positions=[0]*6 i.e. [0, 0, 0, 0, 0, 0]</pre><pre><strong>sim.setJointMotorControlArray(armID,range(6),<br>                              sim.POSITION_CONTROL, [0] * 6)</strong></pre><pre># Making simulation wait for 0.5 seconds before next command<br><strong>time.sleep(0.5)</strong></pre><pre># setting a single joint to a specific position parameters will be # <br># same<br><strong>sim.setJointMotorControl2(armID, 1, sim.POSITION_CONTROL,  <br>                          120*math.pi/180)</strong></pre><pre># running simulation for 3 sec<br><strong>time.sleep(3)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EDrzwB6kB2y4t4xAEKbVvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AEFJjhEMTImjUzKKtrF_ew.png" /><figcaption>Snapshot of the positions</figcaption></figure><p>By this method we can control positions of the joints PyBullet offers more refine control over the joints while controlling torque and velocity that we will see in upcoming stories. function documentation you can see with a single line of command or if you use PyCharm then simple <strong>ctrl+q </strong>inside function braces super simple stuff 😆</p><pre><strong>print(sim.loadURDF.__doc__)</strong></pre><pre># use this line of code with any function you can see its<br># documentation printed</pre><p>Thats it for this story in next story we will try to make our tool of our robot to follow a specific path. I have created a script to write URDF file for your robot just design the parts, run script and follow what stated there its in my GitHub code for this story will also be there check them out.</p><p><a href="https://github.com/8-vishal/createURDF">8-vishal/createURDF</a></p><p><a href="https://github.com/8-vishal/6-DOF-robot-simulation">https://github.com/8-vishal/6-DOF-robot-simulation</a></p><p>Until then GOOD BYE AND KEEP LEARNING HOW OUR BRAIN LEARNS 😅</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ca39807435d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/robotic-simulations-and-learning-with-python/first-simulation-1ca39807435d">First simulation</a> was originally published in <a href="https://medium.com/robotic-simulations-and-learning-with-python">Robotic Simulations and learning  with Python</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Background and Initial Setup.]]></title>
            <link>https://medium.com/robotic-simulations-and-learning-with-python/background-and-initial-setup-76778b1dc592?source=rss----a8e0487fdb6f---4</link>
            <guid isPermaLink="false">https://medium.com/p/76778b1dc592</guid>
            <category><![CDATA[robots]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[3d-design]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[simulation]]></category>
            <dc:creator><![CDATA[Vishal_Kumar]]></dc:creator>
            <pubDate>Sat, 19 Sep 2020 19:22:11 GMT</pubDate>
            <atom:updated>2020-09-19T19:22:11.440Z</atom:updated>
            <content:encoded><![CDATA[<ol><li>Creating URDF files for robots…</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*5kJtOhgGOMBO7Ns3tD1yFg.png" /><figcaption>credits (google Images search)</figcaption></figure><p>Robots are just bunch of joints, couple of sensors thrown together in a systematic and well designed manner, designing a robot is a major task for robotic simulations as your design tells a lot about the jobs robot is going to perform. In this series we will use a 6-DOF robotic arm to perform our simulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c9oKaTSPdDZtb22akJyoBA.png" /><figcaption>6-DOF Robot</figcaption></figure><p>In this simulation we will be using this robot i have created it and uploaded to</p><p><a href="https://github.com/8-vishal/6-DOF-robot-simulation">8-vishal/6-DOF-robot-simulation</a></p><p>Now let’s talk about some of the available robotic simulators some big names in this field are ROS (Robot Operating System), Gazebo, CoppeliaSim, Webots and obviously keep going . . . . 😀 😆. The big daddy of this field is ROS which provides all the functioning you need from validating your idea to real-time working controllers and all other good stuff but these much functionality comes with a price of complexity (as i feel while using ROS) another rising name is CoppeliaSim which is a great piece of software and a great tool for validating your ideas to controlling them in real-time, but again what i feel problematic in CoppeliaSim is its documentation for Python Api as it is designed to use with Lua programming language. So after getting exhausted by looking a good alternative of all these and trying and failing for long i finally make up my mind to use Bullet physics engine to simulate my robots and believe me its work very well and i thought of helping all other robot enthusiast out here with what i learned………</p><p><strong>First Step</strong> :- To create 3D models of parts of your robots.</p><p>This is the easiest part for all Mechanical Engineers (kuddoosss… 😍) and hobbyists who have a good experience in designing 3D parts, i am putting an YouTube playlist which are great if you are beginner in field of designing 3D parts.</p><p><a href="https://www.youtube.com/playlist?list=PLrZ2zKOtC_-DR2ZkMaK3YthYLErPxCnT-">https://www.youtube.com/playlist?list=PLrZ2zKOtC_-DR2ZkMaK3YthYLErPxCnT-</a></p><p>personally i use FreeCad for designing but for beginners Fusion 360 is a good point to start as you can get 1 year free license as a student.</p><p><strong>Second Step</strong> :- To create URDF file.</p><p>URDF file creation is very simple just you have to define what is where and how is it.</p><pre><strong>&lt;link name=&quot;base_link&quot;&gt;<br>  &lt;inertial&gt;<br>    &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;-5.336640178419851e-14 -8.338500278781017e-17 0.2443634195323267&quot;/&gt;<br>    &lt;mass value=&quot;2412.4922874782374&quot;/&gt;<br>    &lt;inertia ixx=&quot;388.738882&quot; ixy=&quot;-0.0&quot; ixz=&quot;-0.0&quot; iyy=&quot;388.738882&quot; iyz=&quot;0.0&quot; izz=&quot;665.868438&quot;/&gt;<br>  &lt;/inertial&gt;<br>  &lt;visual&gt;<br>    &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0 0 0&quot;/&gt;<br>    &lt;geometry&gt;<br>      &lt;mesh filename=&quot;package://Complete_ARM_description/meshes/base_link.stl&quot; scale=&quot;0.001 0.001 0.001&quot;/&gt;<br>    &lt;/geometry&gt;<br>    &lt;material name=&quot;silver&quot;/&gt;<br>  &lt;/visual&gt;<br>  &lt;collision&gt;<br>    &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0 0 0&quot;/&gt;<br>    &lt;geometry&gt;<br>      &lt;mesh filename=&quot;package://Complete_ARM_description/meshes/base_link.stl&quot; scale=&quot;0.001 0.001 0.001&quot;/&gt;<br>    &lt;/geometry&gt;<br>  &lt;/collision&gt;<br>&lt;/link&gt;</strong></pre><pre><strong>&lt;joint name=&quot;Rev1&quot; type=&quot;continuous&quot;&gt;<br>  &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0.0 0.0 0.6&quot;/&gt;<br>  &lt;parent link=&quot;base_link&quot;/&gt;<br>  &lt;child link=&quot;ARM_1_1&quot;/&gt;<br>  &lt;axis xyz=&quot;-0.0 0.0 1.0&quot;/&gt;<br>&lt;/joint&gt;</strong></pre><p>above snippet is for a single link, i will explain the complete procedure for writing urdf file:-</p><ol><li>Open a text editor and create a new file with extension .urdf and we will write line of codes in this file, if you know XML then writing this is a piece of cake for you otherwise just follow along you will able to write your own urdf file after reading this.</li><li>I will use ## for explaining each line in below code snippet in XML&lt;!…&gt; is used for commenting but for sake of simplicity i will use ## for comment.</li></ol><pre>## define body(link) and its name, all properties of body will be  ## children of this link</pre><pre><strong>&lt;link name=&quot;base_link&quot;&gt;</strong></pre><pre>## Inertial Properties of the solid body<br>## Origin of body xyz Cartesian co-ordinates and rpy are roll, pitch ## and yaw<br>## Mass of the body<br>## 3x3 rotational inertial matrix values as the matrix is symmetric ## no need to write same values again<br>## ixx ixy ixz<br>## ixy iyy iyz<br>## ixz iyz izz</pre><pre> <strong> &lt;inertial&gt;<br>    &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0 0 0&quot;/&gt;<br>    &lt;mass value=&quot;0.0&quot;/&gt;<br>    &lt;inertia ixx=&quot;0&quot; ixy=&quot;0&quot; ixz=&quot;0&quot; iyy=&quot;0&quot; iyz=&quot;0&quot; izz=&quot;0&quot;/&gt;<br>  &lt;/inertial&gt;</strong></pre><pre>## Visual properties of solid body<br>## Origin of body xyz Cartesian co-ordinates and rpy are roll, pitch ## and yaw<br>## In geometry child put path to .obj file of your model<br>## material name =&quot;silver&quot; is just a material name and color which ## is already defined in a separate file materials.xacro see GitHub</pre><pre><strong>  &lt;visual&gt;<br>    &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0 0 0&quot;/&gt;<br>    &lt;geometry&gt;<br>      &lt;mesh filename=&quot;path_to .obj file&quot; scale=&quot;0.0 0.0 0.0&quot;/&gt;<br>    &lt;/geometry&gt;<br>    &lt;material name=&quot;silver&quot;/&gt;<br>  &lt;/visual&gt;</strong></pre><pre>## Collision properties of body<br>## Origin of body xyz Cartesian co-ordinates and rpy are roll, pitch ## and yaw<br>## In geometry child put path to .stl file of your model dont swap ## files in visual and collision properties otherwise we will get  ## error in solving for inverse kinematics.</pre><pre><strong>  &lt;collision&gt;<br>    &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0 0 0&quot;/&gt;<br>    &lt;geometry&gt;<br>      &lt;mesh filename=&quot;path_to .stl file&quot; scale=&quot;0.0 0.0 0.0&quot;/&gt;<br>    &lt;/geometry&gt;<br>  &lt;/collision&gt;<br>&lt;/link&gt;</strong></pre><p>The files which i have uploaded on GitHub are only for forward kinematics as further in time when we will reach inverse kinematics calculations i will upload the appropriate urdf file. Now we will discuss about joining two bodies (links).</p><pre>## Joints in URDF files are of 6 types<br>## .Revolute - Similar to Hinge Joint have limits<br>## .Continuous - Revolute around an axis no limits, ex:- wheels<br>## .Prismatic - sliding joint or linear in only 1 axis<br>## .Fixed - Fixed no DOF <br>## .Floating - Joint have all 6 DOF<br>## .Planar - linear joint in multi axis<br>## Origin of joint xyz Cartesian co-ordinates and rpy are roll,    ## pitch and yaw<br>## Parent and child link are just clear by names<br>## axis - axis of rotation for revolute and continous, axis of     ## movement for prismatic and planar</pre><pre><strong>&lt;joint name=&quot;Rev1&quot; type=&quot;continuous&quot;&gt;<br>  &lt;origin rpy=&quot;0 0 0&quot; xyz=&quot;0.0 0.0 0.6&quot;/&gt;<br>  &lt;parent link=&quot;base_link&quot;/&gt;<br>  &lt;child link=&quot;ARM_1_1&quot;/&gt;<br>  &lt;axis xyz=&quot;-0.0 0.0 1.0&quot;/&gt;<br>&lt;/joint&gt;</strong></pre><p>There are more children&#39;s to joint like calibration, dynamics, limit, safety_controller, we will be looking on these children&#39;s in future as we proceed with this publication. That’s it for this story next story will be about setting up our coding environment, installing packages, and our first Robotics Simulation from scratch… 😃😃😃😃</p><p>Until then GOOD BYE AND KEEP LEARNING HOW OUR BRAIN LEARNS 😅</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76778b1dc592" width="1" height="1" alt=""><hr><p><a href="https://medium.com/robotic-simulations-and-learning-with-python/background-and-initial-setup-76778b1dc592">Background and Initial Setup.</a> was originally published in <a href="https://medium.com/robotic-simulations-and-learning-with-python">Robotic Simulations and learning  with Python</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>