Skip to content

Commit 497e506

Browse files
committed
bug #15: if robot is not compliant stiffness is set to 1000. otherwise
to 0 and gravity will pull the arms down
1 parent dc64573 commit 497e506

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Packages/ReachySimulator/Scripts/JointController.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public class JointController : MonoBehaviour
88
private bool changed;
99
private ArticulationBody articulation;
1010

11+
private bool compliant = false;
12+
1113
void Start()
1214
{
1315
articulation = GetComponent<ArticulationBody>();
@@ -19,6 +21,7 @@ void FixedUpdate()
1921
{
2022
var drive = articulation.xDrive;
2123
drive.target = targetPosition;
24+
drive.stiffness = compliant ? 0 : 1000;
2225
articulation.xDrive = drive;
2326

2427
changed = false;
@@ -31,6 +34,12 @@ public void RotateTo(float newTargetPosition)
3134
changed = true;
3235
}
3336

37+
public void IsCompliant(bool comp)
38+
{
39+
compliant = comp;
40+
changed = true;
41+
}
42+
3443
public float GetPresentPosition()
3544
{
3645
return Mathf.Rad2Deg * articulation.jointPosition[0];

Packages/ReachySimulator/Scripts/ReachyController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ void Update()
162162
{
163163
JointController joint = m.gameObject.GetComponent<JointController>();
164164
joint.RotateTo(m.targetPosition);
165+
joint.IsCompliant(m.isCompliant);
165166

166167
m.presentPosition = joint.GetPresentPosition();
167168
}

0 commit comments

Comments
 (0)