Creating a subscriber in a class header/implementation file?

asked 2017-02-17 09:30:09 -0500

JoshMarino gravatar image

updated 2017-02-20 11:39:58 -0500

Hello,

I using the Descartes project and following along with the tutorial here. It does not matter that I am using this project, but I thought I'd mention it anyways.

I would like to have access to '/joint_states' topic in some of the Descartes classes being used throughout the tutorial. I know how to create a C++ subscriber from a C++ node, but is it also possible to add a subscriber in the Descartes classes, descartes_moveit for instance? One of the functions in that class I need to have access to the current joint_states, but would like to avoid passing it from the C++ node since it would have to get passed through 3 others classes first before reaching descartes_moveit.

Edit: I have already modified the Descartes project to use the current joint state by manually entering the joint states in two functions in two different classes. To make this repeatable, I need to grab the current joint state from /joint_states topic. I am doing this for two reasons.

  1. Using the first point in the trajectory as the current state of the robot. I am replacing the startPoint with the current state of the robot when performing djikstra
  2. Free axis for IK search is not aligned with world frame, so I am adding a transform based on the current state of the robot

Edit #2: I did not figure out how to create the subscriber in a class header/implementation file, if that even is possible. However, I did eventually figure out how to pass the current /joint_states message from my main function() to the descartes planner by passing it from the C++ node through 3 or so classes before reaching descartes_moveit.

Question still remains.

Thanks,

Josh

edit retag flag offensive close merge delete

Comments

I would like to have access to '/joint_states' topic in some of the Descartes classes being used

To avoid an xy-problem, could you please tell us what you want to do exactly?

gvdhoorn gravatar image gvdhoorn  ( 2017-02-18 04:21:11 -0500 )edit