Nibba2018's Blog

Weekly Check-in #10

Nibba2018
Published: 08/02/2020

Single Actor, Physics, Scrollbars.

Hello and welcome to my 10th weekly check-in. Second evaluation ended this week and now we move on to our 3rd and final coding period. In today's check-in I will be sharing my progress with the single actor physics simulation that I facing some issues with and I will also be discussing my future plans regarding UI components. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I was able to figure out the uncontrollable spinning problem that I was facing while rendering physics simulations. Specifically the simulation where a brick wall was rendered by a single actor. The spinning problem was as follows:

Here's how the fixed simulation looks like:

I was facing this particular issue because I was directly syncing the orientation of the objects in pyBullet world to the objects in the Fury world. So I decided to apply the change in orientation instead and it worked. In order to achieve this I had to keep track of the bricks' orientation at each step of the simulation, sync the change and then update the tracked orientation. Thankfully, pybullet had convenient tools to achieve this. Here's a snippet on how to update individual objects rendered by a single actor:

def sync_brick(object_index, multibody):
    pos, orn = p.getBasePositionAndOrientation(multibody)

    rot_mat = np.reshape(
        p.getMatrixFromQuaternion(
            p.getDifferenceQuaternion(orn, brick_orns[object_index])),
        (3, 3))

    vertices[object_index * sec: object_index * sec + sec] = \
        (vertices[object_index * sec: object_index * sec + sec] -
         brick_centers[object_index])@rot_mat + pos

    brick_centers[object_index] = pos
    brick_orns[object_index] = orn

All the necessary information is updated here.

What is coming up next?

Currently, the scrollbars are native to ListBox2D only. We are planning to separate scrollbars from ListBox2D to create a standalone UI component. This was in progress previously but was later discontinued, so I was given the responsibility to complete it. After this we plan to improve File Dialog capabilities later on.

Did you get stuck anywhere?

I did not face any major issues but it took me some time to understand and evaluate the existing discontinued PR regarding scrollbar separation.

Thank you for reading, see you next week!!
View Blog Post

Weekly Check-in #9

Nibba2018
Published: 07/26/2020

Tab UI, TabPanel2D, Tab UI Tutorial.

Hello and welcome to my 9th weekly check-in. I will be sharing my progress with TabUI and its corresponding tutorial. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I finished the basic implementation of TabUI. Apart from that I was also able to finish the tutorial which showcases different features of this said UI. With the help of this UI one can have multiple panels containing different UI elements within them. The basic implementation can be demonstrated as follows:

After finishing with the basic implementation I moved on to create its tutorial. For that, I decided to combine 3 of the existing UI tutorials to be rendered with the help of Tab UI. I implemented the following in individual tabs:

  • Controlling a cube with the help of LineSlider2D and RingSlider2D.
  • Using a CheckBox to render a cylinder or a sphere or both.
  • Using ComboBox to set the color of a label.

 

The above tutorial can be demonstrated as follows:

What is coming up next?

Next week I will continue working on the Physics engine integration. Previously we were facing a problem regarding the uncontrollable spinning of objects rendered by a single actor. There must be an issue with mismatching axes alignment of FURY and pyBullet. The spinning problem is as following:

Did you get stuck anywhere?

I did get stuck with the collapsing functionality of Tab UI and the uncontrollable spinning of the bricks in the Physics simulation. Apart from that I did not face any major issues.

Thank you for reading, see you next week!!  
View Blog Post

Weekly Check-in #8

Nibba2018
Published: 07/19/2020

ComboBox2D, TextBlock2D, Clipping Overflow.

Hello and welcome to my 8th weekly check-in. I will be sharing my progress with ComboBox2D and TextBlock2D UI components. After solving TextBlock2D sizing issue, I was finally able to complete the implementation of combo box. I also faced some problems while refactoring TextBlock2D. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I finished the implementation of TextBlock2D and ComboBox2D. I also added necessary tests and tutorials to aid the implementation. It still needs some color design, which will be decided later on. Here's an overview of the tutorial:

 

Its a simple tutorial where I change the color of the label based on the option selected on the combo box.

Now while refactoring TextBlock2D, I noticed that the Text Overflow workaround on ListBox2D broke and started acting weird. This was mainly because the size implementation was changed and the code that I wrote a few months back wasn't relevant anymore. So I removed the previous code and had to re-implement the same. I later found out that I would be needing such an implementation for most of my UI components so I decided to create a separate method for clipping overflowing texts.

I had to figure out a specific algorithm to achieve this as the height and width of each characters were different and the combined width of multiple characters were not equal to the sum of their widths. I decided to go for a binary search implementation as it was faster compared to a simple linear checking algorithm. The said algorithm works as expected and is more effective compared to its previous implementation. I tweaked the previous combo box example to showcase this algorithm.

The extremely long text is now clipped correctly.

What is coming up next?

Next week, I have a couple of things to work on. Firstly, the single actor wall brick simulation is yet to be completed. Once I am done with that I will continue working on Tab UI and try to finish its skeletal implementation.

Did you get stuck anywhere?

I did get stuck regarding the previous implementation of Text Overflow in ListBox2D. Before the current implementation it looked something like this:

Apart from that, I did not face any major issues.

Thank you for reading, see you next week!!
View Blog Post

Weekly Check-in #7

Nibba2018
Published: 07/12/2020

Orientation, Sizing, Tab UI.

Hello and welcome to my 7th weekly check-in. I will be sharing my progress with single actor physics simulation and TextBlock2D sizing issue which was pending for quite a while now. I will also be sharing my thoughts regarding the TAB UI component. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

This week I was working with the orientation problem I mentioned in my previous check-in. I did have some problems regarding it, but thanks to my mentor I was able to figure it out and implement it with the help of scipy's Quaternion to Rotation Matrix method. After understanding the orientation implementation, I spent some time regarding the design of the TAB UI component. I expect the design to be something similar as follows:

Fortunately, we have good news this week. The TextBlock2D sizing issue that we were facing for quite a while has now been fixed. We simply have to keep track of the scene parameter in the _add_to_scene method of each UI component. This scene parameter inherits vtkViewport, hence it allows us to determine the necessary details about the environment of the 3D objects.

What is coming up next?

As the sizing issue regarding TextBlock2D has been fixed, I am very much eager to finish the remaining work left. ComboBox2D and TextBlock2D were left incomplete because of the issue. Therefore, my main objective next week would be to finish them first. Once I am done with it, I will move on to Tab UI. If not, I will continue with the physics simulation.

Did you get stuck anywhere?

Apart from the orientation and sizing problem, I did not face any major issues.

Thank you for reading, see you next week!!
View Blog Post

Weekly Check-in #6

Nibba2018
Published: 07/05/2020

Translation, Reposition, Rotation.

Hello and welcome to my 6th weekly check-in. The first evaluation period officially ends and I am very excited to move on to the second coding period. I will be sharing my progress with handling specific object's properties among various multiple objects rendered by a single actor. I am mainly focusing on making it easier to translate, rotate and reposition a particular object, so that I can use them to render physics simulations more efficiently. The official repository of my sub-org, FURY can always be found here.

What did you do this week?

Last week I worked on physics simulations rendered in FURY with the help of pyBullet. Now the simulations were highly un-optimized, specially the brick wall simulation as each brick was rendered by its own actor. In other words, 1 brick = 1 actor. Now my objective was to render all the bricks using a single actor, but before jumping into the simulation I had to figure out how to modify specific properties of an individual object. Thanks to my mentor's PR, I was able to experiment my implementations quickly.

Translation:

The algorithm behind translation is to first identify the vertices of the object, then bring the vertices to the origin by subtracting their centers and then adding the displacement vector. The said operation can be achieved by the following snippet:

# Update vertices positions
vertices[object_index * sec: object_index * sec + sec] = \
    (vertices[object_index * sec: object_index * sec + sec] -
     centers[object_index]) + transln_vector

Rotation:

The algorithm behind rotation is to first calculate the difference between the vertices and the center of the object. Once we get the resultant matrix, we matrix multiply it with the rotation matrix and then we further add the centers back to it so that we preserve the position of the object. Rotation matrix can be defined as:

where gamma, beta and alpha corresponds to the angle of rotation along Z-axis, Y-axis and X-axis.

def get_R(gamma, beta, alpha):
    """ Returns rotational matrix.
    """
    r = [
        [np.cos(alpha)*np.cos(beta), np.cos(alpha)*np.sin(beta)*np.sin(gamma) - np.sin(alpha)*np.cos(gamma),
        np.cos(alpha)*np.sin(beta)*np.cos(gamma) + np.sin(alpha)*np.sin(gamma)],
        [np.sin(alpha)*np.cos(beta), np.sin(alpha)*np.sin(beta)*np.sin(gamma) + np.cos(alpha)*np.cos(gamma),
        np.sin(alpha)*np.sin(beta)*np.cos(gamma) - np.cos(alpha)*np.sin(gamma)],
        [-np.sin(beta), np.cos(beta)*np.sin(gamma), np.cos(beta)*np.cos(gamma)]
    ]
    r = np.array(r)
    return r

vertices[object_index * sec: object_index * sec + sec] = \
    (vertices[object_index * sec: object_index * sec + sec] -
     centers[object_index])@get_R(0, np.pi/4, np.pi/4) + centers[object_index]

Reposition:

Repositioning is similar to that of translation, except in this case, while repositioning we update centers with the new position value.

new_pos = np.array([1, 2, 3])

# Update vertices positions
vertices[object_index * sec: object_index * sec + sec] = \
    (vertices[object_index * sec: object_index * sec + sec] -
     centers[object_index]) + new_pos

centers[object_index] = new_pos

What is coming up next?

Currently, I am yet to figure out the orientation problem. Once I figure that out I will be ready to implement simulations without any major issues. I am also tasked with creating a wrecking ball simulation and a quadruped robot simulation.

Did you get stuck anywhere?

I did face some problems while rotating objects. My mentors suggested me to implement it via rotation matrix. I still haven't figured out the orientation problem, which I plan to work on next. Apart from these I did not face any major issues.

Thank you for reading, see you next week!!
View Blog Post