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!

hippo5329 commented 1 month ago

what is the lidar model? rplidar A2?

hippo5329 commented 1 month ago

I want to know the installed packages in workspace.

ls linorobot2_ws/src

Leesanhang commented 1 month ago

This is my .bashrc file:

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    i) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

export LINOROBOT2_BASE=mecanum
source /opt/ros/humble/setup.bash
source ~/ros2_ws/install/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

PATH="$PATH:$HOME/.platformio/penv/bin"

Yes, my rplidar model is A2M8

In linorobot2_ws/src/ , I have micro_ros_setup, ros2.repos and uros Actually I'm not entirely sure if the linorobot2 folder should be put into the linorobot_ws or my personal ros2_ws

When I run ros2 run micro_ros_agent micro_ros_agent serial --dev your- by-path --baudrate 921600 It says serial port not found ... error 2, waiting for connection...

Leesanhang commented 1 month ago

Im not sure if this helps:

leesanhang@Pi4B:/tmp$ wget https://github.com/hippo5329/linorobot2/raw/humble/install_linorobot2.bash
--2024-05-31 13:46:06--  https://github.com/hippo5329/linorobot2/raw/humble/install_linorobot2.bash
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/hippo5329/linorobot2/humble/install_linorobot2.bash [following]
--2024-05-31 13:46:07--  https://raw.githubusercontent.com/hippo5329/linorobot2/humble/install_linorobot2.bash
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11334 (11K) [text/plain]
Saving to: ‘install_linorobot2.bash’

install_linorobot2.bash   100%[==================================>]  11.07K  --.-KB/s    in 0.005s  

2024-05-31 13:46:07 (2.24 MB/s) - ‘install_linorobot2.bash’ saved [11334/11334]

leesanhang@Pi4B:/tmp$ bash install_linorobot2.bash mecanum a2

You are installing linorobot2 on your robot computer.

===========SUMMARY============
ROBOT TYPE   : mecanum
LASER SENSOR : a2
DEPTH SENSOR : 

This installer will edit your ~/.bashrc.
Create a linorobot2_ws on your /home/leesanhang directory.
Install linorobot2 ROS2 dependencies.
Install udev rules on /etc/udev/rules.d folder.
Enter [y] to continue. y

INSTALLING NOW....

Starting >>> micro_ros_msgs
Starting >>> linorobot2
Starting >>> linorobot2_base
Starting >>> linorobot2_description                                               
--- stderr: linorobot2                                                                            
CMake Error: The source directory "/home/leesanhang/linorobot2_ws/linorobot2/linorobot2" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
gmake: *** [Makefile:226: cmake_check_build_system] Error 1
---
Failed   <<< linorobot2 [0.71s, exited with code 2]
Aborted  <<< linorobot2_base [0.69s]
Aborted  <<< linorobot2_description [0.66s]
Aborted  <<< micro_ros_msgs [2.46s]                                 

Summary: 0 packages finished [3.94s]
  1 package failed: linorobot2
  3 packages aborted: linorobot2_base linorobot2_description micro_ros_msgs
  3 packages had stderr output: linorobot2 linorobot2_base linorobot2_description
  6 packages not processed
hippo5329 commented 1 month ago

You need to use your by-path of ttyUSB0. Not like this.

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

hippo5329 commented 1 month ago

Your linorobot2 installation failed. Try to install it again.

cd /tmp
rm -rf ~/linorobot2_ws
bash install_linorobot2.bash mecanum a2
hippo5329 commented 1 month ago

The sllidar_ros2 was not placed in src. This is wrong. I am checking this.

ubuntu@jammy:~/linorobot2_ws$ ls 
build  install  log  sllidar_ros2  src

The launch for a2 is wrong. There are a2m7, a2m8 and a2m12. It needs to be resolved.

I don't have a2 to test. You will need to test it on your site. I will update the launch later. It will take some time. ubuntu@jammy:~/linorobot2_ws$ ls src linorobot2 micro_ros_setup ros2.repos uros

Leesanhang commented 1 month ago

Yea I thought it was abit odd when the sllidar folder was not in src. But I didn't dare to just change its location.

Sure, I will test the launch file with my A2 when you're done 🙏🙏 Thank you.

hippo5329 commented 1 month ago

Remember, when I refer

by-path, it means the long by-path device names on your machine.

Pull-up means adding a resistor from the signal to vcc. dio - R - vcc. usually R is 2K or 4.7K depended on requirement.

Pull-down means adding a resistor from the signal to gnd. dio - R - gnd. usually R is 10K.

Series termination means adding a resistor from the signal to outside to improve signal integrity. dio -R - outside. usually R is 10,22,33 or 110 Ohm depends on system requirement.

hippo5329 commented 1 month ago

pull-up 4.7K for 5V, 2K for 3.3V

hippo5329 commented 1 month ago

Please try the updated linorobot2 installation script.

rm /tmp/install* rm -rf ~/linorobot2_ws source /opt/ros/humble/setup.bash cd /tmp wget https://github.com/hippo5329/linorobot2/raw/humble/install_linorobot2.bash bash install_linorobot2.bash mecanum a2m8 source ~/.bashrc

Leesanhang commented 1 month ago

This is my output:

**leesanhang@Pi4B:~$** ros2 launch linorobot2_bringup bringup.launch.py     base_serial_port:=/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-port0     lidar_serial_port:=/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.4:1.0-port0
[INFO] [launch]: All log files can be found below /home/leesanhang/.ros/log/2024-05-31-06-25-44-893068-Pi4B-6550
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ekf_node-1]: process started with pid [6562]
[INFO] [micro_ros_agent-2]: process started with pid [6564]
[INFO] [joint_state_publisher-3]: process started with pid [6566]
[INFO] [robot_state_publisher-4]: process started with pid [6568]
[INFO] [sllidar_node-5]: process started with pid [6570]
[micro_ros_agent-2] [1717107951.799384] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[micro_ros_agent-2] [1717107951.802674] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4
[sllidar_node-5] [INFO] [1717107952.020719898] [sllidar_node]: SLLidar running on ROS2 package SLLidar.ROS2 SDK Version:1.0.1, SLLIDAR SDK Version:2.1.0
[sllidar_node-5] [INFO] [1717107952.047076454] [sllidar_node]: SLLidar S/N: 6BE69A86C0E09CC7A2E09DF7F9343077
[sllidar_node-5] [INFO] [1717107952.047263009] [sllidar_node]: Firmware Ver: 1.25
[sllidar_node-5] [INFO] [1717107952.047308621] [sllidar_node]: Hardware Rev: 5
[sllidar_node-5] [INFO] [1717107952.050089602] [sllidar_node]: SLLidar health status : 0
[sllidar_node-5] [INFO] [1717107952.050255306] [sllidar_node]: SLLidar health status : OK.
[robot_state_publisher-4] [INFO] [1717107952.087315732] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-4] [INFO] [1717107952.089622732] [robot_state_publisher]: got segment base_link
[robot_state_publisher-4] [INFO] [1717107952.089757639] [robot_state_publisher]: got segment camera_depth_link
[robot_state_publisher-4] [INFO] [1717107952.089803639] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-4] [INFO] [1717107952.089834343] [robot_state_publisher]: got segment front_left_wheel_link
[robot_state_publisher-4] [INFO] [1717107952.089861806] [robot_state_publisher]: got segment front_right_wheel_link
[robot_state_publisher-4] [INFO] [1717107952.089887935] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-4] [INFO] [1717107952.089913602] [robot_state_publisher]: got segment laser
[robot_state_publisher-4] [INFO] [1717107952.089939121] [robot_state_publisher]: got segment rear_left_wheel_link
[robot_state_publisher-4] [INFO] [1717107952.089965380] [robot_state_publisher]: got segment rear_right_wheel_link
[micro_ros_agent-2] [1717107952.334793] info     | Root.cpp           | create_client            | create                 | client_key: 0x3889E978, session_id: 0x81
[micro_ros_agent-2] [1717107952.334996] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x3889E978, address: 0
[sllidar_node-5] [INFO] [1717107952.390682731] [sllidar_node]: current scan mode: Express, sample rate: 4 Khz, max_distance: 12.0 m, scan frequency:10.0 Hz, 
[micro_ros_agent-2] [1717107952.427383] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x3889E978, participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.446727] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x3889E978, topic_id: 0x000(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.453512] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x3889E978, publisher_id: 0x000(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.476448] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x3889E978, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[micro_ros_agent-2] [1717107952.483331] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x3889E978, topic_id: 0x001(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.488012] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x3889E978, publisher_id: 0x001(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.509029] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x3889E978, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[micro_ros_agent-2] [1717107952.514478] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x3889E978, topic_id: 0x002(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.519086] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x3889E978, publisher_id: 0x002(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.536609] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x3889E978, datawriter_id: 0x002(5), publisher_id: 0x002(3)
[micro_ros_agent-2] [1717107952.547916] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x3889E978, topic_id: 0x003(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.554708] info     | ProxyClient.cpp    | create_subscriber        | subscriber created     | client_key: 0x3889E978, subscriber_id: 0x000(4), participant_id: 0x000(1)
[micro_ros_agent-2] [1717107952.570184] info     | ProxyClient.cpp    | create_datareader        | datareader created     | client_key: 0x3889E978, datareader_id: 0x000(6), subscriber_id: 0x000(4)
[joint_state_publisher-3] [INFO] [1717107953.520680509] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic...
^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[robot_state_publisher-4] [INFO] [1717107956.212791896] [rclcpp]: signal_handler(signum=2)
[ERROR] [micro_ros_agent-2]: process has died [pid 6564, exit code -2, cmd '/home/leesanhang/linorobot2_ws/install/micro_ros_agent/lib/micro_ros_agent/micro_ros_agent serial --dev /dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-port0 --baudrate 921600 --ros-args -r __node:=micro_ros_agent'].
[ekf_node-1] [INFO] [1717107956.213465822] [rclcpp]: signal_handler(signum=2)
[sllidar_node-5] [INFO] [1717107956.389013859] [sllidar_node]: Stop motor
[INFO] [robot_state_publisher-4]: process has finished cleanly [pid 6568]
[INFO] [ekf_node-1]: process has finished cleanly [pid 6562]
[INFO] [sllidar_node-5]: process has finished cleanly [pid 6570]
[INFO] [joint_state_publisher-3]: process has finished cleanly [pid 6566]

Everything seems to be running well, with the teleop too.

These are my topics and nodes:

leesanhang@Pi4B:~$ ros2 node list
/ekf_filter_node
/esp32
/joint_state_publisher
/robot_state_publisher
/sllidar_node
/transform_listener_impl_aaaadeaf7ec0
leesanhang@Pi4B:~$ ros2 topic list
/battery
/cmd_vel
/diagnostics
/imu/data
/joint_states
/odom
/odom/unfiltered
/parameter_events
/robot_description
/rosout
/scan
/set_pose
/tf
/tf_static
hippo5329 commented 1 month ago

good. check these,

ros2 topic hz /imu/data ros2 topic hz /odom ros2 topic hz /scan

hippo5329 commented 1 month ago

The hz should be close to 10. Then you may proceed to slam, save the map and navigation with the map.

hippo5329 commented 1 month ago

You will need to update the velocity smoother for mecanum drive.

https://github.com/hippo5329/linorobot2_hardware/wiki#velocity-smoother

Leesanhang commented 1 month ago

Hi again, yesterday, everything was doing fine. Both hardware and software wise. Then I removed all the wirings to swap out the faulty motor. When I rewired it today (exactly same way), and ran the software part again, it was okay but when I tried moving the robot motors, it's vibrating front and back, jerking the whole robot. Do you maybe know what is the problem?

hippo5329 commented 1 month ago

I would suggest test_motors and test_acc to diagnosis the problem. You must have enough space to run test_acc on the groud.

Leesanhang commented 4 weeks ago

So I took your advice and ran test_motors and test_acc. Everything was doing fine. When I do the ros2 launch bring up command, and then use the teleop to move the robot, motor 1 is giving very weird outputs. For example, it can only turn in 1 direction and once it starts, it doesn't stop. When I pull out the encoder for motor 1, everything is okay, or at least much better. I've checked all my wiring, and everything is good, everything is grounded properly.

hippo5329 commented 4 weeks ago

please post moniter output

Leesanhang commented 4 weeks ago

This is my test_motor output:

MOTOR1 FWD RPM   -335.5      0.0      0.0      0.0
MOTOR1 FWD RPM   -335.6      0.0      0.0      0.0
MOTOR1 FWD RPM   -335.6      0.0      0.0      0.0
MOTOR1 FWD RPM   -335.6      0.0      0.0      0.0
MOTOR1 FWD RPM   -335.7      0.0      0.0      0.0
MOTOR1 FWD RPM   -335.7      0.0      0.0      0.0
MOTOR1 FWD RPM   -335.7      0.0      0.0      0.0
MOTOR1 SPEED  -1.76 m/s  -7.03 rad/s STOP -0.025 m
MOTOR2 FWD RPM     -4.8    330.6      0.0      0.0
MOTOR2 FWD RPM      0.0    337.7      0.0      0.0
MOTOR2 FWD RPM      0.0    337.9      0.0      0.0
MOTOR2 FWD RPM      0.0    338.1      0.0      0.0
MOTOR2 FWD RPM      0.0    338.3      0.0      0.0
MOTOR2 FWD RPM      0.0    338.4      0.0      0.0
MOTOR2 FWD RPM      0.0    338.5      0.0      0.0
MOTOR2 FWD RPM      0.0    338.7      0.0      0.0
MOTOR2 SPEED   1.77 m/s   7.09 rad/s STOP  0.031 m
MOTOR3 FWD RPM      0.0      5.9    315.7      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 FWD RPM      0.0      0.0    321.8      0.0
MOTOR3 SPEED   1.68 m/s   6.74 rad/s STOP  0.027 m
MOTOR4 FWD RPM      0.0      0.0      5.1    338.0
MOTOR4 FWD RPM      0.0      0.0      0.0    345.9
MOTOR4 FWD RPM      0.0      0.0      0.0    346.5
MOTOR4 FWD RPM      0.0      0.0      0.0    346.7
MOTOR4 FWD RPM      0.0      0.0      0.0    346.9
MOTOR4 FWD RPM      0.0      0.0      0.0    347.1
MOTOR4 FWD RPM      0.0      0.0      0.0    347.4
MOTOR4 FWD RPM      0.0      0.0      0.0    347.5
MOTOR4 SPEED   1.82 m/s   7.28 rad/s STOP  0.032 m
MOTOR1 REV RPM    318.8      0.0      0.0      6.2
MOTOR1 REV RPM    324.0      0.0      0.0      0.0
MOTOR1 REV RPM    324.0      0.0      0.0      0.0
MOTOR1 REV RPM    324.1      0.0      0.0      0.0
MOTOR1 REV RPM    324.0      0.0      0.0      0.0
MOTOR1 REV RPM    324.0      0.0      0.0      0.0
MOTOR1 REV RPM    324.0      0.0      0.0      0.0
MOTOR1 REV RPM    323.9      0.0      0.0      0.0
MOTOR1 SPEED   1.70 m/s   6.78 rad/s STOP  0.023 m
MOTOR2 REV RPM      4.5   -316.6      0.0      0.0
MOTOR2 REV RPM      0.0   -322.8      0.0      0.0
MOTOR2 REV RPM      0.0   -323.0      0.0      0.0
MOTOR2 REV RPM      0.0   -323.1      0.0      0.0
MOTOR2 REV RPM      0.0   -323.1      0.0      0.0
MOTOR2 REV RPM      0.0   -323.0      0.0      0.0
MOTOR2 REV RPM      0.0   -322.7      0.0      0.0
MOTOR2 REV RPM      0.0   -322.2      0.0      0.0
MOTOR2 SPEED  -1.69 m/s  -6.75 rad/s STOP -0.028 m
MOTOR3 REV RPM      0.0     -5.3   -348.8      0.0
MOTOR3 REV RPM      0.0      0.0   -356.2      0.0
MOTOR3 REV RPM      0.0      0.0   -356.3      0.0
MOTOR3 REV RPM      0.0      0.0   -356.4      0.0
MOTOR3 REV RPM      0.0      0.0   -356.3      0.0
MOTOR3 REV RPM      0.0      0.0   -356.2      0.0
MOTOR3 REV RPM      0.0      0.0   -356.3      0.0
MOTOR3 REV RPM      0.0      0.0   -356.2      0.0
MOTOR3 SPEED  -1.86 m/s  -7.46 rad/s STOP -0.033 m
MOTOR4 REV RPM      0.0      0.0     -6.3   -319.4
MOTOR4 REV RPM      0.0      0.0      0.0   -326.0
MOTOR4 REV RPM      0.0      0.0      0.0   -326.0
MOTOR4 REV RPM      0.0      0.0      0.0   -326.0
MOTOR4 REV RPM      0.0      0.0      0.0   -326.0
MOTOR4 REV RPM      0.0      0.0      0.0   -325.9
MOTOR4 REV RPM      0.0      0.0      0.0   -325.8
MOTOR4 REV RPM      0.0      0.0      0.0   -326.0

Apologies, I accidentally reverted the motor 1 positive and negative.

Leesanhang commented 4 weeks ago

This is my test_acc output:

MAX VEL   0.88   0.85 m/s    3.63 rad/s
MIN VEL  -0.89  -0.89 m/s   -3.22 rad/s
MAX ACC  20.10  20.03 m/s2   73.06 rad/s2
MIN ACC -19.72 -19.05 m/s2  -81.69 rad/s2
IMU ACC   2.05  -2.24 m/s2
time to 0.9x max vel   0.08 sec
distance to stop   0.03 m
BAT  3.73V MIN  0.21V
MAX PWM 1023.0 -1023.0
MAX VEL   0.85   0.86 m/s    3.75 rad/s
MIN VEL  -0.86  -0.90 m/s   -3.33 rad/s
MAX ACC  19.56  20.60 m/s2   75.59 rad/s2
MIN ACC -19.21 -19.66 m/s2  -84.36 rad/s2
IMU ACC   2.13  -2.94 m/s2
time to 0.9x max vel   0.08 sec
distance to stop   0.14 rad
BAT  4.21V MIN  1.20V
MAX PWM 1023.0 -1023.0
MAX VEL   0.88   0.85 m/s    3.64 rad/s
MIN VEL  -0.89  -0.89 m/s   -3.22 rad/s
MAX ACC  20.06  19.89 m/s2   73.31 rad/s2
MIN ACC -19.87 -19.13 m/s2  -82.35 rad/s2
IMU ACC   3.08  -1.04 m/s2
time to 0.9x max vel   0.08 sec
distance to stop   0.03 m
BAT  3.61V MIN  0.68V
[ 33084][E][Wire.cpp:513] requestFrom(): i2cRead returned Error 263
MAX PWM 1023.0 -1023.0
MAX VEL   0.85   0.86 m/s    3.75 rad/s
MIN VEL  -0.86  -0.90 m/s   -3.33 rad/s
MAX ACC  19.47  20.33 m/s2   75.37 rad/s2
MIN ACC -19.36 -19.55 m/s2  -84.79 rad/s2
IMU ACC   2.59  -3.41 m/s2
time to 0.9x max vel   0.08 sec
distance to stop   0.14 rad
BAT  4.31V MIN  1.25V
MAX PWM  511.5 -511.5
MAX VEL   0.43   0.42 m/s    1.77 rad/s
MIN VEL  -0.43  -0.43 m/s   -1.60 rad/s
MAX ACC   9.92   9.62 m/s2   38.49 rad/s2
MIN ACC  -9.75  -9.57 m/s2  -38.63 rad/s2
IMU ACC   1.58  -0.17 m/s2
time to 0.9x max vel   0.06 sec
distance to stop   0.02 m
BAT  3.48V MIN  0.99V
MAX PWM  511.5 -511.5
MAX VEL   0.42   0.42 m/s    1.80 rad/s
MIN VEL  -0.42  -0.44 m/s   -1.64 rad/s
MAX ACC   9.50   9.69 m/s2   38.31 rad/s2
MIN ACC  -9.61  -9.57 m/s2  -41.40 rad/s2
IMU ACC   2.42  -2.09 m/s2
time to 0.9x max vel   0.06 sec
distance to stop   0.07 rad
BAT  2.98V MIN  0.96V
MAX PWM  511.5 -511.5
MAX VEL   0.43   0.41 m/s    1.77 rad/s
MIN VEL  -0.43  -0.43 m/s   -1.60 rad/s
MAX ACC   9.92   9.63 m/s2   38.30 rad/s2
MIN ACC  -9.81  -9.53 m/s2  -39.05 rad/s2
IMU ACC   2.08  -0.17 m/s2
time to 0.9x max vel   0.06 sec
distance to stop   0.02 m
BAT  3.55V MIN  1.04V

Hope it helps.

Leesanhang commented 4 weeks ago

This is the weird thing about the motor. I used a detached motor for a better visualization.

Uploading WhatsApp Video 2024-06-06 at 04.23.36_41da4a00.mp4…

hippo5329 commented 4 weeks ago

Please take a picture of the robot to see four wheels. The Mecanum wheels must be installed correctly. Front wheels pair and back wheels pair are different. It should look like a big X from the top.

Please correct the motor polarity and run test_motors / test_acc. In test_motors, the wheels do not touch ground. But in test_acc, the robot needs to be on the ground. The robot will move very fast. Be very careful. The robot will move forward and backward. Rotate counterclockwise and clockwise.

Can you post the video on youtube?

Leesanhang commented 4 weeks ago

The problem was the polarity.

However, I am facing a micro-ROS issue now and I'm hoping to get some guidance on this. This is when I run the robot bringup command.

leesanhang@Pi4B:~$ ros2 launch linorobot2_bringup bringup.launch.py     base_serial_port:=/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.2:1.0-port0     lidar_serial_port:=/dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-port0
[INFO] [launch]: All log files can be found below /home/leesanhang/.ros/log/2024-05-31-05-35-05-279499-Pi4B-4745
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [ekf_node-1]: process started with pid [4813]
[INFO] [micro_ros_agent-2]: process started with pid [4815]
[INFO] [joint_state_publisher-3]: process started with pid [4817]
[INFO] [robot_state_publisher-4]: process started with pid [4820]
[INFO] [sllidar_node-5]: process started with pid [4827]
[micro_ros_agent-2] [1717104913.972887] info     | TermiosAgentLinux.cpp | init                     | running...             | fd: 3
[micro_ros_agent-2] [1717104913.973905] info     | Root.cpp           | set_verbose_level        | logger setup           | verbose_level: 4
[micro_ros_agent-2] [1717104914.182600] info     | Root.cpp           | create_client            | create                 | client_key: 0x604407F2, session_id: 0x81
[micro_ros_agent-2] [1717104914.182787] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x604407F2, address: 0
[robot_state_publisher-4] [INFO] [1717104914.457506579] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-4] [INFO] [1717104914.457979727] [robot_state_publisher]: got segment base_link
[robot_state_publisher-4] [INFO] [1717104914.458082561] [robot_state_publisher]: got segment camera_depth_link
[robot_state_publisher-4] [INFO] [1717104914.458122487] [robot_state_publisher]: got segment camera_link
[robot_state_publisher-4] [INFO] [1717104914.458151116] [robot_state_publisher]: got segment front_left_wheel_link
[robot_state_publisher-4] [INFO] [1717104914.458178802] [robot_state_publisher]: got segment front_right_wheel_link
[robot_state_publisher-4] [INFO] [1717104914.458307857] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-4] [INFO] [1717104914.458351857] [robot_state_publisher]: got segment laser
[robot_state_publisher-4] [INFO] [1717104914.458382746] [robot_state_publisher]: got segment rear_left_wheel_link
[robot_state_publisher-4] [INFO] [1717104914.458412209] [robot_state_publisher]: got segment rear_right_wheel_link
[micro_ros_agent-2] [1717104914.466890] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x604407F2, participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.498531] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x604407F2, topic_id: 0x000(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.514749] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x604407F2, publisher_id: 0x000(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.530972] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x604407F2, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[sllidar_node-5] [INFO] [1717104914.541342727] [sllidar_node]: SLLidar running on ROS2 package SLLidar.ROS2 SDK Version:1.0.1, SLLIDAR SDK Version:2.1.0
[micro_ros_agent-2] [1717104914.547264] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x604407F2, topic_id: 0x001(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.558755] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x604407F2, publisher_id: 0x001(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.566465] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x604407F2, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[micro_ros_agent-2] [1717104914.576680] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x604407F2, topic_id: 0x002(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.590002] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x604407F2, publisher_id: 0x002(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.610584] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x604407F2, datawriter_id: 0x002(5), publisher_id: 0x002(3)
[micro_ros_agent-2] [1717104914.615586] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x604407F2, topic_id: 0x003(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104914.621520] info     | ProxyClient.cpp    | create_subscriber        | subscriber created     | client_key: 0x604407F2, subscriber_id: 0x000(4), participant_id: 0x000(1)
[sllidar_node-5] [INFO] [1717104914.625870875] [sllidar_node]: SLLidar S/N: 6BE69A86C0E09CC7A2E09DF7F9343077
[sllidar_node-5] [INFO] [1717104914.626406875] [sllidar_node]: Firmware Ver: 1.25
[sllidar_node-5] [INFO] [1717104914.626509357] [sllidar_node]: Hardware Rev: 5
[sllidar_node-5] [INFO] [1717104914.633722320] [sllidar_node]: SLLidar health status : 0
[sllidar_node-5] [INFO] [1717104914.633914061] [sllidar_node]: SLLidar health status : OK.
[micro_ros_agent-2] [1717104914.674358] info     | ProxyClient.cpp    | create_datareader        | datareader created     | client_key: 0x604407F2, datareader_id: 0x000(6), subscriber_id: 0x000(4)
[sllidar_node-5] [INFO] [1717104914.984629783] [sllidar_node]: current scan mode: Express, sample rate: 4 Khz, max_distance: 12.0 m, scan frequency:10.0 Hz, 
[joint_state_publisher-3] [INFO] [1717104916.308042356] [joint_state_publisher]: Waiting for robot_description to be published on the robot_description topic...
[micro_ros_agent-2] [1717104930.907725] info     | Root.cpp           | delete_client            | delete                 | client_key: 0x604407F2
[micro_ros_agent-2] [1717104930.909726] info     | SessionManager.hpp | destroy_session          | session closed         | client_key: 0x604407F2, address: 0
[micro_ros_agent-2] [1717104930.938645] info     | Root.cpp           | create_client            | create                 | client_key: 0x57A4A9FF, session_id: 0x81
[micro_ros_agent-2] [1717104930.938714] info     | SessionManager.hpp | establish_session        | session established    | client_key: 0x57A4A9FF, address: 0
[micro_ros_agent-2] [1717104931.010435] info     | ProxyClient.cpp    | create_participant       | participant created    | client_key: 0x57A4A9FF, participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.015549] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x57A4A9FF, topic_id: 0x000(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.019623] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x57A4A9FF, publisher_id: 0x000(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.026763] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x57A4A9FF, datawriter_id: 0x000(5), publisher_id: 0x000(3)
[micro_ros_agent-2] [1717104931.031753] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x57A4A9FF, topic_id: 0x001(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.036422] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x57A4A9FF, publisher_id: 0x001(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.042683] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x57A4A9FF, datawriter_id: 0x001(5), publisher_id: 0x001(3)
[micro_ros_agent-2] [1717104931.048564] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x57A4A9FF, topic_id: 0x002(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.055204] info     | ProxyClient.cpp    | create_publisher         | publisher created      | client_key: 0x57A4A9FF, publisher_id: 0x002(3), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.072656] info     | ProxyClient.cpp    | create_datawriter        | datawriter created     | client_key: 0x57A4A9FF, datawriter_id: 0x002(5), publisher_id: 0x002(3)
[micro_ros_agent-2] [1717104931.090499] info     | ProxyClient.cpp    | create_topic             | topic created          | client_key: 0x57A4A9FF, topic_id: 0x003(2), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.095011] info     | ProxyClient.cpp    | create_subscriber        | subscriber created     | client_key: 0x57A4A9FF, subscriber_id: 0x000(4), participant_id: 0x000(1)
[micro_ros_agent-2] [1717104931.107278] info     | ProxyClient.cpp    | create_datareader        | datareader created     | client_key: 0x57A4A9FF, datareader_id: 0x000(6), subscriber_id: 0x000(4)

When I continuously press on for example: forward, the client and session is destroyed. The issue is when I start running the robot controller - teleop_twist_keyboard and try to move the robot, the micro-ROS will suddenly disconnect and cause a major lag in my robot movement.

hippo5329 commented 4 weeks ago

This might be power issue. You will need to add 220-470uF cap to every power. Put the cap near the load. Post the photos of all your parts and wiring. You should add a battery voltage sensor as I wrote in my wiki. VBAT -- 33K -- adc pin -- 10K - gnd

Leesanhang commented 4 weeks ago

Sorry, capacitor to the load of what exactly?

Leesanhang commented 4 weeks ago

Sorry, Im not too sure if the photo is gonna do you any good. But the signal wiring has been verified. The IMU is directly below the Lidar.

WhatsApp Image 2024-06-07 at 02 06 23_76222db2

hippo5329 commented 4 weeks ago

24v battery

68k -- adc -- 10k -- gnd

Leesanhang commented 4 weeks ago

Sure, but the 24V solely powers the motors only though. Would it fix the micro-ROS connection problem?

hippo5329 commented 4 weeks ago

solder a 220uF cap to vin gnd of esp32. solder 220uF to vin gnd of each motor driver. note the cap are polarized.

hippo5329 commented 4 weeks ago

how do you power pi

Leesanhang commented 4 weeks ago

I have not actually found a solution to powering my Pi yet. For now my solution is a powerbank. But Im not sure if that would be sufficient.

hippo5329 commented 4 weeks ago

change the vin of step down 3.3V of encoders, to 24v. you had shown me the photo before.

Leesanhang commented 4 weeks ago

Okay so actually I tried to use an external supply (USB) from a powerbank and stepped it down to 3.3V and connected a common ground with the ESP. It is slightly better but the micro-ROS is still destroying the session and client sometimes.

hippo5329 commented 4 weeks ago

cap to filter power noise is important.

check "sudo dmesg", if there any low voltage warning?

The power bank output voltage maybe to low. You can use a step down from 24V, and set the voltage to around 5.15V

Leesanhang commented 4 weeks ago

No, there is no low power warning. The 5.15V is for the encoders you mean?

hippo5329 commented 4 weeks ago

no. 5.15v for pi

hippo5329 commented 4 weeks ago

there are many connecters in the power and ground. they will create noise. try remove some connectors.for the switch, there is no need to have ⁰8 switch both wires. you canhe

hippo5329 commented 4 weeks ago

no need to switch both 24v and gnd. switch 24v is enough.

hippo5329 commented 4 weeks ago

do you use two 24v batteries?

hippo5329 commented 4 weeks ago

I havevt ried to remove those contact resistence with soldering if possible. I removed the power switch and replaced with a power mosfet.

Leesanhang commented 4 weeks ago

Oh, I see. step it down to 5.15 for Pi. I will check the current levels and try to power my Pi with that. I use 2 12V batteries in series. Unfortunately I don't have 24V batteries.

Pardon me, but what do you mean by the contact resistance?

hippo5329 commented 4 weeks ago

every connecter contact snd switch contact has resistence. though you might think the resistence is very low, the motor current will create voltage , ie noise.

hippo5329 commented 4 weeks ago

the noise can make the signal run into faulty level, lower than gnd or higher than vcc. and cause trouble to the controller.

the surge current when motor start or stop is very strong when it is loaded with weight.

hippo5329 commented 4 weeks ago

if one motor draw 3A, four motors will draw 12A. a contact of 0.1 ohm will mkae 1.2v noise. three contacts will add 3.6v noise.so you have to use very thick wires and reduce the resistence as much as possible.

hippo5329 commented 4 weeks ago

I use 14 awg wire. other makers may use 12 awg wire.

hippo5329 commented 4 weeks ago

Please try reduce the motor max rpm and current with

define MOTOR_MAX_RPM [ your rpm / 2 ] // motor's max RPM

define PWM_MAX (pow(2, PWM_BITS) - 1) / 2

Leesanhang commented 3 weeks ago

I simply added capacitors to my motor terminals, would that be okay? I use very big diameter wires actually. If i remember correctly, It's probably 22 or 24 AWG wires.

hippo5329 commented 3 weeks ago

Wrong. Do not add cap to motor terminal. Add cap to VIN and GND of motor control boards.

The larger AWG number, the thinner wire. So AWG 22/24 are very thin.

hippo5329 commented 3 weeks ago

https://en.wikibooks.org/wiki/Engineering_Tables/Standard_Wire_Gauge