rcruzoliver_0-1715591584751.png

SDK - Python webserver custom User Interface for Motion App

rcruzoliver
Long-established Member

In this How-To we present a demo example of a custom user interface for the Motion App running as a webserver in ctrlX OS.

In the following picture we can see an overview of the system that is presented in this How-To. In summary, ctrlX OS native websevers are available through the port 8443, whereas our custom one speaks and listens in port 5000. We also see how the apps interact with the datalayer nodes.

Overview diagramOverview diagram

1. Requirements
  • ctrlX OS 2.xx. installed in a ctrlX CORE device (X3, X5, X7 or virtual)
  • Offical Bosch Rexroth Motion App
  • Source code for custom Python webserver app

installed appsinstalled appsThis project has been developed from the example in the official Bosch Rexroth app development SDK. If you want to have access to the specific source code of the implementation presented in this How-To, do not hesitate to leave us a comment and we will contact you.

2. ctrlX OS setup

The Motion app allows the user to define axes, which can be mapped later to a Profile that connects the defined axis object with the hardware. Axis can then be grouped in the so-called kinematics, this allows to define specific machine mechanical architectures, as it can be a Cartesian robot presented here.

2.1. Define 3 axes

Go to the Axes tab in the Motion app.

Axes TabAxes Tab

We need to first bring the Motion app to configuration state:

Configuration modeConfiguration mode

After that we are allowed to define new axes by clicking in the blue "+" (or a big ¨+¨ symbol in the middle of the screen if you do not have any axis yet).

Generate 3 axes called "AxisX", "AxisY" and "AxisZ" with the configuration you can see in the image.
NOTE: These names are used by the websever, so keep it consistent.

Adding axesAdding axes

2.2. Map the axes with the hardware profiles (optional)

Axis profiles tabAxis profiles tab

In this example we are working with virtual axes, so they are not mapped to hardware. If you are working with real drives, follow the common steps to set this up.

2.3. Define a Cartesian kinematic

Go to the Coordinated Motion tab.

Coordinated Motion tabCoordinated Motion tab

Bring the Motion app to configuration state, if it was not there already.

Now you can add a new kinematic with the blue ¨+¨(or a big ¨+¨ symbol in the middle of the screen if you do not have any kinematic yet).

Define a ¨Cartesian¨ kinematics called ¨Kinematics¨. Again, the naming is used by the Webserver, be coherent with it.

Now, let's add the previously defined axes to this kinematic. Click on the ¨Kinematics¨ picture/text as depicted in the next image.
Edit kinematicsEdit kinematics
You can connect the axes to the kinematics clicking on the pencil.Open axis settingOpen axis setting

Axis mappingAxis mapping

After this step, you can bring the Motion app back to ¨Running¨state. Make also sure that the whole ctrlX is in Operating State (Not setup, not Service).

3. Webserver functionalities

Now, you are ready to interact with the websever. You can open it by clicking under ¨Webserver¨ tab in the lateral menu, a new window will start with the server.  You may need to tell the browser that it is safe place manually.

NOTE: If you are working with ctrlX CORE virtual, do not forget to use port forwarding and map port 5000:5000. It is the port where the server is externally available.

If everything was fine, you should see this.

User interfaceUser interface

You could already use the webserver, but let's monitor its operation by looking at the Commissioning Tab for Kinematics.

How to go to commisioning tabHow to go to commisioning tabYou must see something like this:

Comissioning tabComissioning tab

Now let's go back to the webserver and press ¨Power¨. You will see how the button changes color from ¨Red¨ to ¨Green¨. You can see how the kinematics have been powered up.

Kinematics powered upKinematics powered up

Let's commision something from the webserver. Write some numbers under ¨Target position¨ and click ¨Start¨ in the webserver. You will see the actual position of the axis in the Comissioning Tab. You can stop this movement at any time by clicking ¨Stop¨  in the websever.

To power off the axis click the ¨Power¨ button in the webserver again, it will turn ¨Red¨. You can inspect the result of this operation in the commissioning tab.

4. Conclusions

In this How-To we have seen how we can design a custom webserver that can interact with ctrlX OS. In particular we are using the Datalayer-API that the Motion app provides, as well as interacting with custom messages (defined as flatbuffers) with the Datalayer.

If you found this post interesting do not forget to leave a like!

rcruzoliver
rcruzoliver
Enhancing ctrlX platform with solutions. Everything can be snapcrafted! Robotics specialist, ask me anything about ROS2 and ctrlX OS.
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist