16-05-2023, 07:57 AM
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/139fZwr1...sp=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 -----
Control_main.cs -----
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.
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/139fZwr1...sp=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.