link_joints.cpp File Reference

This is an example to show how to get data from the hand, read the position for a specific joint and send this as the target to another joint. More...

#include <ros/ros.h>
#include <iostream>
#include <cmath>
#include <stdexcept>
#include "duration.h"
#include <sys/time.h>
#include "ros/time.h"
#include <cstdio>
#include <sstream>
#include <log4cxx/logger.h>
#include "ros/console.h"
#include <boost/static_assert.hpp>
#include <cassert>
#include <stdint.h>
#include <assert.h>
#include <stddef.h>
#include <string>
#include "ros/assert.h"
#include <vector>
#include <map>
#include <set>
#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/function.hpp>
#include "exceptions.h"
#include <boost/shared_array.hpp>
#include "ros/types.h"
#include "ros/forwards.h"
#include "ros/common.h"
#include "ros/macros.h"
#include <string.h>
#include <boost/array.hpp>
#include "serialized_message.h"
#include "message_forward.h"
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include "message_traits.h"
#include "ros/exception.h"
#include <boost/call_traits.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/not.hpp>
#include <cstring>
#include <boost/bind.hpp>
#include <typeinfo>
#include <ros/message.h>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/make_shared.hpp>
#include <ros/static_assert.h>
#include "ros/message_traits.h"
#include "ros/builtin_message_traits.h"
#include "ros/serialization.h"
#include "ros/message_event.h"
#include "forwards.h"
#include "timer_options.h"
#include "wall_timer_options.h"
#include "ros/service_traits.h"
#include <boost/lexical_cast.hpp>
#include "subscription_callback_helper.h"
#include "ros/spinner.h"
#include <time.h>
#include "ros/publisher.h"
#include <boost/utility.hpp>
#include "ros/service_server.h"
#include "ros/subscriber.h"
#include "ros/node_handle.h"
#include "ros/init.h"
#include "XmlRpcValue.h"
#include "node_handle.h"
#include "ros/names.h"
#include <ostream>
#include "ros/message_operations.h"
#include <sr_robot_msgs/joint.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void callback (const sr_robot_msgs::joints_dataConstPtr &msg)
int main (int argc, char **argv)

Variables

std::string child_name = "MFJ3"
 the name of the child joint to link to the parent
std::string parent_name = "FFJ3"
 the name of the parent joint
ros::Publisher pub
ros::Subscriber sub

Detailed Description

This is an example to show how to get data from the hand, read the position for a specific joint and send this as the target to another joint.

Author:
Ugo Cupcic <ugo@shadowrobot.com>, Contact <contact@shadowrobot.com>
Date:
Thu Jul 8 16:57:22 2010

Copyright 2011 Shadow Robot Company Ltd.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright 2011 Shadow Robot Company Ltd.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

To test this program, just start the hand, rviz visualizer, the control GUI and this example (in 4 different consoles):

 roslaunch sr_hand srh_motor.launch
 roslaunch sr_hand rviz_motor.launch
 rosrun sr_control_gui __init__.py
 rosrun sr_hand link_joints
 

If you move the joint slider for FFJ3, then MFJ3 will move as well.

Definition in file link_joints.cpp.


Function Documentation

void callback ( const sr_robot_msgs::joints_dataConstPtr &  msg  ) 

The callback function is called each time a message is received on the topic /srh/shadowhand_data

Parameters:
msg message of type sr_hand::joints_data

if it's the parent joint, read the target, and send it to the child.

Examples:
link_joints.cpp.

Definition at line 80 of file link_joints.cpp.

int main ( int  argc,
char **  argv 
)

The main: initialise a ros node, a subscriber and a publisher

Parameters:
argc 
argv 
Returns:
0 on success

init the subscriber and subscribe to the topic /srh/shadowhand_data, using the callback function callback()

init the publisher on the topic /srh/sendupdate publishing messages of the type sr_robot_msgs::sendupdate.

Definition at line 135 of file link_joints.cpp.


Variable Documentation

std::string child_name = "MFJ3"

the name of the child joint to link to the parent

Examples:
link_joints.cpp.

Definition at line 67 of file link_joints.cpp.

std::string parent_name = "FFJ3"

the name of the parent joint

Examples:
link_joints.cpp.

Definition at line 65 of file link_joints.cpp.

ros::Publisher pub
Examples:
link_joints.cpp.

Definition at line 72 of file link_joints.cpp.

ros::Subscriber sub
Examples:
link_joints.cpp.

Definition at line 70 of file link_joints.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator


sr_hand
Author(s): Ugo Cupcic / ugo@shadowrobot.com, contact@shadowrobot.com
autogenerated on Fri Jan 11 09:32:55 2013