ADVRHumanoids / xbot2_examples

Examples and tutorials on the new XBot2 framework -- WIP
9 stars 4 forks source link

How could I run an example and simulate the robot on Rviz? #27

Closed lia2790 closed 3 years ago

lia2790 commented 3 years ago

Point

I would like to run an example and simulate the robot on Rviz, how could I do it? For example, I have my simple example: homing and I am able to run it on gazebo, how could I do if I would desire to run it on Rviz? Thank you in advance!

@liesrock @alaurenzi

alaurenzi commented 3 years ago

HI @lia2790, you can run a "dummy" mode with --hw dummy

lia2790 commented 3 years ago

Hi @alaurenzi, I tried to run the command

xbot2-core --hw dummy

after having set xbot2 configuration with

set_xbot2_config /home/liana/catkin_ws/src/CartesioTests/CartesioTestsCpp/configs/xbot/coman_config/coman_example.yaml

and set the XBOT_ROOT with

export  XBOT_ROOT=/home/liana/catkin_ws/src/CartesioTests/CartesioTestsCpp

but actually, I get the following error

liana@iitadvrlw003 ~/catkin_ws $ xbot2-core --hw dummy
terminate called after throwing an instance of 'XBot::ParseError'
  what():  specifying an hw type is incompatible with 'xbotcore_devices' field
Aborted (core dumped)

How should I fix it?

this is the content of my yaml file

XBotCore:
   config_path: "/home/liana/catkin_ws/src/CartesioTests/CartesioTestsCpp/configs/xbot/coman_config/coman.yaml"

XBotInterface:
  urdf_path: "/home/liana/catkin_ws/src/CartesioTests/CartesioTestsCpp/robots/coman/urdf/coman.urdf"
  srdf_path: "/home/liana/catkin_ws/src/CartesioTests/CartesioTestsCpp/robots/coman/srdf/coman.srdf"
  joint_map_path: "/home/liana/catkin_ws/src/CartesioTests/CartesioTestsCpp/configs/xbot/coman_config/coman_joint_map.yaml"

RobotInterface:
   framework_name: "ROS"

ModelInterface:
  model_type: "RBDL"
  is_model_floating_base: "true"

MasterCommunicationInterface:
   framework_name: "ROS"

# hal
xbotcore_devices:

    joint_master:
        master: true  # this is a master device for 'joint'
        thread: rt_main

# define threads to be created
xbotcore_threads:
    rt_main:  {sched: fifo , prio: 60, period: 0.001, core_id: 2}
    nrt_main: {sched: other, prio: 0 , period: 0.005}

xbotcore_plugins:

    # this plugin is shipped with xbot2, and it generates the
    # ROS api for the framework
    # it is not designed to be real-time safe, so it must executed
    # inside a thread with `other` priority
    ros_io: {thread: nrt_main, type: ros_io}
    ros_control: {thread: nrt_main, type: ros_control}
    # cartesio: {thread: rt_main, type: cartesio_rt}

# additional parameters that don't relate to any plugin 
xbotcore_param:
    /joint_master/tx_filter_autostart: {value: true, type: bool}
    /joint_master/tx_filter_cutoff: {value: 2.0, type: double}
    /xbot_internal/ros_io/call_timeout: {value: 1.0, type: chrono}
    /rt_slow/memory_hooks: {value: true, type: bool}
torydebra commented 3 years ago

Hi,

