Robotics StackExchange | Archived questions

PID control of original robot in Gazebo

Hi, I want to speed control the robot arm by using gazebo. I wrote launch and yaml file and run, but I get error.

velocity_cougarbot.launch

<launch>
      <param name = "robot_description" textfile = "$(find make_robot2)/urdf/cougarbot.urdf"/>

      <include file = "$(find gazebo_ros)/launch/empty_world.launch"/>

     <node name = "spawn_urdf" pkg = "gazebo_ros" type = "spawn_model" args = "-param robot_description -urdf -model cougarbot"/>

    <rosparam file = "$(find make_robot2)/config/velocity_controllers.yaml" command = "load"/>

   <node name = "controller_spawner" pkg = "controller_manager" type = "spawner" args = "arm_controller"/>

   <node name = "robot_state_publisher" pkg = "robot_state_publisher" type = "robot_state_publisher"/>
</launch>

velocity_controllers,yaml

arm_controller:
  type: "velocity_controllers/JointTrajectoryController"
  joints:
    - hip
    - shoulder
    - elbow
    - wrist
  gains:
    hip: {p:10, d:1, i:1,i_clamp:1}
    shoulder: {p:10, d:1, i:1,i_clamp:1}
    elbow: {p:10, d:1, i:1,i_clamp:1}
    wrist: {p:10, d:1, i:1,i_clamp:1}

Error

user@ubuntu:~$ roslaunch make_robot2 velocity_cougarbot.launch
... logging to /home/rentaro/.ros/log/a74e4d40-003d-11ed-b0a7-bbbf09bb464c/roslaunch-ubuntu-10877.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:45057/

SUMMARY
========

PARAMETERS
 * /arm_controller/gains/elbow/d:0.1: None
 * /arm_controller/gains/elbow/i:1: None
 * /arm_controller/gains/elbow/p:100: None
 * /arm_controller/gains/hip/d:0.1: None
 * /arm_controller/gains/hip/i:1: None
 * /arm_controller/gains/hip/p:100: None
 * /arm_controller/gains/shoulder/d:0.1: None
 * /arm_controller/gains/shoulder/i:1: None
 * /arm_controller/gains/shoulder/p:100: None
 * /arm_controller/gains/wrist/d:0.1: None
 * /arm_controller/gains/wrist/i:1: None
 * /arm_controller/gains/wrist/p:100: None
 * /arm_controller/joints: ['hip', 'shoulder...
 * /arm_controller/type: velocity_controll...
 * /gazebo/enable_ros_network: True
 * /robot_description: <?xml version="1....
 * /rosdistro: noetic
 * /rosversion: 1.15.14
 * /use_sim_time: True

NODES
  /
    controller_spawner (controller_manager/spawner)
    gazebo (gazebo_ros/gzserver)
    gazebo_gui (gazebo_ros/gzclient)
    robot_state_publisher (robot_state_publisher/robot_state_publisher)
    spawn_urdf (gazebo_ros/spawn_model)

auto-starting new master
process[master]: started with pid [10885]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to a74e4d40-003d-11ed-b0a7-bbbf09bb464c
process[rosout-1]: started with pid [10895]
started core service [/rosout]
load_parameters: unable to set parameters (last param was [/arm_controller/gains/wrist/i:1=None]): cannot marshal None unless allow_none is enabled
Traceback (most recent call last):
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/__init__.py", line 347, in main
    p.start()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/parent.py", line 316, in start
    self.runner.launch()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/launch.py", line 676, in launch
    self._setup()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/launch.py", line 663, in _setup
    self._load_parameters()
  File "/opt/ros/noetic/lib/python3/dist-packages/roslaunch/launch.py", line 354, in _load_parameters
    r  = param_server_multi()
  File "/usr/lib/python3.8/xmlrpc/client.py", line 879, in __call__
    return MultiCallIterator(self.__server.system.multicall(marshalled_list))
  File "/usr/lib/python3.8/xmlrpc/client.py", line 1109, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 1447, in __request
    request = dumps(params, methodname, encoding=self.__encoding,
  File "/usr/lib/python3.8/xmlrpc/client.py", line 968, in dumps
    data = m.dumps(params)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 501, in dumps
    dump(v, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 523, in __dump
    f(self, value, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 576, in dump_array
    dump(v, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 523, in __dump
    f(self, value, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 594, in dump_struct
    dump(v, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 523, in __dump
    f(self, value, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 576, in dump_array
    dump(v, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 523, in __dump
    f(self, value, write)
  File "/usr/lib/python3.8/xmlrpc/client.py", line 527, in dump_nil
    raise TypeError("cannot marshal None unless allow_none is enabled")
TypeError: cannot marshal None unless allow_none is enabled
[rosout-1] killing on exit
[master] killing on exit

Please tell me how to solve.

Asked by Renox on 2022-07-10 07:01:58 UTC

Comments

hip: {p:10, d:1, i:1,i_clamp:1}

try with a space between your keys and your values. So instead of p:10, p: 10.

PyYAML doesn't like it when you don't separate them with at least one space.

Asked by gvdhoorn on 2022-07-10 07:15:06 UTC

It looks like your controller arguments are being assigned to the None object by default. Could you instead define your gains as:

gains:
    hip: [p, d, i, i_clamp]

You can then use indexing to obtain the arguments in your code, i.e., p = gains.hip[0].

Asked by cenwerem on 2022-07-10 18:59:33 UTC

I am a beginner of programming, so I first tried the method of gvdhoorn. As a result, I get another error.

Error

[ERROR] [1657504789.455790454, 0.308000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/hip
[ERROR] [1657504789.456985693, 0.308000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/shoulder
[ERROR] [1657504789.458574517, 0.308000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/elbow
[ERROR] [1657504789.459541456, 0.308000000]: No p gain specified for pid.  Namespace: /gazebo_ros_control/pid_gains/wrist

Asked by Renox on 2022-07-10 21:32:12 UTC

Answers