Obi Official Forum
Help Cable jitters when extending and reducing cable lengths - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Cable jitters when extending and reducing cable lengths (/thread-3873.html)



Cable jitters when extending and reducing cable lengths - rohit_dhak - 16-05-2023

Hello,



So I am controlling the position of an object attached to 4 cables (Scene shown below).



[attachment=1756]



When giving control to all the cable to move the robot. Sometimes the cables jitter continuously.

(check the video in the link below)



https://drive.google.com/file/d/139fZwr1qw8G0J2ZYvQP-ZL3oEqWSof7C/view?usp=sharing



I am using the following parameters.



# Rope Blueprint (same for all cables):

Thickness = 0.05

Resolution = 0.05

Pooled particles = 200



# All cables:

Substeps for Obi Fixed updater = 70


[attachment=1757]



Obi Solver:
[attachment=1758]

[attachment=1759]


The code to control the cable lengths is given below.

Control_c1#.cs -----

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiRope))]
public class Control_C1 : MonoBehaviour
{
    public ObiRope rope1;
    public ObiRopeCursor cursor1;
    public float rope_c1;
    public float rope_c1_rest;
    public float minLength = 0.1f;
    //public float speed = 1;
    public float cable_threshold = 0.02f;
    public float time_dt;
    public float cable1Velocity;
    public float velocityConstant = 1.0f;
    public float c1_control_ip;
    public TCPListenPipe listenerScript;





    // Use this for initialization
    void Start ()
       {
        rope1 = GetComponent<ObiRope>();
        cursor1 = GetComponent<ObiRopeCursor>();
        listenerScript = FindObjectOfType<TCPListenPipe>();
        time_dt = Time.deltaTime;
    }
    
    // Update is called once per frame
    public void Update()
    {
        rope_c1 = rope1.CalculateLength();
        rope_c1_rest = rope1.restLength;
        c1_control_ip = listenerScript.c1_action;
    }

    // Function to get current length of cable 1
    public float GetCable1CurrentLength()
    {
        return rope_c1;
    }

    // Function to get rest length of cable 1
    public float GetCable1RestLength()
    {
        return rope_c1_rest;
    }

    // Function to determine variable cable input velocity
    public float GetCable1Velocity(float length, float control_ip)
    {
        float c1_control_ip = control_ip;
        float c1_len = length;
        cable1Velocity =  velocityConstant * (c1_control_ip - c1_len);
        return cable1Velocity;
    }

    // Function to set cable 1 control input with variable velocity
    public Action SetCable1(float length, float control_ip, float velocity)
    {
        float c1_control_ip = control_ip;
        float c1_len = length;
        float c1_vel = velocity;

        return () =>
        {
            if (c1_len > c1_control_ip + cable_threshold)
            {
                cursor1.ChangeLength(c1_len - c1_vel * time_dt);
            }
            else if (c1_len < c1_control_ip - cable_threshold)
            {
                cursor1.ChangeLength(c1_len + c1_vel * time_dt);
            }
            else if (c1_len == c1_control_ip - cable_threshold)
            {
                Debug.Log("Current Length and Control input are the same for Cable 1");
                return;
            }
        };
    }


Control_main.cs -----

Code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//|Method to control all cables parallely
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void set_control()
    {
        var CableParams = paramScript.allParams.Cable;
        var Control = paramScript.allParams.Control;
        var Velocity = paramScript.allParams.Velocity;

        if (Velocity.c1_vel!= 0 && Velocity.c2_vel!= 0 && Velocity.c3_vel!= 0 && Velocity.c4_vel!= 0)
        {
            // Setting control with variable velocity
            Parallel.Invoke(c1Script.SetCable1(CableParams.Cable1, Control.c1_control_ip, Velocity.c1_vel),
                            c2Script.SetCable2(CableParams.Cable2, Control.c2_control_ip, Velocity.c2_vel),
                            c3Script.SetCable3(CableParams.Cable3, Control.c3_control_ip, Velocity.c3_vel),
                            c4Script.SetCable4(CableParams.Cable4, Control.c4_control_ip, Velocity.c4_vel));
        }

       
        // Checking applied control and setting the action_completed status
        if (Control.c1_control_ip!= 0
            && Control.c2_control_ip!= 0
            && Control.c3_control_ip!= 0
            && Control.c4_control_ip!= 0
            && Math.Abs(CableParams.Cable1 - Control.c1_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable2 - Control.c2_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable3 - Control.c3_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable4 - Control.c4_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable1_rest-CableParams.Cable1)<0.05
            && Math.Abs(CableParams.Cable2_rest-CableParams.Cable2)<0.05
            && Math.Abs(CableParams.Cable3_rest-CableParams.Cable3)<0.05
            && Math.Abs(CableParams.Cable4_rest-CableParams.Cable4)<0.05)
        {
            if (action_completed == 0.0f)
            {
                action_done = 1.0f;
                action_status = "completed";
                //Debug.Log("Action Status: " + action_status);
                action_completed = 1.0f;
            }
        }
    }

The variable velocities for all cables and the cable control inputs are received from python using a TCP connection.

Any advice or suggestion is greatly appreciated.


RE: Cable jitters when extending and reducing cable lengths - josemendez - 16-05-2023

(16-05-2023, 07:57 AM)rohit_dhak Wrote: Hello,



So I am controlling the position of an object attached to 4 cables (Scene shown below).







When giving control to all the cable to move the robot. Sometimes the cables jitter continuously.

(check the video in the link below)



https://drive.google.com/file/d/139fZwr1qw8G0J2ZYvQP-ZL3oEqWSof7C/view?usp=sharing



I am using the following parameters.



# Rope Blueprint (same for all cables):

Thickness = 0.05

Resolution = 0.05

Pooled particles = 200



# All cables:

Substeps for Obi Fixed updater = 70






Obi Solver:





The code to control the cable lengths is given below.

Control_c1#.cs -----

Code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiRope))]
public class Control_C1 : MonoBehaviour
{
    public ObiRope rope1;
    public ObiRopeCursor cursor1;
    public float rope_c1;
    public float rope_c1_rest;
    public float minLength = 0.1f;
    //public float speed = 1;
    public float cable_threshold = 0.02f;
    public float time_dt;
    public float cable1Velocity;
    public float velocityConstant = 1.0f;
    public float c1_control_ip;
    public TCPListenPipe listenerScript;





    // Use this for initialization
    void Start ()
       {
        rope1 = GetComponent<ObiRope>();
        cursor1 = GetComponent<ObiRopeCursor>();
        listenerScript = FindObjectOfType<TCPListenPipe>();
        time_dt = Time.deltaTime;
    }
    
    // Update is called once per frame
    public void Update()
    {
        rope_c1 = rope1.CalculateLength();
        rope_c1_rest = rope1.restLength;
        c1_control_ip = listenerScript.c1_action;
    }

    // Function to get current length of cable 1
    public float GetCable1CurrentLength()
    {
        return rope_c1;
    }

    // Function to get rest length of cable 1
    public float GetCable1RestLength()
    {
        return rope_c1_rest;
    }

    // Function to determine variable cable input velocity
    public float GetCable1Velocity(float length, float control_ip)
    {
        float c1_control_ip = control_ip;
        float c1_len = length;
        cable1Velocity =  velocityConstant * (c1_control_ip - c1_len);
        return cable1Velocity;
    }

