hippo5329 / linorobot2_hardware

A fork of the linorobot/linorobot2_hardware project which builds motor controller firmware for teensy, esp32 and pico to control mobile robots based on micro-ROS with various sensors support.
Apache License 2.0
14 stars 12 forks source link

Waiting for robot_description to be published on robot_description topic #15

Open Leesanhang opened 1 month ago

Leesanhang commented 1 month ago

Hi there, I am currently doing my project on ROS2. Here are some of the hardware I am using: Mecanum base, esp32-WROOM-32 microcontroller, Cytron MDD10A (Generic 1) motor drivers, A2M8 RPLidar, and a raspberry Pi 4B as the main computer.

I have followed the steps in this page exactly up until the "test_acc" part. One small issue that I did encounter was "test_sensors" part. The values are not changing even when I tilt my robot and so on. (But i guess its fine since the Gyro isn't that important for my project).

The main issue that I've been facing for the past 2 weeks was this: when I run: ros2 launch linorobot2_bringup bringup.launch.py or ros2 launch linorobot2_bringup bringup.launch.py base_serial_port:=/dev/ttyUSB0 lidar_serial_port:=/dev/ttyUSB1 micro_ros_baudrate:=921600

it gives me this in the terminal: WhatsApp Image 2024-05-22 at 15 35 47_3e9edf6d

it just waits infinitely for the robot_description to be published on the robot_description topic.

If it helps, this is my urdf file for my robot:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
  <xacro:property name="base_length" value="0.49" />
  <xacro:property name="base_width" value="0.39" />
  <xacro:property name="base_height" value="0.06" />

  <xacro:property name="wheel_radius" value="0.0723" />
  <xacro:property name="wheel_width" value="0.05" />

  <xacro:property name="laser_pose">
    <origin xyz="-0.0475 0 0.125" rpy="0 0 0"/>
  </xacro:property>

  <material name="grey">
        <color rgba="0.5 0.5 0.5 1" />
    </material>

    <material name="blue">
        <color rgba="0 0 0.5 1" />
    </material>

    <material name="pink">
        <color rgba="1 0.75 0.8 1" />
    </material>

    <!-- base_footprint (projection of base_link on the ground) -->

    <link name="base_footprint"/>

    <joint name="base_joint" type="fixed">
        <parent link="base_footprint"/>
        <child link="base_link"/>
        <origin xyz="0 0 0.2" rpy="0 0 0"/>
    </joint>

    <!-- base_link and base_scan (required for Nav2) -->

    <link name="base_link">
        <visual>
            <geometry>
                <box size="${base_length} ${base_width} ${base_height}" />
            </geometry>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <material name="blue" />
        </visual>
    </link>

    <joint name="base_scan_joint" type="fixed">
        <parent link="base_link"/>
        <child link="base_scan"/>
        <origin xyz="0 0 0.06" rpy="0 0 0"/>
    </joint>

    <link name="base_scan">
        <visual>
            <geometry>
                <cylinder radius="0.0375" length="0.04"/>
            </geometry>
            <origin xyz="0 0 0.04" rpy="0 0 0" />
            <material name="pink" />
        </visual>
    </link>

    <!-- Wheels (4 mecanum wheels) -->

    <joint name="base_left_back_wheel_joint" type="continuous">
        <parent link="base_link"/>
        <child link="left_back_wheel"/>
        <origin xyz="-0.22 0.225 -0.01" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
    </joint>

    <link name="left_back_wheel">
        <visual>
            <geometry>
                <cylinder radius="${wheel_radius}" length="${wheel_width}"/>
            </geometry>
            <origin xyz="0 0 0" rpy="1.57 0 0" />
            <material name="grey" />
        </visual>
    </link>

    <joint name="base_right_back_wheel_joint" type="continuous">
        <parent link="base_link"/>
        <child link="right_back_wheel"/>
        <origin xyz="-0.22 -0.225 -0.01" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
    </joint>

    <link name="right_back_wheel">
        <visual>
            <geometry>
                <cylinder radius="0.05" length="0.0723"/>
            </geometry>
            <origin xyz="0 0 0" rpy="1.57 0 0" />
            <material name="grey" />
        </visual>
    </link>

    <joint name="base_left_front_wheel_joint" type="continuous">
        <parent link="base_link"/>
        <child link="left_front_wheel"/>
        <origin xyz="0.22 0.225 -0.01" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
    </joint>

    <link name="left_front_wheel">
        <visual>
            <geometry>
                <cylinder radius="0.05" length="0.0723"/>
            </geometry>
            <origin xyz="0 0 0" rpy="1.57 0 0" />
            <material name="grey" />
        </visual>
    </link>

    <joint name="base_right_front_wheel_joint" type="continuous">
        <parent link="base_link"/>
        <child link="right_front_wheel"/>
        <origin xyz="0.22 -0.225 -0.01" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
    </joint>

    <link name="right_front_wheel">
        <visual>
            <geometry>
                <cylinder radius="0.05" length="0.0723"/>
            </geometry>
            <origin xyz="0 0 0" rpy="1.57 0 0" />
            <material name="grey" />
        </visual>
    </link>

</robot>

Any help to solve this issue is much appreciated, Thank youu!

Leesanhang commented 1 month ago

Btw, when I run git reset --hard , it says: HEAD is now at 4804a0b Revert "clock: disable clock_gettime from micro_ros_platformio". Should I be worried about it?

hippo5329 commented 1 month ago

I pushed update to support generic1, generic2 and esc motor interfaces. The "git reset --hard" message is fine. Now please git reset and pull my update. Remove the motor driver wires. Connect only mpu6050. Use the pin assignments in esp32_config.h .

git reset --hard git pull

  1. Build, upload firmware and connect micro-ros.
  2. select generic 1 motor interface, do not change motor pins. upload and connect micro-ros again.
  3. enable mpu6050 and upload test_sensors.
  4. upload firmware. connect micro-ros and check /imu/data.
  5. If these all work, then connect motor driver and motor. upload test_motors.
Leesanhang commented 1 month ago

Correct me if im wrong, but the ESP32 has no Pin 0 right? image

hippo5329 commented 1 month ago

I changed the motor interface pin assignments. It should work though I didn't test them yet. I ordered generic 1 similar to the cytron to test.

hippo5329 commented 1 month ago

You are right. esp32 30 pins version does not have d0. I push another update for motor pins. please pull again. Then perform the tests.

git pull

Leesanhang commented 1 month ago

Hi again, I'm trying to follow your steps closely for now. However, I am facing an issue. Every time I shut down my Pi and come back the next day, micro-ROS will just magically not work. Do you maybe have an idea on why this is happening?

hippo5329 commented 1 month ago

What is the error message from micro-ROS agent? Check 'ls /dev/ttyU* -l" to the the access. Which micro-SD you use? Write speed of the memory card is important.

Leesanhang commented 1 month ago

I mean, it just doesnt connect fully as usual. However, I just realised what the problem is. There are a few parts to your steps: serial connection test, test sensors, test motors, and test acceleration right? Starting from test sensors, I uncomment the MPU6050 line. That's when the connection is not complete when I run ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0 --baudrate 921600 . Is that normal?

Leesanhang commented 1 month ago

I think the MPU might be the main problem in my case. This is when MPU is commented out, while doing https://github.com/hippo5329/linorobot2_hardware/wiki#connect-micro-ros-agent-again-and-check-imudata-topic WhatsApp Image 2024-06-03 at 00 32 40_7fb68f68 (micro-ROS is working when MPU is not defined)

This is when MPU is uncommented, doing the same steps WhatsApp Image 2024-06-03 at 00 41 19_2f1dff3a (micro-ROS is not working when MPU is defined)

Hope this helps with helping me find out what my problem is πŸ™πŸΌπŸ™πŸΌπŸ™πŸΌ

hippo5329 commented 1 month ago

Please uncomment the mpu6050 to enable IMU and run test_sensors. Press reset button to see the messages of i2cdetect.

hippo5329 commented 1 month ago

https://github.com/hippo5329/linorobot2_hardware/wiki#connect-the-imu-and-test_sensors

hippo5329 commented 1 month ago

If you have run this step, is the IMU reading correct in test_sensors?

hippo5329 commented 1 month ago

In your previous message, micro-ros2 agent can not connect because the esp32 stopped when the IMU init failed. You should see the LED blinks 3 times per sec.

Leesanhang commented 1 month ago

I ran the test_sensors commands and this is what i got. WhatsApp Image 2024-06-03 at 01 55 28_cbfd5ce3 The random characters are due to pressing the ESP reset button.

Yes, the LED blinks thrice if micro-ROS connection failed.

hippo5329 commented 1 month ago

The IMU looks good in test_sensors. Now, upload firmware and check the monitor . Press reset button to see the messages.

cd firmware pio run -e esp32 -t upload pio device monitor -e esp32

hippo5329 commented 1 month ago

The reading of IMU changed too much. Do not move the IMU and check test_sensors later. The reading should be close to 0,0,9.8 with normal stand.

We will check the firmware boot monitor message first.

Leesanhang commented 1 month ago

This is when I ros2 run micro_ros_agent micro_ros_agent serial --dev /dev/ttyUSB0 --baudrate 921600

WhatsApp Image 2024-06-03 at 02 13 38_aa7c9167

I did not touch the IMU. Not sure why the values are fluctuating about those values.

hippo5329 commented 1 month ago

The message you just posted is topic echo /imu/data on another terminal. esp32 is connected to agent and the /imu/data topic looks fine.

hippo5329 commented 1 month ago

Post the photos of wiring of your esp32 board wiring and mpu6050.

hippo5329 commented 1 month ago

The imu will do self calibration. It will take a few seconds.

Leesanhang commented 1 month ago

Here is the temporary wiring. I have not switched to a full scale wiring since the wiring will be messy if I include the encoders and motor drivers.

WhatsApp Image 2024-06-03 at 03 07 02_0cbe2169

Blue: ESP Vin -> MPU Vcc Purple: ESP GND -> MPU GND White: ESP SCL(22) - > MPU SCL Grey: ESP SDA(21) -> MPU SDA

hippo5329 commented 1 month ago

We run the i2c at 400Khz. The 2k pull up on sda scl are required at this speed. Otherwise, i2c communication will be unstable. You may reduce the i2c speed tp 100Khz temporarily if there is no pull up.

In esp32_config.h

define BOARD_INIT { \

Wire.begin(SDA_PIN, SCL_PIN); \
Wire.setClock(400000); \

}

change 400000 to 100000 for 100Khz.

hippo5329 commented 1 month ago

IMG_20240602_121948.jpg

Leesanhang commented 1 month ago

Would this be okay? I connected the SDA and SCL pins through a 2k resistance before passing it to the MPU.

WhatsApp Image 2024-06-03 at 03 28 39_2315f3db The changes I see in the terminal now is that the fluctuations are slowed down by alot. But the values dont change when I move the IMU around.

hippo5329 commented 1 month ago

Wrong. I should draw a schematic.

Leesanhang commented 1 month ago

Okay, but yea I understand my mistake. I interpreted "pull up" wrongly. My bad.

hippo5329 commented 1 month ago

IMG_20240602_124413.jpg

Leesanhang commented 1 month ago

How about this? WhatsApp Image 2024-06-03 at 03 52 12_00d369a7 Black (Top) is from 3v3 orange and yellow is from SDA SCL of the ESP respectively Grey and white (bottom 2 wires) are to SDA and SCL of MPU respectively The resistors are in the same column with both jumpers.

hippo5329 commented 1 month ago

The value of pull up resisters does not have to be exact 2K. something around 2-2.2k will work. What are the resisters you have? If you have 1K, then put two 1K in series to get 2K.

hippo5329 commented 1 month ago

IMG_20240602_130706.jpg

hippo5329 commented 1 month ago

Anyways. Your previous wiring might work. Try out.

Leesanhang commented 1 month ago

Is this good? they're 1k resistors each.

WhatsApp Image 2024-06-03 at 04 19 07_ae6a563d

hippo5329 commented 1 month ago

Good. It should work.

Leesanhang commented 1 month ago

This is my output now. WhatsApp Image 2024-06-03 at 04 25 02_12e4fa7e

hippo5329 commented 1 month ago

Look good.

Leesanhang commented 1 month ago

I'll continue with test_motors now.

Btw, do I have to worry about the linear acceleration values? Im not moving the sensor.

hippo5329 commented 1 month ago

The reading of the IMU looks good. Minor noise.

Leesanhang commented 1 month ago

I just wanted to ask if GPIO pins 36 and 39 needs to be pulled high as well? Because I remember faintly that I did see that somewhere. Im asking this because I dont think Motor 1's encoder info is going to the ESP. Im not receiving the Motor 1 RPM. All other motors are fine.

hippo5329 commented 1 month ago

no

hippo5329 commented 1 month ago

take photo motor and encoder

Leesanhang commented 1 month ago

This is my motor, with the default encoder. The motor is rated 24V, 6000rpm, with a 1:27 reducer. The encoder is the GMR type. S2929beb9b9914f14ab6c41f57fe0e589C

hippo5329 commented 1 month ago

Screenshot from 2024-06-02 17-51-11

hippo5329 commented 1 month ago

encoder: red to 3.3V black gnd white A green B You should add a LM1117-3.3V LDO for the encoder. Do not use 3V3 of esp32, because the motor wiring is very noisy.

LM1117 Vin = esp32 Vin 5V, gnd = gnd, Vout 3.3V to encoder Vcc

Leesanhang commented 4 weeks ago

Hope this is good. (it's 3.3V) WhatsApp Image 2024-06-03 at 18 30 01_7b16546d

Leesanhang commented 4 weeks ago

I changed the whole motor itself and it works now.

Leesanhang commented 4 weeks ago

I'm getting this warning, what does the warning mean? I followed your steps, connecting the esp then only Lidar. WhatsApp Image 2024-06-03 at 23 30 19_a0efe000

hippo5329 commented 4 weeks ago

The by-path were mine. You will need to use your by-path.

Leesanhang commented 4 weeks ago

I can't seem to get past this step always. WhatsApp Image 2024-06-04 at 01 03 19_99212fed

hippo5329 commented 4 weeks ago

Try connection dev with by-path

ros2 run micro_ros_agent micro_ros_agent serial --dev your- by-path --baudrate 921600

hippo5329 commented 4 weeks ago

I didn't see your rplidar node.

cat ~/.bashrc

Please use copy & paste of your screen message. Do not use screen capture. It is difficult for me to check. My eyes are not so good.