Hello,
so I have this script that i found in a package which i am using to control a robot (TFAttachement.cs)
From my terrible programming experience, I suspect that the last two lines make it so that the robot spawns at 0,0,0 and the joints are rotating around this point as well.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Unity.Robotics.ROSTCPConnector
{
public class TFAttachment : MonoBehaviour
{
[SerializeField]
string m_FrameID;
public string FrameID { get => m_FrameID; set => m_FrameID = value; }
[SerializeField]
string m_TFTopic = "/tf";
public string TFTopic { get => m_TFTopic; set => m_TFTopic = value; }
void Start()
{
transform.parent = TFSystem.GetOrCreateInstance().GetTransformObject(m_FrameID, m_TFTopic).transform;
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
}
}
}
The problem is i want to move the robot to be placed at another location than 0.0.0, so I thought to change the last to lines to this :
transform.position = new Vector3(-2,0,0);
transform.rotation = Quaternion.identity;
problem with this one is that when the robot rotates, the joints are rotating and moving relatively to the 0,0,0 point and not spawn, showing the joints flying in space.
I have been trying to find a way to fix the rotation so that is showing correctly, and relative to the new point, but to no end.
Any help would be appreciated