Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gazebo_ros: Added set_model_configuration service to ROS2(Humble) #1503

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from

Conversation

prakharg01
Copy link

Description

This pull request aims to enhance the functionality by porting the ROS1 service set_model_configuration to ROS2 (Humble). Upon launching the empty.world, users gain the ability to specify initial joint angles, facilitating entity spawning at custom configurations.

Changes Made

Ported ROS1 Service to ROS2 (Humble):

  • The primary focus of this pull request is the migration of the ROS1 service to ROS2 (Humble), ensuring compatibility with the latest ROS ecosystem advancements.
    .

How to Test

  1. Set up ROS2 (Humble) dependencies in your environment.

  2. Build and compile the project with the latest changes.

  3. Launch empty. world in your ROS2 environment.

  4. Write a service call to test the functionality:

void SetModelConfiguration::set_model_configuration()
{
  set_model_configuration_client_ =
    this->create_client<gazebo_msgs::srv::SetModelConfiguration>("/gazebo/set_model_configuration");

  if (set_model_configuration_client_->service_is_ready())
  {
    auto srv = std::make_shared<gazebo_msgs::srv::SetModelConfiguration::Request>();

    srv->model_name = std::string("<>");
    srv->urdf_param_name = std::string("robot_description");
    std::map<std::string, double> joint_map = {
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
    };
  for (auto & it : joint_map)
    {
      srv->joint_names.push_back(it.first);
      srv->joint_positions.push_back(it.second);
    }

    auto setmodel_future_ = set_model_configuration_client_->async_send_request(srv);
  }
  else
    RCLCPP_WARN(
      get_logger(),
      "[SetSimulationConfiguration]: not calling service using a callback, service not ready!");
}

// <> : Enter the respective arguments, this example is for a 12DOF robot.

The service is visible after launching empty.world
@prakharg01 prakharg01 changed the title Added set_model_configuration service to ROS2(Humble) gazebo_ros: Added set_model_configuration service to ROS2(Humble) Aug 21, 2023
@hushmandesmaeili
Copy link

Any updates on this?

@landersson
Copy link

I'd find this useful and would like to see this PR merged.

@graiola
Copy link

graiola commented Oct 22, 2024

no news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants