Ask Your Question
1

Problem on understand the ros2_control demo code

asked 2021-08-22 10:03:21 -0500

shahrol.baharom gravatar image

updated 2021-08-23 01:23:03 -0500

I try to understand the ros2_control on differential drive hardware interface from demo code. I already send cmd_val for move the robot , and it move in rviz2. My problem is I find the log code for example like below, but none of the log show in terminal, there any setup that I need to configure to make the log show into the terminal? I have notice by change the code in ros2_control_demo_hardware/src/diffbot_system.cpp:- comment the code in read and write function did not give any effect to it.....I still can control the robot model in rviz2 by using cmd_val.... please advice

RCLCPP_INFO(
      rclcpp::get_logger("DiffBotSystemHardware"),
      "Got position state %.5f and velocity state %.5f for '%s'!", hw_positions_[i],
      hw_velocities_[i], info_.joints[i].name.c_str());

The output in terminal is show below. Any info please advice.

shahrol@cloud001:~/ros2control_ws$ ros2 launch ros2_control_demo_bringup diffbot_system.launch.py 
[INFO] [launch]: All log files can be found below /home/shahrol/.ros/log/2021-08-22-16-21-04-744139-cloud001-134924
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [134928]
[INFO] [ros2_control_node-2]: process started with pid [134930]
[INFO] [spawner.py-3]: process started with pid [134932]
[INFO] [spawner.py-4]: process started with pid [134934]
[robot_state_publisher-1] Parsing robot urdf xml string.
[robot_state_publisher-1] The root link base_link has an inertia specified in the URDF, but KDL does not support a root link with an inertia.  As a workaround, you can add an extra dummy link to your URDF.
[robot_state_publisher-1] Link caster_frontal_wheel had 0 children
[robot_state_publisher-1] Link caster_rear_wheel had 0 children
[robot_state_publisher-1] Link left_wheel had 0 children
[robot_state_publisher-1] Link right_wheel had 0 children
[robot_state_publisher-1] [INFO] [1629620465.260133412] [robot_state_publisher]: got segment base_link
[robot_state_publisher-1] [INFO] [1629620465.260239956] [robot_state_publisher]: got segment caster_frontal_wheel
[robot_state_publisher-1] [INFO] [1629620465.260257605] [robot_state_publisher]: got segment caster_rear_wheel
[robot_state_publisher-1] [INFO] [1629620465.260270296] [robot_state_publisher]: got segment left_wheel
[robot_state_publisher-1] [INFO] [1629620465.260287220] [robot_state_publisher]: got segment right_wheel
[ros2_control_node-2] [INFO] [1629620465.284592757] [controller_manager]: update rate is 100 Hz
[spawner.py-4] [INFO] [1629620465.535399234] [spawner_joint_state_broadcaster]: Waiting for /controller_manager services
[spawner.py-3] [INFO] [1629620465.557948856] [spawner_diffbot_base_controller]: Waiting for /controller_manager services
[ros2_control_node-2] [INFO] [1629620465.742730985] [controller_manager]: Loading controller 'joint_state_broadcaster'
[spawner.py-4] [INFO] [1629620465.760737880] [spawner_joint_state_broadcaster]: Loaded joint_state_broadcaster
[ros2_control_node-2] [INFO] [1629620465.762902101] [controller_manager]: Configuring controller 'joint_state_broadcaster'
[ros2_control_node-2] [INFO] [1629620465.766650485] [controller_manager]: Loading controller 'diffbot_base_controller'
[spawner.py-3] [INFO] [1629620465.780861909] [spawner_diffbot_base_controller]: Loaded diffbot_base_controller
[ros2_control_node-2] [INFO] [1629620465.800242009] [controller_manager]: Configuring controller 'diffbot_base_controller'
[spawner.py-4] [INFO] [1629620465.801521326] [spawner_joint_state_broadcaster]: Configured and started joint_state_broadcaster
[spawner.py-3] [INFO] [1629620465.821667248] [spawner_diffbot_base_controller]: Configured and started diffbot_base_controller
[INFO] [spawner.py-4]: process has finished cleanly [pid 134934]
[INFO] [spawner.py-3]: process has finished cleanly [pid 134932]
edit retag flag offensive close merge delete

Comments

What exactly do you want to archive? Do you use Gazebo or do you run the code on a real robot?

Darkproduct gravatar image Darkproduct  ( 2021-08-24 18:23:51 -0500 )edit

Hi, I would like to run the code on real robot..... hope you can help me in the process

shahrol.baharom gravatar image shahrol.baharom  ( 2021-08-24 20:22:57 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-08-24 11:48:59 -0500

shahrol.baharom gravatar image

This the solution of my problem, what you need to make the hardware interface work is by change the diffbot_system.urdf.xacro. Change it to true as show below.

<xacro:arg name="use_fake_hardware" default="false"/>

edit flag offensive delete link more
2

answered 2021-08-25 04:18:30 -0500

Darkproduct gravatar image

updated 2021-08-25 04:18:59 -0500

My problem is I find the log code for example like below, but none of the log show in terminal, there any setup that I need to configure to make the log show into the terminal?

This is probably due to not having this output={"stdout": "screen","stderr": "screen",}, (I think the short version is output="both") in your launch file, for all nodes you want to have in the terminal output.

Example:

Node(
    package="controller_manager",
    executable="ros2_control_node",
    parameters=[robot_description, controller_config_path],
    output={
        "stdout": "screen",
        "stderr": "screen",
    },
    condition=UnlessCondition(use_sim),
),

I have notice by change the code in ros2_control_demo_hardware/src/diffbot_system.cpp:- comment the code in read and write function did not give any effect to it.....

This is either, because you didn't see the output, because of the problem above, or you maybe didn't compile? I don't really know.

What exactly do you mean by "I can control the robot in rviz?" Do the wheel joints move in rviz and not on the real robot?

edit flag offensive delete link more

Comments

currently I have a robot but it not complete, It just a piece of motor, motor driver, motor encoder and Arduino mega, all already mount on a frame. I already write the firmware for Arduino mega for receive a serial data but with my own data format. Now I in process to write a serial driver for hardware interface. So I need to know what data need to send via serial. I know ros2_control will get the linear and angular speed from cmd_val so I want to see how I can pack this info and send it via serial also how I can receive speed info from my robot.

shahrol.baharom gravatar image shahrol.baharom  ( 2021-08-26 22:14:57 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2021-08-22 10:03:21 -0500

Seen: 241 times

Last updated: Aug 25 '21