    // Function to set cable 1 control input with variable velocity
    public Action SetCable1(float length, float control_ip, float velocity)
    {
        float c1_control_ip = control_ip;
        float c1_len = length;
        float c1_vel = velocity;

        return () =>
        {
            if (c1_len > c1_control_ip + cable_threshold)
            {
                cursor1.ChangeLength(c1_len - c1_vel * time_dt);
            }
            else if (c1_len < c1_control_ip - cable_threshold)
            {
                cursor1.ChangeLength(c1_len + c1_vel * time_dt);
            }
            else if (c1_len == c1_control_ip - cable_threshold)
            {
                Debug.Log("Current Length and Control input are the same for Cable 1");
                return;
            }
        };
    }


Control_main.cs -----

Code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//|Method to control all cables parallely
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void set_control()
    {
        var CableParams = paramScript.allParams.Cable;
        var Control = paramScript.allParams.Control;
        var Velocity = paramScript.allParams.Velocity;

        if (Velocity.c1_vel!= 0 && Velocity.c2_vel!= 0 && Velocity.c3_vel!= 0 && Velocity.c4_vel!= 0)
        {
            // Setting control with variable velocity
            Parallel.Invoke(c1Script.SetCable1(CableParams.Cable1, Control.c1_control_ip, Velocity.c1_vel),
                            c2Script.SetCable2(CableParams.Cable2, Control.c2_control_ip, Velocity.c2_vel),
                            c3Script.SetCable3(CableParams.Cable3, Control.c3_control_ip, Velocity.c3_vel),
                            c4Script.SetCable4(CableParams.Cable4, Control.c4_control_ip, Velocity.c4_vel));
        }

       
        // Checking applied control and setting the action_completed status
        if (Control.c1_control_ip!= 0
            && Control.c2_control_ip!= 0
            && Control.c3_control_ip!= 0
            && Control.c4_control_ip!= 0
            && Math.Abs(CableParams.Cable1 - Control.c1_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable2 - Control.c2_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable3 - Control.c3_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable4 - Control.c4_control_ip) < 0.2f
            && Math.Abs(CableParams.Cable1_rest-CableParams.Cable1)<0.05
            && Math.Abs(CableParams.Cable2_rest-CableParams.Cable2)<0.05
            && Math.Abs(CableParams.Cable3_rest-CableParams.Cable3)<0.05
            && Math.Abs(CableParams.Cable4_rest-CableParams.Cable4)<0.05)
        {
            if (action_completed == 0.0f)
            {
                action_done = 1.0f;
                action_status = "completed";
                //Debug.Log("Action Status: " + action_status);
                action_completed = 1.0f;
            }
        }
    }

The variable velocities for all cables and the cable control inputs are received from python using a TCP connection.

Any advice or suggestion is greatly appreciated.

Hi,

Both your settings and your code look correct to me. Would it be possible to share your scene/project so that we can take a closer look, by sending them to support(at)virtualmethodstudio.com? thanks!


RE: Cable jitters when extending and reducing cable lengths - rohit_dhak - 16-05-2023

(16-05-2023, 08:45 AM)josemendez Wrote: Hi,

Both your settings and your code look correct to me. Would it be possible to share your scene/project so that we can take a closer look, by sending them to support(at)virtualmethodstudio.com? thanks!


I'm refactoring the code on python side.
Will send it by today or by latest tomorrow.

Thank You.


RE: Cable jitters when extending and reducing cable lengths - rohit_dhak - 30-05-2023

(16-05-2023, 09:07 AM)rohit_dhak Wrote: I'm refactoring the code on python side.
Will send it by today or by latest tomorrow.

Thank You.


So I have sent all the files and necessary information on Virtual Method Support <support@virtualmethodstudio.com>
Please have a look and let me know if you need any more information.

Thank You.


RE: Cable jitters when extending and reducing cable lengths - rohit_dhak - 05-06-2023

(16-05-2023, 08:45 AM)josemendez Wrote: Hi,

Both your settings and your code look correct to me. Would it be possible to share your scene/project so that we can take a closer look, by sending them to support(at)virtualmethodstudio.com? thanks!


Hello,

I am not sure if you received the mail where I sent the information regarding the cable jitter issue.

I am still awiting a reply.

Thank you.


RE: Cable jitters when extending and reducing cable lengths - josemendez - 07-06-2023

(05-06-2023, 08:33 AM)rohit_dhak Wrote: Hello,

I am not sure if you received the mail where I sent the information regarding the cable jitter issue.

I am still awiting a reply.

Thank you.

Hi Rohit,

Received your message, haven't had time to look at it yet. Will do so asap and get back to you shortly.

kind regards,


RE: Cable jitters when extending and reducing cable lengths - burntends - 05-03-2024

(07-06-2023, 11:34 AM)josemendez Wrote: Hi Rohit,

Received your message, haven't had time to look at it yet. Will do so asap and get back to you shortly.

kind regards,

what was the resolution? I'm lifting a cable that is scooped up with robot arms (rope is resting in the elbow area... and it jitters and bounces when I lift and shift, even going slow.