Just tried with my usual config (that is similar to your) and I have the same problem with --hw dummy option (and not with default option sim

I have another config that instead work also with dummy option , you can try to adapt from this:

XBotInterface:
  urdf_path: /home/embedded/TelePhysicalOperation/src/TelePhysicalOperation/tpo_gazebo/urdf/centauro_with_coms.urdf
  srdf_path: /home/embedded/TelePhysicalOperation/src/TelePhysicalOperation/tpo_gazebo/srdf/centauro.srdf
  #urdf_path: $(rospack find tpo_gazebo)/urdf/teleop_fixed_base_XBot.urdf
  #srdf_path: $(rospack find tpo_gazebo)/srdf/teleop_fixed_base_XBot.srdf

ModelInterface:
  model_type: "RBDL"
  is_model_floating_base: "false"

## XBot2 related configuration

# hal
xbotcore_device_configs:
    sim: $(rospack find centauro_config)/hal/centauro_gz.yaml
    dummy: $(rospack find centauro_config)/hal/centauro_dummy.yaml
    ec_pos: /home/embedded/xbot2_ws/configs/CentauroConfig/hal/centauro_ec_all.yaml

# define threads to be created
xbotcore_threads:
    rt_main:  {sched: fifo , prio: 60, period: 0.001, core_id: 2}
    nrt_main: {sched: other, prio: 0 , period: 0.005}

# define plugins to be loaded
xbotcore_plugins:

    # this plugin is shipped with xbot2, and it generates the
    # ROS api for the framework
    # it is not designed to be real-time safe, so it must executed
    # inside a thread with `other` priority
    ros_io: 
        thread: nrt_main
        type: ros_io 
        params:
            publish_tf: {value: "true", type: bool} 

    ros_ctrl: {thread: nrt_main, type: ros_control}

    homing:
        thread: rt_main
        type: homing

    # notice that you can reuse the same plugin, by providing
    # different names and possibly different parameters

    #tpo_control:
    #    thread: rt_main
    #    type: xbot_control_main_plugin
    #    params:
    #        js_topic: {value: "joint_states", type: string} #topic where robot state pub will read from for rviz
    #        aw_topic: {value: "wrench_commands", type: string} #topic where this plugin will read the command for wrenches
    #        logging: {value: "false", type: bool} # Log data to matlab format
    #        control_points_available: {value: "control_points_available", type: string}
    #        max_control_point: {value: 2, type: int} # Max number of forces applicable at the same time
    #        force_norm_sat: {value: 4, type: double} # saturation value for incoming input force (norm of the force is considered)

    tpo_control_cartesio:
        thread: nrt_main
        type: xbot_control_main_plugin_cartesio
        params:
            js_topic: {value: "joint_states", type: string} #topic where robot state pub will read from for rviz
            aw_topic: {value: "wrench_commands", type: string} #topic where this plugin will read the command for wrenches
            logging: {value: "true", type: bool} # Log data to matlab format
            control_points_available: {value: "control_points_available", type: string}
            max_control_point: {value: 2, type: int} # Max number of forces applicable at the same time
            force_norm_sat: {value: 4, type: double} # saturation value for incoming input force (norm of the force is considered)
            #TODO relative path
            stack_filepath: {value: "/home/embedded/TelePhysicalOperation/src/TelePhysicalOperation/telephysicaloperation/config/cartesio/centauro_stack.yaml", type: string} 

    # manipulability_visualizer:
    #     thread: nrt_main
    #     type: manipulability_visualizer
    #     params:
    #         aw_topic: {value: "/tpo_control/wrench_commands", type: string} #topic where this plugin will read the command for wrenches
    #         markers_topic: {value: "manipulability_markers", type: string}
    #         max_control_point: {value: 2, type: int} # Max number of forces applicable at the same time
    #         el_axis_scale_factor: {value: "1", type: double }
    #         el_axis_max_norm: {value: "0.6", type: double }
    #         el_axis_min_value: {value: "0.02", type: double } # when a eigenvalue is zero, we must put a low number anyway otherwise marker is not shown

# additional parameters that don't relate to any plugin 
xbotcore_param:
    /joint_master/tx_filter_autostart: {value: true, type: bool}
    /joint_master/tx_filter_cutoff: {value: 2.0, type: double}
    /xbot_internal/ros_io/call_timeout: {value: 1.0, type: chrono}
    /rt_/memory_hooks: {value: true, type: bool}
    /jm/enable_safety: {value: false, type: bool} #for ubuntu 18
liesrock commented 3 years ago

Ciao @lia2790 : the issue is related with the config file.

I helped @torydebra to fix this in https://github.com/ADVRHumanoids/TelePhysicalOperation/tree/centauro/telephysicaloperation/config

Please try to speak with him (@torydebra) to have more insight and we will later update this issue.

lia2790 commented 3 years ago

Hi @liesrock, @torydebra, thank you for your answer and help me.. I will speak with davide...

liesrock commented 3 years ago

more insight of the work done can be found here: https://github.com/ADVRHumanoids/xbot2_wip/issues/43

lia2790 commented 3 years ago

I have not access

lia2790 commented 3 years ago

Thanks to all, I am finally able to run xbot2 core successfully with the right config files (can you see them here). thanks!