ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

how to get value of joints [closed]

asked 2021-11-29 08:57:50 -0600

regoGr gravatar image

updated 2021-11-29 09:53:13 -0600

Hello everyone! I have a manipulator (with MoveIt) and I can to set my joints manually (from -90 to 90). I need to get values of joints from RVIZ to my code (to another program on Python like input values) after press the "Plan&Execute" button in the "Planning" tab. How can I do that? I don't want to get a coordinates of joint like [0.0032, 1.23453, -54.56342]. I want exactly these values (53 or -87 or something else). image description

There is one problem. I have a model with roscpp, not with rospy. And I have a launch file which I launch. It has the next code:

<launch>
  
  <arg name="pipeline" default="ompl"/>
  
  <arg name="db" default="false"/>
  
  <arg name="db_path" default="$(find manipulator_moveit_config)/default_warehouse_mongo_db"/>
  
  <arg name="debug" default="false"/>
  
  <arg name="load_robot_description" default="true"/>
  
  <arg name="execution_type" default="interpolate"/>
  
  <arg name="use_gui" default="false"/>
  <arg name="use_rviz" default="true"/>
  
  
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" unless="$(arg use_gui)">
    <rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
  </node>
  <node name="joint_state_publisher" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" if="$(arg use_gui)">
    <rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
  </node>
  
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen"/>
  
  <include file="$(dirname)/move_group.launch">
    <arg name="allow_trajectory_execution" value="true"/>
    <arg name="fake_execution" value="true"/>
    <arg name="execution_type" value="$(arg execution_type)"/>
    <arg name="info" value="true"/>
    <arg name="debug" value="$(arg debug)"/>
    <arg name="pipeline" value="$(arg pipeline)"/>
    <arg name="load_robot_description" value="$(arg load_robot_description)"/>
  </include>
  
  <include file="$(dirname)/moveit_rviz.launch" if="$(arg use_rviz)">
    <arg name="rviz_config" value="$(find manipulator_moveit_config)/launch/moveit.rviz"/>
    <arg name="debug" value="$(arg debug)"/>
  </include>
  
  <include file="$(dirname)/default_warehouse_db.launch" if="$(arg db)">
    <arg name="moveit_warehouse_database_path" value="$(arg db_path)"/>
  </include>
</launch>

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by 130s
close date 2023-06-04 23:12:26.749875

Comments

1

Hi @regoGr, I added you points so you can load your pictures.

osilva gravatar image osilva  ( 2021-11-29 09:05:01 -0600 )edit

Thank you @osilva!

regoGr gravatar image regoGr  ( 2021-11-29 09:09:10 -0600 )edit
1

Are you asking how to convert between radians and degrees?

fvd gravatar image fvd  ( 2021-11-29 09:19:48 -0600 )edit

@fvd, no. I have a program on Python and I want to send this values like input values to that program.

regoGr gravatar image regoGr  ( 2021-11-29 09:23:01 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2021-11-29 09:33:47 -0600

osilva gravatar image

Hi @regoGr

please take a look at this example: https://github.com/ros-planning/movei...

Specifically to get the joint info you can use: move_group.get_current_joint_values()

And you can find more information on the MoveIt classes: http://docs.ros.org/en/jade/api/movei...

edit flag offensive delete link more

Comments

Thank you @osilva for your answer! I made my question widely. In which file I can make .get_current_joint_values() and does it exist in roscpp?

regoGr gravatar image regoGr  ( 2021-11-29 09:54:48 -0600 )edit
1

I added a C++ tag to your question. But there is also a C++ equivalent : http://docs.ros.org/en/kinetic/api/mo...

const robot_state::RobotState & moveit::planning_interface::MoveGroupInterface::getJointValueTarget ( ) const

osilva gravatar image osilva  ( 2021-11-29 10:03:05 -0600 )edit
1

you will need to create either a Python or C++ node to access the joint information. Take a look at the MoveIt tutorials: https://ros-planning.github.io/moveit...

osilva gravatar image osilva  ( 2021-11-29 10:13:09 -0600 )edit

Thank you for your advice! I have some progress with my issue, but I can't to view result with human view. I have some code:

ros::init(argc, argv, "move_group_interface_tutorial");
...
static const std::string PLANNING_GROUP = "robot_arm";
...
const robot_state::JointModelGroup* joint_model_group =
      move_group.getCurrentState()->getJointModelGroup(PLANNING_GROUP);
...
ROS_INFO_NAMED("tutorial", "Joint state: %s", move_group.getJointValueTarget());

And for this I have the next output: [ INFO] [1638348085.283503376]: Joint state: ?)2?+V What I do wrong? I tried to do:

ROS_INFO_NAMED("tutorial", "Joint state: %s", move_group.getJointValueTarget().c_str());
but this class haven't the method c_str()

regoGr gravatar image regoGr  ( 2021-12-01 02:47:18 -0600 )edit
0

answered 2021-12-01 08:14:11 -0600

regoGr gravatar image

I made just

  std::cout << move_group.getJointValueTarget();
and get the next result:

Robot State @0x560885425600
  * Position: 0 0 0 0 0 0 0 
  * Velocity: 0 0 0 0 0 0 0 
  * Acceleration: 0 0 0 0 0 0 0 
  * Dirty Link Transforms: ASSUMED_FIXED_ROOT_JOINT
  * Dirty Collision Body Transforms: NULL
Joint transforms:
  ASSUMED_FIXED_ROOT_JOINT [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  fixed [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  base1_to_base2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  base2_to_link1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link1_to_for_link2_1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link2_1_to_for_link2_2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link2_2_to_link2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link2_to_imu_block2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link2_to_laser1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link2_to_link3 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link3_to_imu_block3 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link3_to_link4 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link4_to_for_link5_1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link5_1_to_imu_block4 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link5_1_to_link5 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link5_to_for_link5_2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link5_2_to_imu_block5 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link5_2_to_laser4 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link5_2_to_left_finger [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  left_finger_to_for_laser_left_1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_laser_left_1_to_for_laser_left_2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_laser_left_2_to_laser2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  left_finger_to_left_tip [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_link5_2_to_right_finger [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  right_finger_to_for_laser_right_1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_laser_right_1_to_for_laser_right_2 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  for_laser_right_2_to_laser3 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  right_finger_to_right_tip [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link1_to_imu_block1 [dirty]: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
Link poses:
  world: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  base1_link: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  base2_link: T.xyz = [0, 0, 0], Q.xyzw = [0.5, 0, 0, 0]
  link1: T ...
(more)
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-11-29 08:57:50 -0600

Seen: 635 times

Last updated: Dec 01 '21