Skip to content

Commit

Permalink
Polish - licenses, remove boost dependency, remove silly log lines
Browse files Browse the repository at this point in the history
  • Loading branch information
ccpowers committed Apr 20, 2017
1 parent 50c306e commit d48dbce
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 58 deletions.
2 changes: 0 additions & 2 deletions sawyer_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ find_package(catkin
find_package(GAZEBO REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")

find_package(Boost REQUIRED COMPONENTS system)

catkin_package(
CATKIN_DEPENDS
Expand All @@ -28,7 +27,6 @@ link_directories(
)

include_directories(include
${Boost_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
${GAZEBO_INCLUDE_DIRS}
)
Expand Down
1 change: 0 additions & 1 deletion sawyer_gazebo/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<build_depend>libgazebo7-dev</build_depend>
<build_depend>gazebo_ros</build_depend>
<build_depend>gazebo_ros_control</build_depend>
<build_depend>sawyer_description</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>intera_core_msgs</build_depend>

Expand Down
14 changes: 7 additions & 7 deletions sawyer_gazebo/src/sawyer_gazebo_ros_control_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ class SawyerGazeboRosControlPlugin : public gazebo_ros_control::GazeboRosControl
{
private:
// mutex for re-entrant calls to modeCommandCallback
boost::mutex mtx_;
std::mutex mtx_;
ros::Subscriber speed_ratio_sub_;
ros::Subscriber joint_command_timeout_sub_;
ros::Subscriber joint_command_sub_;

public:
void Load(gazebo::physics::ModelPtr parent, sdf::ElementPtr sdf) {
GazeboRosControlPlugin::Load(parent, sdf);
GazeboRosControlPlugin::Load(parent, sdf);

speed_ratio_sub_ = model_nh_.subscribe<std_msgs::Float64>("/robot/limb/right/set_speed_ratio", 1, &SawyerGazeboRosControlPlugin::speedRatioCallback, this);
joint_command_timeout_sub_ = model_nh_.subscribe<std_msgs::Float64>("/robot/limb/right/joint_command_timeout", 1, &SawyerGazeboRosControlPlugin::jointCommandTimeoutCallback, this);
joint_command_sub_ = model_nh_.subscribe<intera_core_msgs::JointCommand>("/robot/limb/right/joint_command", 1, &SawyerGazeboRosControlPlugin::jointCommandCallback, this);
speed_ratio_sub_ = model_nh_.subscribe<std_msgs::Float64>("/robot/limb/right/set_speed_ratio", 1, &SawyerGazeboRosControlPlugin::speedRatioCallback, this);
joint_command_timeout_sub_ = model_nh_.subscribe<std_msgs::Float64>("/robot/limb/right/joint_command_timeout", 1, &SawyerGazeboRosControlPlugin::jointCommandTimeoutCallback, this);
joint_command_sub_ = model_nh_.subscribe<intera_core_msgs::JointCommand>("/robot/limb/right/joint_command", 1, &SawyerGazeboRosControlPlugin::jointCommandCallback, this);
}

void speedRatioCallback(const std_msgs::Float64 msg) {
ROS_INFO_STREAM_NAMED("ros_control_plugin", "Data: " << msg.data);
ROS_INFO_STREAM_NAMED("ros_control_plugin", "Data: " << msg.data);
}

void jointCommandTimeoutCallback(const std_msgs::Float64 msg) {
Expand All @@ -70,7 +70,7 @@ class SawyerGazeboRosControlPlugin : public gazebo_ros_control::GazeboRosControl

void jointCommandCallback(const intera_core_msgs::JointCommandConstPtr& msg) {
// lock out other thread(s) which are getting called back via ros.
boost::lock_guard<boost::mutex> guard(mtx_);
std::lock_guard<std::mutex> guard(mtx_);

std::vector<std::string> start_controllers;
std::vector<std::string> stop_controllers;
Expand Down
2 changes: 1 addition & 1 deletion sawyer_sim_controllers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.3)
project(sawyer_sim_controllers)

## Add support for C++11, supported in ROS Kinetic and newer
# add_definitions(-std=c++11)
add_definitions(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/***************************************************************************
* Copyright (c) 2013-2017, Rethink Robotics Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**************************************************************************/

#include <effort_controllers/joint_position_controller.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/***************************************************************************
* Copyright (c) 2013-2017, Rethink Robotics Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**************************************************************************/

#ifndef SAWYER_POSITION_CONTROLLER_H
#define SAWYER_POSITION_CONTROLLER_H

Expand Down
49 changes: 15 additions & 34 deletions sawyer_sim_controllers/src/joint_group_position_controller.cpp
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2013, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Open Source Robotics Foundation
* nor the names of its contributors may be
* used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/***************************************************************************
* Copyright (c) 2013-2017, Rethink Robotics Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**************************************************************************/

#include <sawyer_sim_controllers/joint_group_position_controller.h>
#include <pluginlib/class_list_macros.h>
Expand Down
28 changes: 15 additions & 13 deletions sawyer_sim_controllers/src/sawyer_position_controller.cpp
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
/***************************************************************************
* Copyright (c) 2013-2017, Rethink Robotics Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**************************************************************************/

#include <sawyer_sim_controllers/sawyer_position_controller.h>
#include <pluginlib/class_list_macros.h>

namespace sawyer_sim_controllers {
bool SawyerPositionController::init(hardware_interface::EffortJointInterface* hw, ros::NodeHandle &n){
ROS_INFO_STREAM_NAMED("sawyercontroller", "initializing position controller");
if(!sawyer_sim_controllers::JointGroupPositionController::init(hw, n)) {
ROS_INFO_STREAM_NAMED("sawyercontroller", "failed parent init");
return false;
} else {
ROS_INFO_STREAM_NAMED("sawyercontroller", "about to subscribed");
// TODO what is the correct topic name / type combination
// this topic is subscribed in parent class too as array. should change name.
std::string topic_name;
if (n.getParam("topic", topic_name)) {
ros::NodeHandle nh("~");
sub_joint_command_ = nh.subscribe(topic_name, 1, &SawyerPositionController::jointCommandCB, this);
} else {
sub_joint_command_ = n.subscribe("joint_command", 1, &SawyerPositionController::jointCommandCB, this);
}



}
ROS_INFO_STREAM_NAMED("sawyercontroller", "i guess init was all good");
return true;
}

void SawyerPositionController::jointCommandCB(const intera_core_msgs::JointCommandConstPtr& msg) {
ROS_INFO_STREAM_NAMED("sawyercontroller", "Got joint command");
std::vector<Command> commands;

for (int i = 0; i < msg->names.size(); i++) {
ROS_INFO_STREAM("Joint " << msg->names[i] << " going to " << msg->position[i]);
Command cmd = Command();
cmd.name_ = msg->names[i];
cmd.position_ = msg->position[i];
commands.push_back(cmd);
}
position_command_buffer_.writeFromNonRT(commands);
new_command_ = true;
ROS_INFO_STREAM("jointCommandCb new command: " << new_command_);

}

}
Expand Down

0 comments on commit d48dbce

Please sign in to comment.