siemens / ros-sharp

ROS# is a set of open source software libraries and tools in C# for communicating with ROS from .NET applications, in particular Unity3D
Apache License 2.0
987 stars 373 forks source link

Having trouble with step "2.3 Gazebo Simulation Setup" / Turtlebot3 not moving in GAZEBO and missing some nodes in RQT GRAPH #449

Open HieskarSG opened 1 year ago

HieskarSG commented 1 year ago

I have a question!

Here is my question: I'm using ubuntu 18.04.5, ROS Melodic, Gazebo 9, Unity 2021.3.24f1 and turtlebot3.

I followed all the tutorials and videos. I'm using a xbox controller to move my robot here's my code if it helps for context:

using UnityEngine;

public class ControlDeRobot : MonoBehaviour
{

    public float moveSpeed = 1.0f; // Velocidad de movimiento del objeto
    public float rotationSpeed = 100.0f; // Velocidad de rotación del objeto

    private bool DeadmanPressed = false;
    private bool PlusVelInput = false;
    private bool MinVelInput = false;
    private float VariadorVel = 0.0f;

    void Update()
    {

        //Verificar si el botón de hombre muerto está presionado
        //El botón "DeadmanButton" está configurado como "LT" en el mando Xbox en Input Manager
        DeadmanPressed = Input.GetButton("DeadmanButton"); 

        if (DeadmanPressed)
        {
            // Captura la entrada de los ejes horizontal y vertical
        float horizontalInput = Input.GetAxis("MoverHorizontal");
        float verticalInput = Input.GetAxis("MoverVertical");

           //Captura la entrada de los botones de subir y bajar velocidad
         PlusVelInput = Input.GetButton("PlusVel");
         MinVelInput = Input.GetButton("MinVel");

            // Calcula el desplazamiento en función de la entrada
            Vector3 moveDirection = new Vector3(horizontalInput, 0, verticalInput).normalized;

            //Aumenta el valor del variador de velocidad en 0.2 cada que se presione botón PlusVel
            if (PlusVelInput)
            {
                VariadorVel = VariadorVel + 0.1f;            
            }

            //Disminuye el valor del variador de velocidad en 0.2 cada que se presione el botón MinVel
            if (MinVelInput)
            {
                VariadorVel = VariadorVel - 0.1f;
                 }

            moveSpeed = moveSpeed + VariadorVel;
            moveSpeed = Mathf.Clamp(moveSpeed, 0.0f, 6.0f); // Limita la velocidad a un rango de 0 a 5 

            // Mueve el objeto en la dirección calculada
            transform.Translate(moveDirection * moveSpeed * Time.deltaTime);

        // Captura la entrada de los ejes de rotación (joysticks del control de Xbox)
        float rotationInput = Input.GetAxis("Xbox360RightStickX");

        // Calcula la rotación en función de la entrada
        Vector3 rotation = new Vector3(0, rotationInput, 0) * rotationSpeed * Time.deltaTime;

        // Rota el objeto en la dirección calculada
        transform.Rotate(rotation);
    }
}
}

First I use: roslaunch file_server ros_sharp_communication.launch , then I play my scene in UNITY, after that I run: roslaunch file_server visualize_robot.launch model:=$(rospack find x_1)/turtlebot3_burger.urdf.urdf (I've done the steps in unity transfer URDF to ROS). Finally y use: roslaunch gazebo_simulation_scene gazebo_simulation_scene.launch

In MY rqt GRAPH it show this: image

instead of this that is shown in the video: image

I've researched a lot, but haven't figured out what is wrong and why my turtlebot 3 is not moving in gazebo along with the one in Unity.

Thank you so much for your help.

MartinBischoff commented 10 months ago

outdated / closing due to inactivity