The odor
The odor

Reputation: 7

How can I reposition my ArticulationBody-based robot in Unity using c# scripts?

Edit to simplify the question: I can't figure out how to use transform.position = Vector3(x,y,z) while using an ArticulationBody. I have tried changing this.transform.GetComponent<ArticulationBody>().velocity as a poor alternative, but I can't get it to move any way other than changing the angles using xDrive.target, which is insufficient. How can I use the prior two options or an alternative to move my game objects?

I am trying to teach an agent (com.unity.ml-agents) to control a robot (imported from Revolve2 using com.unity.robotics.urdf-importer), but I have trouble resetting it. The agent itself, i.e. the controller, is easy to reset using either EndEpisode() or MaxStep=...;, but the actual robot does not want to listen to anything I do

I have tried transform.position = startPositionOrSomeRandomVector3, but it seems to have no effect at all. I have also tried, even if it would be a much worse solution even if it worked, to repeatedly set each elements velocity to be towards start position:

DateTime startTime = DateTime.Now;
while ((DateTime.Now - startTime).TotalSeconds < 5) {
    articulationBody.velocity = new Vector3(1e30f,1e30f,1e30f);//this.transform.position - startPosition;
    Thread.Sleep(1000);
} 

It used to be while ((this.transform.position - startPosition).magnitude > 1), but that crashed when entering playmode. Same for the addition of Thread.Sleep(1000); the script crashed without it.

Upvotes: 1

Views: 73

Answers (0)

Related Questions