Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Nov 19, 2023 · 1 comment

Comments

@HieskarSG
Copy link

  • [ YES ] I am at the right place and my issue is directly related to ROS#. General technical questions I would post e.g. at ROS Answers or Stack Overflow. For library-specific questions I would look for help in the corresponding library forums.
  • [ YES ] I have thoroughly read the Contributing Guideline and writing this issue is the right thing to do in my case.

I have a question!

  • [ YES ] I searched the Wiki, open and closed issues for an answer. I tried my best to find the answer by myself without success. I believe that the discussion we will have in this issue, and the solutions we might find, will help me, and likely other community members who have a similar problem.

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.

  • My OS is: Windows 10
  • My Unity Version is: 2021.3.24f1
  • My ROS Distribution is: Melodic
  • My Build Target Platform is: Gazebo 9
@MartinBischoff
Copy link
Collaborator

outdated / closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants