Overview

  • - BondSim3DVisual is a 3D visualization environment, which enables creation of the virtual scenes. A virtual scene is 3D computer view of a part of the real space in which robots, or other mechanisms including humans, work. It include also the light sources and camera and is based on VTK© visualization technique in Windows environment. The current version of VTK the program uses needs that the graphic card of the comupter on which the program runs supports OpenGL version 3.2 or higher. When installing the program it checks if this is satisfied; otherwise the installation is rejected.
  • - To define a 3D virtual scene a simple text based script are used. The kinematics of the problem is described first. Next the objects that populate the scene are described as 3D geometric objects. They can be constructed from the primitive bodies such as cylinders, cubes, spheres and others, but also CAD generated geometric models in form of .stl (stereo lithographic) files can be imported as well. The objects are defined in their initial position. Also rendering of the object is defined by the corresponing commands. The scripts are edited using Notepad program that program directly calls and are stored in the program database.  
  • - To create the virtual scene for a project the corresponing script is read in first, translated and the visualization objects are created in the computer memory. The generated objects are then rendered on the computer screen. The objects are shown in their initial positions. The camera view of the scene can be changed by mouse clicks.
  • - The objects on the sceene can be moved manualy by a menu driven command. When the command is issued a dialog opens which enables setting the joint angles or displacemnts. By clicking the OK the program updates the scene. We can experiment with different values to check the behavior of the objects in the scene. To reset the scene we may click Reset button. By Close button we close the operations.
  • - There is also IPC (Inter Process Communications) command, which enables driving of the objects in the virtual scene by an external program, typically BondSim. To enable the communications between these two programs Named Pipe technology is used. The BondSim3DVisual serves as a server, which creates the pipe and redraws the scene based on the messages received from the client (BondSim, see the figure below). 

Interprocess communication between the server and client

Interprocess communication between the server and client

  • - To start the communication both BondSim 3D Visual and client program have to be loaded on the same, or distinct computers linked into a local net. When the virtual scene is created and the IPC command is issued the pipe is created. On the client side the corresponding dynamical (BondSim) model is opened and built. When the client connects to the server the process can start. By running the simulations the client sends messages to the server, which procesed them and redraw the scene. Thus, during the simulation it is possible to watch how the process evolves and the corresponing objects moves in the virtual scene. The process stops when the simulation finishes.
  • - The motion can be recorded also as an AVI file, which can be later replayed by a suitable media player.

Generating Virtual 3D Scene

To generate a virtual scene BondSim3DVisual needs to be started first, e.g. by double clicking its icon on the desktop. The main frame opens as shown below representing the visualization environment. At the top the frame contains the Program title. Beneath it is a menu bar that lists the commands that can be used at this starting level. Below it there is the toolbar containing the buttons with short-cuts for often used commands. When the mouse cursor is moved over these buttons a small (tooltip) window appears showing the command that is invoked by clicking the button.

Visualization environment
Visualization environment

BondSim3DVisual program comes with several already preinstalled projects. One of these is Puma 560, a project that visualizes the motion of the famous Puma 560 robot arm. To open the corresponding project script we click menu File and select Open submenu, and then Project command. We can do it also using Open Project toolbar button. A dialog window opens, which contains a list from which we can select the corresponding project name (see the figure below). We select Puma560_Project and click OK.

Open project dialog
OpenProject


A Notepad window opens containing the script, which defines the virtual scene. The Figure below shows Puma 560 project script. It is a very simple one, which defines only the global (world) coordinates, size of the workspace and inserts the Puma 560 robot arm from the robot space.

Puma 560 Project
Puma560Project

The robot subcommand (after Insert) denotes the model space part where the models of different robots and other complex mechanisms are held. Thus using Insert command different robots and other mechanisms can be placed in the scene.

To open the corresponding Puma 560 arm script we apply Open->Robot command from File menu (or use Open Robot toolbar button). In the dialog that opens select Puma 560 robot and click OK. The Notepad opens the corresponding script, a part of which is shown in the figure below.

Puma560 script

Puma560For every object there is a Device command. It is designed with robots in mind, but can be used also for other objects. It defines the name of the device. The robot has the links (members) that are connected one to other and to the body by the joints. The joints could be revolute or prismatic. More complex joints can be described by these simple ones, e.g. the robot’s wrist. To every link there is attached a local coordinate frame. These frames rotate/slide about/along the joints axes driven by the actuators. The displacements of the links are not defined by the script. They are supplied from outside.  The device command defines only their initial position as well as their minimum and maximum displacements.

The most of other commands serves to construct the Puma 560 body and links by assembling the primitive bodies such as cubes, cylinders, polyprisms, etc.  The script could be much shorter if CAD models of the parts are used in the form of .stl files. (This is the case with ABB_IRB1600_12 robot contained also in the projects list.).

There are two important visualization commands: render and probe. The first serves to render (draw) a particular body object on the screen in a specified color. In the script part shown above we can see the render command for Puma body. It asks the system to render it in a gray color.

The probe command (not shown above) serves to define a probe as a point attached to an object in the scene. During the motion of the object, the probe moves with it, and its coordinates are picked and sent out. Thus, we can add a probe to the robot tip and during the motion of the robot its positions are returned back to the client. 

The detailed description of the script and the commands can be found in the book shown on the top of the page. 

To create the corresponding virtual scene we close the script and click Create 3D scene toolbar button (the fith from the left), or select the corresponding command from File menu. A similar dialog as earlier opens (see the figure below).

Dialog window for creating project virtual scene
Dialog window for creating project virtual scene
 

We select the project from the list for which we wish to create the virtual scene. Note that we can also define the background color. It is defined by red, green and blue values in the range 0.0-1.0. The currently default background is white, but it can be changed to any other color. When we are finished with the selection we click OK button. After a short delay (depending on the computer) the virtual scene appears with Puma robot as shown in the next figure.

3D virtual scene with Puma 560
Puma5603DScene

The robot is shown in its initial pose defined by the script. The colored thick lines represent the coordinate axes of the robot base. We can change the viewing direction on the scene by clicking to the screen. Thus, if we click by the mouse on the left side of the robot but close to its body, the scene changes as shown in the figure below.

al scene with Puma 560
Puma5603DScene1
 

Preparing IP Communication with Client

Before we start IPC with BondSim as a client we must load it and open the corresponding project we wish to visualize by the server. To illustrate this we use Puma 560 project, which we can find among the BondSim library projects. We right-click the project and copy it into the model workspace. It represents a model of Puma 560 robot arm in the control loop. More details you may find in the book shown at the top of the page.

Bond Graph model of Puma 560 control loop
Bond Graph model of Puma 560 control loop

   

The system level model the figure above shows the Puma 560 project, which consists of the following main components: Manipulator, which represents the Puma 560 robot arm, Workspace, which models the space in which robot works, and finally the Input and Controller, which drive the robot in the feedback control loop.

The model of Manipulator consists of two main components: Arm and Wrist (see the figure below on the left). Model of the Arm is shown in the figure on the right. The Arm and Wrist consist of three joints and links each and correspond to Device command in Puma 560 script (see Generating Virtual 3D Scene).

Model of Manipulator  & Model of Arm
Model of Manipulator  & Model of Arm

The important role plays IPC pipe component represented in the system level model of the robot (see the figure at the top) as a red ring (a pipe). This component was created by dragging and dropping the corresponding tool from Editing Tools, Continuous Signal Components. It serves to collect the signals (the joint angles in degrees) at the input and sent them to the server during the simulation run; it also distributes the signals received from the server (e.g. the coordinates of the robot tip). The order of the signal values that are sent must corresponds to the order of the joints in Device command in the script (counting from the robot base to its tip). By clicking the input ports a dialog opens, which show these signal (see the figure below). The same holds for the signals received. 

IPC pipe component dialog
PipeOutputVariablesWe must build the model first. After this operation was successfully completed to start the communication with the server we must connect to it by selecting Connect IPC Socket command in Simulation menu. If the command is accepted we can start the simulation and both side of pipe are active - simulation and visualization. For more details refer please to the book.

Running Robot in 3D Scene

To run robot in the visual scene we use both applications: the server (BondSim3DVisual) to create a virtual scene and redraw it and the client (BondSim) to simulate system and drive the virtual scene. We connect them in the named pipe loop as shown below. The named pipe permits running these applications on the same or remote computers connected by a local link; in the last case we must supply the client with the server’s computer name.

The Named Pipe communication loop
The Named Pipe communication loop

To create the virtual scene and drive the robot (see the figure below):

  • - Load BondSim 3D Visual program.
  • - Select command Create Virtual Scene in menu File and in the dialog that opens select project Puma 560. Accept default background color and click OK button.
  • - When the virtual screen is constructed with the robot in it pick BondSim3DVisual program frame by the title and move it e.g. to the left top position on the computer screen.
  • - Load BondSim program.
  • - Activate Model Library tab and expand Projects branch. Select project Puma 560 and right-click it and when the menu drops down select command Copy to the Workspace.
  • - Click Open Project toolbar button (the second from the left) and in dialog box that opens select Puma 560 project and click OK
  • - The Puma 560 project opens. We may change the size of the client frame window and retain only the central part. Drag the frame e.g. to the right so that it does not cover the server (see below). Click Build button. Observe the message that appears in Output window.

Now the both applications are ready to communicate and work jointly. We do the following:

  • - Click BondSim3DVisual title to activate the virtual scene. In menu Operation select command Start IPC. The server now creates the IPC pipe and waits for the client to connect to.
  • - The next, click on Bond Graph model to activate the client, open the Simulation menu and select command Connect IPC Socket.  A dialog opens requiring the server computer's name. Here, as the both programs are loaded on the same computer and thus the client knows where the server is, we may simply click OK.
  • - The client now connects to the server’s pipe object. If the connection went well, the server creates a separate thread for listening messages received by the pipe from the client. The communication was now established and we can start the simulation.

Computer screen with Puma virtual screen (on the top left) and its Bond Graph model

                                                  Computer screen with Puma virtual screen (on the top left) and its Bond Graph model (on the bottom right)

 Thus, we click Run button (a large red arrow one) to start simulation and simulation option dialog opens as shown below.

Simulation options
Simulation options

 

This is the same dialog we already encountered (see BondSim, Running the Simulations).

  • - We can accept the simulation parameters already set and click Restart button. Note, however the Output Delay box, which specifies 50 ms. It does mean that every 50 ms the values of joint angels that are evaluated during the simulation run are collected, packed into a message and sent to the server to redraw the scene. After receiving the message the server recalculates the position of the all changed objects and updates the scene. Thus, there are 1/0.050 = 20 generated scene updates (movie frames) per second. If we use a much lower delay (much higher frames per second rate) the scene could blink. This value of the frames per second is close to the movie frame standard. 
  • - Now we may view the motion of Puma arms until end of simulation, which occurs relatively quickly.  We can repeat the simulations and IPC session as the scene is still active until we close the simulation session by clicking End Simulation button.
  • - We may record the Puma motion as an .avi file. To do it, before the start of a simulation run, we return back to the Server and in menu File select command Start Movie. This command opens a dialog which requires the .avi filename and where to store it. By accepting the command by OK the recortings starts.
  • - When the simulation finishes we again open server menu File and select End Movie.  The server closes and saves the .avi file. We may afterwards replay this file by the most media players. Several such files are played on the web's Home page.