RosController.h
Go to the documentation of this file.
1 //| This file is a part of the ORCA framework.
2 //|
3 //| Copyright 2018, Fuzzy Logic Robotics
4 //| Copyright 2017, ISIR / Universite Pierre et Marie Curie (UPMC)
5 //|
6 //| Main contributor(s): Antoine Hoarau, Ryan Lober, and
7 //| Fuzzy Logic Robotics <info@fuzzylogicrobotics.com>
8 //|
9 //| ORCA is a whole-body reactive controller framework for robotics.
10 //|
11 //| This software is governed by the CeCILL-C license under French law and
12 //| abiding by the rules of distribution of free software. You can use,
13 //| modify and/ or redistribute the software under the terms of the CeCILL-C
14 //| license as circulated by CEA, CNRS and INRIA at the following URL
15 //| "http://www.cecill.info".
16 //|
17 //| As a counterpart to the access to the source code and rights to copy,
18 //| modify and redistribute granted by the license, users are provided only
19 //| with a limited warranty and the software's author, the holder of the
20 //| economic rights, and the successive licensors have only limited
21 //| liability.
22 //|
23 //| In this respect, the user's attention is drawn to the risks associated
24 //| with loading, using, modifying and/or developing or reproducing the
25 //| software by the user in light of its specific status of free software,
26 //| that may mean that it is complicated to manipulate, and that also
27 //| therefore means that it is reserved for developers and experienced
28 //| professionals having in-depth computer knowledge. Users are therefore
29 //| encouraged to load and test the software's suitability as regards their
30 //| requirements in conditions enabling the security of their systems and/or
31 //| data to be ensured and, more generally, to use and operate it in the
32 //| same conditions as regards security.
33 //|
34 //| The fact that you are presently reading this means that you have had
35 //| knowledge of the CeCILL-C license and that you accept its terms.
36 
37 #pragma once
38 
39 // #include <ros/ros.h>
40 #include <orca/optim/Controller.h>
42 // #include <orca_ros/GetString.h>
43 
44 namespace orca_ros
45 {
46 namespace optim
47 {
48 
50 {
51 public:
52  RosController( const std::string& robot_name,
53  std::shared_ptr<orca::optim::Controller> c,
54  bool attach_torque_publish_callback = false);
55 
56  virtual ~RosController();
57 
58  bool getNameService(orca_ros::GetString::Request &req, orca_ros::GetString::Response &res);
59  bool printService(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
60  bool setPrintLevelService(orca_ros::SetInt::Request &req, orca_ros::SetInt::Response &res);
61  bool updateService(orca_ros::UpdateController::Request &req, orca_ros::UpdateController::Response &res);
62  bool addTaskService(orca_ros::AddTask::Request &req, orca_ros::AddTask::Response &res);
63  bool addConstraintService(orca_ros::AddConstraint::Request &req, orca_ros::AddConstraint::Response &res);
64  bool getSolutionService(orca_ros::GetMatrix::Request &req, orca_ros::GetMatrix::Response &res);
65  bool getJointTorqueCommandService(orca_ros::GetMatrix::Request &req, orca_ros::GetMatrix::Response &res);
66  bool getJointAccelerationCommandService(orca_ros::GetMatrix::Request &req, orca_ros::GetMatrix::Response &res);
67  bool activateTasksAndConstraintsService(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
68  bool deactivateTasksAndConstraintsService(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
69  bool tasksAndConstraintsDeactivatedService(orca_ros::GetBool::Request &req, orca_ros::GetBool::Response &res);
70 
71 private:
72  void publishJointTorqueCommands();
73 
74 private:
75  std::shared_ptr<orca::optim::Controller> ctrl_;
76 
77  ros::ServiceServer ss_getName_;
78  ros::ServiceServer ss_print_;
79  ros::ServiceServer ss_setPrintLevel_;
80  ros::ServiceServer ss_update_;
81  ros::ServiceServer ss_addTask_;
82  ros::ServiceServer ss_addConstraint_;
83  ros::ServiceServer ss_getSolution_;
84  ros::ServiceServer ss_getJointTorqueCommand_;
85  ros::ServiceServer ss_getJointAccelerationCommand_;
86  ros::ServiceServer ss_activateTasksAndConstraints_;
87  ros::ServiceServer ss_deactivateTasksAndConstraints_;
88  ros::ServiceServer ss_tasksAndConstraintsDeactivated_;
89 
90 private:
91  ros::Publisher desired_torque_pub_;
92  orca_ros::JointTorqueCommand trq_msg_;
93  int ndof_ = 0;
94  bool robot_compensates_gravity_ = false;
95 };
96 
97 } // namespace optim
98 } // namespace orca
bool updateService(orca_ros::UpdateController::Request &req, orca_ros::UpdateController::Response &res)
Definition: RosController.cc:67
Definition: RosWrapperBase.h:50
bool printService(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: RosController.cc:55
bool addTaskService(orca_ros::AddTask::Request &req, orca_ros::AddTask::Response &res)
Definition: RosController.cc:73
bool addConstraintService(orca_ros::AddConstraint::Request &req, orca_ros::AddConstraint::Response &res)
Definition: RosController.cc:83
bool getJointTorqueCommandService(orca_ros::GetMatrix::Request &req, orca_ros::GetMatrix::Response &res)
Definition: RosController.cc:99
Definition: RosCartesianAccelerationPID.h:42
virtual ~RosController()
Definition: RosController.cc:44
Definition: RosController.h:49
bool activateTasksAndConstraintsService(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: RosController.cc:111
bool deactivateTasksAndConstraintsService(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
Definition: RosController.cc:117
bool getJointAccelerationCommandService(orca_ros::GetMatrix::Request &req, orca_ros::GetMatrix::Response &res)
Definition: RosController.cc:105
bool setPrintLevelService(orca_ros::SetInt::Request &req, orca_ros::SetInt::Response &res)
Definition: RosController.cc:61
bool tasksAndConstraintsDeactivatedService(orca_ros::GetBool::Request &req, orca_ros::GetBool::Response &res)
Definition: RosController.cc:123
RosController(const std::string &robot_name, std::shared_ptr< orca::optim::Controller > c, bool attach_torque_publish_callback=false)
Definition: RosController.cc:5
bool getNameService(orca_ros::GetString::Request &req, orca_ros::GetString::Response &res)
Definition: RosController.cc:49
bool getSolutionService(orca_ros::GetMatrix::Request &req, orca_ros::GetMatrix::Response &res)
Definition: RosController.cc:93