Skip to content

Instantly share code, notes, and snippets.

@tylerjw
Last active June 30, 2020 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerjw/e6443adaff45490f35932fd280af10a5 to your computer and use it in GitHub Desktop.
Save tylerjw/e6443adaff45490f35932fd280af10a5 to your computer and use it in GitHub Desktop.
MoveIt JogArm -> Servo and API migration guide

MoveIt Servo migration guide

The ros package moveit_jog_arm is now named moveit_servo. If you were previously using moveit_jog_arm you will need to do a find/replace for these phrases in your code base:

  • jog_arm -> servo
  • JogArm -> Servo
  • jog_server -> servo_server

C++ API Changes

The api for moveit_servo has also recently changed. The short of it is you now use it through ros instead of with method calls. Internally it is now using ros timers instead of threads. This means that you'll need to be using ros::AsyncSpinner with multiple threads. We recommend you use at least 4 threads.

Parameters

When servo is constructed it loads parameters from rosparam. These parameters are loaded into a struct and after servo is constructed you can access that struct using the Servo::getParameters() method.

Starting / Stopping

Before you had to provide a thread to start. Now you just call the method Servo::start(). To stop you call the method Servo::stop(). This starts/stops ros timers.

Sending Commands

Instead of calling methods on the servo object you send commands to it through a ros publisher. To do that you need to setup the publisher for the type of message you are sending and the topic. The topic that moveit_servo listens to is set in the parameters. Here is how you would connect to the twist stamped command topic:

twist_stamped_pub_ =
      nh_.advertise<geometry_msgs::TwistStamped>(servo_->getParameters().cartesian_command_in_topic, 1);

Using zero-copy message passing and memory pool allocation (Optional)

To take advantage of zero copy message passing and memory pool allocations there is a new method in jog arm you can use to allocate each message you send. To use it you'll need to include moveit_servo/make_shared_from_pool.h.

auto msg = moveit::util::make_shared_from_pool<geometry_msgs::TwistStamped>();

Change drift dimensions

This is now a service and the way you ineteract with it is through ros:

change_drift_dimensions_client_ = nh_.serviceClient<moveit_msgs::ChangeDriftDimensions>(
      nh_.getNamespace() + "/" + ros::this_node::getName() + "/change_drift_dimensions");
      
...

moveit_msgs::ChangeDriftDimensions srv;
srv.request = drift_dimensions;
if (!change_drift_dimensions_client_.call(srv))
{
  ROS_ERROR_STREAM_NAMED(LOGNAME, "Failed call to service change_drift_dimensions");
  return false;
}
@AndyZe
Copy link

AndyZe commented Jun 30, 2020

Mention if this is optional or not:

To take advantage of zero copy message passing and memory pool allocations there is a new method in jog arm you can use to allocate each message you send. To use it you'll need to include moveit_servo/make_shared_from_pool.h.

@AndyZe
Copy link

AndyZe commented Jun 30, 2020

Do do that you need to setup

TO do that

@AndyZe
Copy link

AndyZe commented Jun 30, 2020

This is now a service and they way

and THE way

@AndyZe
Copy link

AndyZe commented Jun 30, 2020

Looks really good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment