Skip to content

Commit 21db637

Browse files
committed
Updated app name (M1DemoMachineROS)
1 parent abf6b3f commit 21db637

9 files changed

Lines changed: 60 additions & 61 deletions

File tree

doc/1.GettingStarted/GSM1DemoMachine.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Use keyboard to explore different controllers:
8484
- Key A: position, velocity, and torque controller demonstrations
8585
- Key Q: return to idle state
8686

87-
## Build and run M1ROSDemoMachine (To be tested)
87+
## Build and run M1DemoMachineROS
8888

8989
Configure the CMakeList.txt, select the M1DemoMachine, and set the flags for using a real robot without ROS support:
9090

@@ -94,7 +94,7 @@ Configure the CMakeList.txt, select the M1DemoMachine, and set the flags for usi
9494
#set (STATE_MACHINE_NAME "M2DemoMachine")
9595
#set (STATE_MACHINE_NAME "M3DemoMachine")
9696
#set (STATE_MACHINE_NAME "X2DemoMachine")
97-
set (STATE_MACHINE_NAME "M1ROSDemoMachine")
97+
set (STATE_MACHINE_NAME "M1DemoMachineROS")
9898
#set (STATE_MACHINE_NAME "LoggingDevice")
9999
# Comment to use actual hardware, uncomment for a nor robot (virtual) app
100100
set(NO_ROBOT OFF)

doc/1.GettingStarted/GettingStarted.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ This example enables simple movements with the AnkleMotus M1 System.
104104
### [M1DemoMachine - Instructions](GSM1DemoMachine.md)
105105
See the code example in `src/apps/M1DemoMachine`.
106106

107-

src/apps/MultiM1Machine/MultiM1Machine.cpp renamed to src/apps/M1DemoMachineROS/M1DemoMachineROS.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include "MultiM1Machine.h"
1+
#include "M1DemoMachineROS.h"
22

3-
#define OWNER ((MultiM1Machine *)owner)
3+
#define OWNER ((M1DemoMachineROS *)owner)
44

5-
MultiM1Machine::MultiM1Machine(int argc, char *argv[]){
6-
spdlog::debug("MultiM1Machine::constructed!");
5+
M1DemoMachineROS::M1DemoMachineROS(int argc, char *argv[]){
6+
spdlog::debug("M1DemoMachineROS::constructed!");
77

88
ros::init(argc, argv, "m1", ros::init_options::NoSigintHandler);
99
ros::NodeHandle nodeHandle("~");
@@ -16,23 +16,23 @@ MultiM1Machine::MultiM1Machine(int argc, char *argv[]){
1616
robot_ = new RobotM1(robotName_);
1717

1818
// Create ros object
19-
multiM1MachineRos_ = new MultiM1MachineROS(robot_);
19+
M1MachineRos_ = new M1MachineROS(robot_);
2020

2121
// Pass nodeHandle to the classes that use ROS features
22-
multiM1MachineRos_->setNodeHandle(nodeHandle);
23-
multiM1MachineRos_->initialize();
22+
M1MachineRos_->setNodeHandle(nodeHandle);
23+
M1MachineRos_->initialize();
2424

2525
// Create states with ROS features // This should be created after ros::init()
26-
multiControllerState_ = new MultiControllerState(this, robot_, multiM1MachineRos_);
26+
multiControllerState_ = new MultiControllerState(this, robot_, M1MachineRos_);
2727

2828
//Initialize the state machine with first state of the designed state machine, using baseclass function.
2929
StateMachine::initialize(multiControllerState_);
3030
}
3131

32-
MultiM1Machine::~MultiM1Machine() {
32+
M1DemoMachineROS::~M1DemoMachineROS() {
3333
currentState->exit();
3434
robot_->disable();
35-
delete multiM1MachineRos_;
35+
delete M1MachineRos_;
3636
delete robot_;
3737
}
3838

@@ -42,12 +42,12 @@ MultiM1Machine::~MultiM1Machine() {
4242
*
4343
*/
4444

45-
void MultiM1Machine::init() {
45+
void M1DemoMachineROS::init() {
4646
// ros::init(argc, argv, "m1", ros::init_options::NoSigintHandler);
4747
// ros::NodeHandle nodeHandle("~");
4848

4949
// // Pass nodeHandle to the classes that use ROS features
50-
// multiM1MachineRos_->setNodeHandle(nodeHandle);
50+
// M1MachineRos_->setNodeHandle(nodeHandle);
5151

5252
if(robot_->initialise()) {
5353
initialised = true;
@@ -88,27 +88,27 @@ void MultiM1Machine::init() {
8888
logHelper.add(multiControllerState_->tau_cmd, "CommandTorque"); // motor_torque = command_torque + compensation_torque
8989
logHelper.add(robot_->tau_motor, "MotorTorque");
9090

91-
logHelper.add(multiM1MachineRos_->jointTorqueCommand_, "MM1_DesiredJointTorques");
92-
logHelper.add(multiM1MachineRos_->jointPositionCommand_, "MM1_DesiredJointPositions");
93-
logHelper.add(multiM1MachineRos_->interactionTorqueCommand_, "MM1_DesiredInteractionTorques");
91+
logHelper.add(M1MachineRos_->jointTorqueCommand_, "MM1_DesiredJointTorques");
92+
logHelper.add(M1MachineRos_->jointPositionCommand_, "MM1_DesiredJointPositions");
93+
logHelper.add(M1MachineRos_->interactionTorqueCommand_, "MM1_DesiredInteractionTorques");
9494

9595
logHelper.add(multiControllerState_->digitalInValue_, "digitalIn");
9696
logHelper.add(multiControllerState_->digitalOutValue_, "digitalOut");
9797

9898
logHelper.startLogger();
9999
}
100100

101-
void MultiM1Machine::end() {
101+
void M1DemoMachineROS::end() {
102102
if(initialised) {
103103
currentState->exit();
104104
robot_->stop();
105105
logHelper.endLog();
106-
delete multiM1MachineRos_;
106+
delete M1MachineRos_;
107107
delete robot_;
108108
}
109109
}
110110

111-
bool MultiM1Machine::configureMasterPDOs() {
111+
bool M1DemoMachineROS::configureMasterPDOs() {
112112
spdlog::debug("M1DemoMachine::configureMasterPDOs()");
113113
return robot_->configureMasterPDOs();
114114
}
@@ -118,9 +118,9 @@ bool MultiM1Machine::configureMasterPDOs() {
118118
* that need to run every program loop update cycle.
119119
*
120120
*/
121-
void MultiM1Machine::hwStateUpdate(void) {
121+
void M1DemoMachineROS::hwStateUpdate(void) {
122122
robot_->updateRobot();
123-
multiM1MachineRos_->update();
123+
M1MachineRos_->update();
124124
time_ = (std::chrono::duration_cast<std::chrono::microseconds>(
125125
std::chrono::steady_clock::now() - time0_).count()) / 1e6;
126126
ros::spinOnce();

src/apps/MultiM1Machine/MultiM1Machine.h renamed to src/apps/M1DemoMachineROS/M1DemoMachineROS.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
2-
* \file MultiM1Machine.h
2+
* \file M1DemoMachineROS.h
33
* \author Emek Baris Kucuktabak
44
* \version 0.1
55
* \date 2020-11-22
66
* \copyright Copyright (c) 2020
77
*
8-
* /brief The MultiM1Machine class represents an example implementation of a stateMachine in multi-robot control setting
8+
* /brief The M1DemoMachineROS class represents an example implementation of a stateMachine in multi-robot control setting
99
*
1010
*/
1111
#ifndef M1_SM_H
@@ -28,22 +28,22 @@
2828
#include "LogHelper.h"
2929
#include "logging.h"
3030

31-
#include "MultiM1MachineROS.h"
31+
#include "M1MachineROS.h"
3232

3333
/**
3434
* @brief Example implementation of a StateMachine for the M1Robot class. States should implemented M1DemoState
3535
*
3636
*/
37-
class MultiM1Machine : public StateMachine {
37+
class M1DemoMachineROS : public StateMachine {
3838
public:
3939
bool running = false;
4040
/**
4141
* \todo Pilot Parameters would be set in constructor here
4242
*
4343
*/
44-
// MultiM1Machine();
45-
MultiM1Machine(int argc, char *argv[]);
46-
~MultiM1Machine();
44+
// M1DemoMachineROS();
45+
M1DemoMachineROS(int argc, char *argv[]);
46+
~M1DemoMachineROS();
4747
// void init(int argc, char *argv[]);
4848
void init();
4949
void end();
@@ -60,7 +60,7 @@ class MultiM1Machine : public StateMachine {
6060

6161
protected:
6262
RobotM1 *robot_; /*<!Pointer to the Robot*/
63-
MultiM1MachineROS *multiM1MachineRos_; /*<!Pointer to the ROS Class*/
63+
M1MachineROS *M1MachineRos_; /*<!Pointer to the ROS Class*/
6464

6565
private:
6666
std::string robotName_; // robot name(obtained from node name)

src/apps/MultiM1Machine/MultiM1MachineROS.cpp renamed to src/apps/M1DemoMachineROS/M1MachineROS.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#include "MultiM1MachineROS.h"
1+
#include "M1MachineROS.h"
22

3-
MultiM1MachineROS::MultiM1MachineROS(RobotM1 *robot) {
3+
M1MachineROS::M1MachineROS(RobotM1 *robot) {
44
robot_ = robot;
55
}
66

7-
MultiM1MachineROS::~MultiM1MachineROS() {
7+
M1MachineROS::~M1MachineROS() {
88
ros::shutdown();
99
}
1010

11-
void MultiM1MachineROS::initialize() {
12-
spdlog::debug("MultiM1MachineROS::init()");
11+
void M1MachineROS::initialize() {
12+
spdlog::debug("M1MachineROS::init()");
1313

14-
jointCommandSubscriber_ = nodeHandle_->subscribe("joint_commands", 1, &MultiM1MachineROS::jointCommandCallback, this);
15-
interactionTorqueCommandSubscriber_ = nodeHandle_->subscribe("interaction_effort_commands", 1, &MultiM1MachineROS::interactionTorqueCommandCallback, this);
14+
jointCommandSubscriber_ = nodeHandle_->subscribe("joint_commands", 1, &M1MachineROS::jointCommandCallback, this);
15+
interactionTorqueCommandSubscriber_ = nodeHandle_->subscribe("interaction_effort_commands", 1, &M1MachineROS::interactionTorqueCommandCallback, this);
1616
jointStatePublisher_ = nodeHandle_->advertise<sensor_msgs::JointState>("joint_states", 10);
1717
interactionWrenchPublisher_ = nodeHandle_->advertise<geometry_msgs::WrenchStamped>("interaction_wrench", 10);
1818

@@ -22,12 +22,12 @@ void MultiM1MachineROS::initialize() {
2222
interactionTorqueCommand_ = Eigen::VectorXd(M1_NUM_INTERACTION);
2323
}
2424

25-
void MultiM1MachineROS::update() {
25+
void M1MachineROS::update() {
2626
publishJointStates();
2727
publishInteractionForces();
2828
}
2929

30-
void MultiM1MachineROS::publishJointStates() {
30+
void M1MachineROS::publishJointStates() {
3131
Eigen::VectorXd jointPositions = robot_->getPosition();
3232
Eigen::VectorXd jointVelocities = robot_->getVelocity();
3333
Eigen::VectorXd jointTorques = robot_->getTorque();
@@ -45,7 +45,7 @@ void MultiM1MachineROS::publishJointStates() {
4545
jointStatePublisher_.publish(jointStateMsg_);
4646
}
4747

48-
void MultiM1MachineROS::publishInteractionForces() {
48+
void M1MachineROS::publishInteractionForces() {
4949
Eigen::VectorXd interactionTorque = robot_->getJointTor_s();
5050
ros::Time time = ros::Time::now();
5151

@@ -57,11 +57,11 @@ void MultiM1MachineROS::publishInteractionForces() {
5757
interactionWrenchPublisher_.publish(interactionWrenchMsg_);
5858
}
5959

60-
void MultiM1MachineROS::setNodeHandle(ros::NodeHandle &nodeHandle) {
60+
void M1MachineROS::setNodeHandle(ros::NodeHandle &nodeHandle) {
6161
nodeHandle_ = &nodeHandle;
6262
}
6363

64-
void MultiM1MachineROS::jointCommandCallback(const sensor_msgs::JointState &msg) {
64+
void M1MachineROS::jointCommandCallback(const sensor_msgs::JointState &msg) {
6565

6666
for(int i=0; i<M1_NUM_JOINTS; i++){
6767
jointPositionCommand_[i] = msg.position[i];
@@ -70,7 +70,7 @@ void MultiM1MachineROS::jointCommandCallback(const sensor_msgs::JointState &msg)
7070
}
7171
}
7272

73-
void MultiM1MachineROS::interactionTorqueCommandCallback(const std_msgs::Float64MultiArray &msg) {
73+
void M1MachineROS::interactionTorqueCommandCallback(const std_msgs::Float64MultiArray &msg) {
7474

7575
for(int i=0; i<M1_NUM_JOINTS; i++){
7676
interactionTorqueCommand_[i] = msg.data[i];

src/apps/MultiM1Machine/MultiM1MachineROS.h renamed to src/apps/M1DemoMachineROS/M1MachineROS.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/**
2-
* /file MultiM1MachineROS.h
2+
* /file M1MachineROS.h
33
* /author Emek Baris Kucuktabak
4-
* /brief ROS part of the MultiM1Machine
4+
* /brief ROS part of the M1Machine
55
* /version 0.1
66
* /date 2020-11-03
77
*
88
* @copyright Copyright (c) 2020
99
*
1010
*/
1111

12-
#ifndef SRC_MultiM1MachineROS_H
13-
#define SRC_MultiM1MachineROS_H
12+
#ifndef SRC_M1MachineROS_H
13+
#define SRC_M1MachineROS_H
1414

1515
// msg types
1616
#include <sensor_msgs/JointState.h>
@@ -21,10 +21,10 @@
2121
#include "RobotM1.h"
2222
#include "ros/ros.h" // This state machine requires ROS
2323

24-
class MultiM1MachineROS {
24+
class M1MachineROS {
2525
public:
26-
MultiM1MachineROS(RobotM1 *robot);
27-
~MultiM1MachineROS();
26+
M1MachineROS(RobotM1 *robot);
27+
~M1MachineROS();
2828

2929
void update(void);
3030
void publishJointStates(void);
@@ -57,4 +57,4 @@ class MultiM1MachineROS {
5757

5858
};
5959

60-
#endif //SRC_MultiM1MachineROS_H
60+
#endif //SRC_M1MachineROS_H

src/apps/MultiM1Machine/states/MultiControllerState.cpp renamed to src/apps/M1DemoMachineROS/states/MultiControllerState.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ void MultiControllerState::during(void) {
9999
robot_->setJointTor(Eigen::VectorXd::Zero(M1_NUM_JOINTS));
100100
}
101101
else if(controller_mode_ == 2){ // follow position commands
102-
robot_->setJointPos(multiM1MachineRos_->jointPositionCommand_);
102+
robot_->setJointPos(M1MachineRos_->jointPositionCommand_);
103103
}
104104
else if(controller_mode_ == 3){ // follow torque commands
105-
robot_->setJointTor(multiM1MachineRos_->jointTorqueCommand_);
105+
robot_->setJointTor(M1MachineRos_->jointTorqueCommand_);
106106
}
107107
else if(controller_mode_ == 4){ // virtual spring - torque mode
108108
tau = robot_->getJointTor();
@@ -125,7 +125,7 @@ void MultiControllerState::during(void) {
125125
tau_filtered = tau_s(0);
126126

127127
// get interaction torque from virtual spring
128-
spring_tor = -multiM1MachineRos_->interactionTorqueCommand_(0);
128+
spring_tor = -M1MachineRos_->interactionTorqueCommand_(0);
129129
// spring_tor = spk_*M_PIf64*(45-q(0))/180.0; //stiffness; q(0) in degree
130130
robot_->tau_spring[0] = spring_tor; // for ROS publish only
131131

src/apps/MultiM1Machine/states/MultiControllerState.h renamed to src/apps/M1DemoMachineROS/states/MultiControllerState.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "State.h"
1515
#include "RobotM1.h"
16-
#include "MultiM1MachineROS.h"
16+
#include "M1MachineROS.h"
1717

1818
// dynamic reconfigure
1919
#include <dynamic_reconfigure/server.h>
@@ -26,14 +26,14 @@
2626
*/
2727
class MultiControllerState : public State {
2828
RobotM1 *robot_;
29-
MultiM1MachineROS *multiM1MachineRos_;
29+
M1MachineROS *M1MachineRos_;
3030

3131
public:
3232
void entry(void);
3333
void during(void);
3434
void exit(void);
35-
MultiControllerState(StateMachine *m, RobotM1 *exo, MultiM1MachineROS *multiM1MachineRos, const char *name = NULL) :
36-
State(m, name), robot_(exo), multiM1MachineRos_(multiM1MachineRos){};
35+
MultiControllerState(StateMachine *m, RobotM1 *exo, M1MachineROS *M1MachineRos, const char *name = NULL) :
36+
State(m, name), robot_(exo), M1MachineRos_(M1MachineRos){};
3737

3838
int cali_stage;
3939
int cali_velocity;

src/core/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static int rt_thread_epoll_fd; /*!< epoll file descriptor for rt thread */
5151
static int rtControlPriority = 80; /*!< priority of application thread */
5252
static void *rt_control_thread(void *arg);
5353
static pthread_t rt_control_thread_id;
54-
const float controlLoopPeriodInms = 10; /*!< Define the control loop period (in ms): the period of rt_control_thread loop. */
55-
const float CANUpdateLoopPeriodInms = 10; /*!< Define the CAN PDO sync message period (and so PDO update rate). In ms. Less than 3 can lead to unstable communication */
54+
const float controlLoopPeriodInms = 3; /*!< Define the control loop period (in ms): the period of rt_control_thread loop. */
55+
const float CANUpdateLoopPeriodInms = 3; /*!< Define the CAN PDO sync message period (and so PDO update rate). In ms. Less than 3 can lead to unstable communication */
5656
CO_NMT_reset_cmd_t reset_local = CO_RESET_NOT;
5757

5858
/** @brief Task Timer used for the Control Loop*/

0 commit comments

Comments
 (0)