Skip to content

Commit 14d6de1

Browse files
authored
Merge pull request #100 from HebiRobotics/iamtesch/remainder-of-changes
Cleanup formatting and naming
2 parents 4323fa3 + 0021eea commit 14d6de1

4 files changed

Lines changed: 73 additions & 79 deletions

File tree

kits/arm/ex_AR_kit.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,31 @@ int main(int argc, char* argv[])
6161
std::cout << "Arm connected." << std::endl;
6262

6363

64-
/////////////////////////
65-
//// MobileIO Setup /////
66-
/////////////////////////
64+
//////////////////////////
65+
//// MobileIO Setup //////
66+
//////////////////////////
6767

6868
// Create the MobileIO object
69-
std::unique_ptr<util::MobileIO> mobile = util::MobileIO::create("Arm", "mobileIO");
70-
if (!mobile)
69+
std::unique_ptr<util::MobileIO> mobile_io = util::MobileIO::create("Arm", "mobileIO");
70+
if (!mobile_io)
7171
{
7272
std::cout << "couldn't find mobile IO device!\n";
7373
return 1;
7474
}
7575

7676
// Clear any garbage on screen
77-
mobile->resetUI();
77+
mobile_io->resetUI();
7878

7979
// Setup instructions for display
8080
std::string instructions;
8181
instructions = ("B1 - Home Position\nB3 - AR Control Mode\n"
8282
"B6 - Grav Comp Mode\nB8 - Quit\n");
8383

8484
// Display instructions on screen
85-
mobile->appendText(instructions);
85+
mobile_io->appendText(instructions);
8686

8787
// Setup state variable for mobile device
88-
auto last_mobile_state = mobile->update();
88+
auto last_mobile_state = mobile_io->update();
8989

9090
//////////////////////////
9191
//// Main Control Loop ///
@@ -121,61 +121,61 @@ int main(int argc, char* argv[])
121121

122122
if (softstart) {
123123
// End softstart when arm reaches its homePosition
124-
if (arm -> atGoal()){
125-
mobile->appendText("Softstart Complete!");
124+
if (arm -> atGoal()) {
125+
mobile_io->appendText("Softstart Complete!");
126126
softstart = false;
127127
continue;
128-
}
129-
arm -> send();
128+
}
129+
arm -> send();
130130

131-
// Stay in softstart, don't do any other behavior
132-
continue;
133-
}
131+
// Stay in softstart, don't do any other behavior
132+
continue;
133+
}
134134

135-
// Get latest mobile_state
136-
auto updated_mobile = mobile->update(0);
135+
// Get latest mobile_state
136+
auto updated_mobile_io = mobile_io->update(0);
137137

138-
if (!updated_mobile)
139-
std::cout << "Failed to get feedback from mobile I/O; check connection!\n";
140-
else
141-
{
138+
if (!updated_mobile_io)
139+
std::cout << "Failed to get feedback from mobile I/O; check connection!\n";
140+
else
141+
{
142142
// Button B1 - Return to home position
143-
if (mobile->getButtonDiff(1) == util::MobileIO::ButtonState::ToOn) {
144-
ar_mode = false;
145-
arm -> setGoal(arm::Goal::createFromPosition(4, home_position));
143+
if (mobile_io->getButtonDiff(1) == util::MobileIO::ButtonState::ToOn) {
144+
ar_mode = false;
145+
arm -> setGoal(arm::Goal::createFromPosition(4, home_position));
146146
}
147147

148148
// Button B3 - Start AR Control
149-
if (mobile->getButtonDiff(3) == util::MobileIO::ButtonState::ToOn) {
150-
xyz_phone_init << mobile -> getLastFeedback().mobile().arPosition().get().getX(),
151-
mobile -> getLastFeedback().mobile().arPosition().get().getY(),
152-
mobile -> getLastFeedback().mobile().arPosition().get().getZ();
149+
if (mobile_io->getButtonDiff(3) == util::MobileIO::ButtonState::ToOn) {
150+
xyz_phone_init << mobile_io -> getLastFeedback().mobile().arPosition().get().getX(),
151+
mobile_io -> getLastFeedback().mobile().arPosition().get().getY(),
152+
mobile_io -> getLastFeedback().mobile().arPosition().get().getZ();
153153
std::cout << xyz_phone_init << std::endl;
154-
rot_phone_init = makeRotationMatrix(mobile -> getLastFeedback().mobile().arOrientation().get());
154+
rot_phone_init = makeRotationMatrix(mobile_io -> getLastFeedback().mobile().arOrientation().get());
155155
ar_mode = true;
156156
}
157157

158158
// Button B6 - Grav Comp Mode
159-
if (mobile->getButtonDiff(6) == util::MobileIO::ButtonState::ToOn) {
159+
if (mobile_io->getButtonDiff(6) == util::MobileIO::ButtonState::ToOn) {
160160
arm -> cancelGoal();
161161
ar_mode = false;
162162
}
163163

164164
// Button B8 - End Demo
165-
if (mobile->getButtonDiff(8) == util::MobileIO::ButtonState::ToOn) {
165+
if (mobile_io->getButtonDiff(8) == util::MobileIO::ButtonState::ToOn) {
166166
// Clear MobileIO text
167-
mobile->resetUI();
167+
mobile_io->resetUI();
168168
return 1;
169169
}
170170
}
171171

172172
if (ar_mode) {
173173
// Get the latest mobile position and orientation
174174
Eigen::Vector3d xyz_phone;
175-
xyz_phone << mobile->getLastFeedback().mobile().arPosition().get().getX(),
176-
mobile->getLastFeedback().mobile().arPosition().get().getY(),
177-
mobile->getLastFeedback().mobile().arPosition().get().getZ();
178-
auto rot_phone = makeRotationMatrix(mobile->getLastFeedback().mobile().arOrientation().get());
175+
xyz_phone << mobile_io->getLastFeedback().mobile().arPosition().get().getX(),
176+
mobile_io->getLastFeedback().mobile().arPosition().get().getY(),
177+
mobile_io->getLastFeedback().mobile().arPosition().get().getZ();
178+
auto rot_phone = makeRotationMatrix(mobile_io->getLastFeedback().mobile().arOrientation().get());
179179

180180
// Calculate new targets
181181
Eigen::Vector3d xyz_scale;
@@ -198,7 +198,7 @@ int main(int argc, char* argv[])
198198
}
199199

200200
// Clear MobileIO text
201-
mobile->resetUI();
201+
mobile_io->resetUI();
202202

203203
return 0;
204204
}

kits/arm/ex_gravity_compensation.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ int main(int argc, char* argv[])
3737
return -1;
3838
}
3939

40-
// For this demo, we need just the arm
41-
std::unique_ptr<arm::Arm> arm;
42-
4340
//////////////////////////
4441
///// Arm Setup //////////
4542
//////////////////////////
4643

4744
// Create the arm object from the configuration (retry if not found)
48-
arm = arm::Arm::create(*example_config);
45+
std::unique_ptr<arm::Arm> arm = arm::Arm::create(*example_config);
4946
while (!arm) {
5047
std::cerr << "Failed to create arm, retrying..." << std::endl;
5148
arm = arm::Arm::create(*example_config);

kits/arm/ex_mobile_io_control.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Mobile IO Control
3-
* An example for setting up your arm for simple control from a mobile io devoce
3+
* An example for setting up your arm for simple control from a mobile io device
44
* to pre-programmed waypoints.
55
*/
66

@@ -40,7 +40,7 @@ int main(int argc, char* argv[])
4040
//////////////////////////
4141

4242
// Create the arm object from the configuration, and retry if not found
43-
auto arm = arm::Arm::create(*example_config);
43+
std::unique_ptr<arm::Arm> arm = arm::Arm::create(*example_config);
4444
while (!arm) {
4545
std::cerr << "Failed to create arm, retrying..." << std::endl;
4646
arm = arm::Arm::create(*example_config);
@@ -52,8 +52,8 @@ int main(int argc, char* argv[])
5252
//////////////////////////
5353

5454
// Create the MobileIO object
55-
std::unique_ptr<util::MobileIO> mobile = util::MobileIO::create("Arm", "mobileIO");
56-
if (!mobile)
55+
std::unique_ptr<util::MobileIO> mobile_io = util::MobileIO::create("Arm", "mobileIO");
56+
if (!mobile_io)
5757
{
5858
std::cout << "couldn't find mobile IO device!\n";
5959
return 1;
@@ -64,13 +64,13 @@ int main(int argc, char* argv[])
6464
"B3 - Waypoint 3\n"
6565
"B6 - Grav comp mode\nB8 - Quit\n");
6666
// Clear any garbage on screen
67-
mobile->clearText();
67+
mobile_io->clearText();
6868

6969
// Display instructions on screen
70-
mobile->appendText(instructions);
70+
mobile_io->appendText(instructions);
7171

7272
// Setup instructions
73-
auto last_state = mobile->update();
73+
auto last_state = mobile_io->update();
7474

7575
/////////////////////////////
7676
// Control Variables Setup //
@@ -79,18 +79,17 @@ int main(int argc, char* argv[])
7979
// Single Waypoint Vectors
8080
auto num_joints = arm->robotModel().getDoFCount();
8181
Eigen::VectorXd positions(num_joints);
82-
double single_time;
83-
single_time = 3;
82+
double single_time = 3;
8483

8584
//////////////////////////
8685
//// Main Control Loop ///
8786
//////////////////////////
8887

8988
while(arm->update())
9089
{
91-
auto updated_mobile = mobile->update(0);
90+
auto updated_mobile_io = mobile_io->update(0);
9291

93-
if (!updated_mobile)
92+
if (!updated_mobile_io)
9493
std::cout << "Failed to get feedback from mobile I/O; check connection!\n";
9594
else
9695
{
@@ -99,34 +98,34 @@ int main(int argc, char* argv[])
9998
/////////////////
10099

101100
// Buttton B1 - Home Position
102-
if (mobile->getButtonDiff(1) == util::MobileIO::ButtonState::ToOn) {
101+
if (mobile_io->getButtonDiff(1) == util::MobileIO::ButtonState::ToOn) {
103102
positions << 0, 0, 0, 0, 0, 0;
104103
arm -> setGoal(arm::Goal::createFromPosition(single_time, positions));
105104
}
106105

107106
// Button B2 - Waypoint 1
108-
if (mobile->getButtonDiff(2) == util::MobileIO::ButtonState::ToOn) {
107+
if (mobile_io->getButtonDiff(2) == util::MobileIO::ButtonState::ToOn) {
109108
positions << M_PI/4, M_PI/3, 2*M_PI/3, M_PI/3, M_PI/4, 0;
110109
arm -> setGoal(arm::Goal::createFromPosition(single_time, positions));
111110
}
112111

113112
// Button B3 - Waypoint 2
114-
if (mobile->getButtonDiff(3) == util::MobileIO::ButtonState::ToOn) {
113+
if (mobile_io->getButtonDiff(3) == util::MobileIO::ButtonState::ToOn) {
115114
positions << -M_PI/4, M_PI/3, 2*M_PI/3, M_PI/3, 3*M_PI/4, 0;
116115
arm -> setGoal(arm::Goal::createFromPosition(single_time, positions));
117116

118117
}
119118

120119
// Button B6 - Grav Comp Mode
121-
if (mobile->getButtonDiff(6) == util::MobileIO::ButtonState::ToOn) {
120+
if (mobile_io->getButtonDiff(6) == util::MobileIO::ButtonState::ToOn) {
122121
// cancel any goal that is set, returning arm into gravComp mode
123122
arm -> cancelGoal();
124123
}
125124

126125
// Button B8 - End Demo
127-
if (mobile->getButtonDiff(8) == util::MobileIO::ButtonState::ToOn) {
126+
if (mobile_io->getButtonDiff(8) == util::MobileIO::ButtonState::ToOn) {
128127
// Clear MobileIO text
129-
mobile->resetUI();
128+
mobile_io->resetUI();
130129
return 1;
131130
}
132131
}
@@ -136,10 +135,8 @@ int main(int argc, char* argv[])
136135
}
137136

138137
// Clear MobileIO text
139-
mobile->clearText();
138+
mobile_io->clearText();
140139

141140
return 0;
142141
}
143142

144-
145-

kits/arm/ex_teach_repeat.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,20 @@ int main(int argc, char* argv[])
9898
std::cout << "Arm connected." << std::endl;
9999

100100

101-
/////////////////////////
102-
//// MobileIO Setup /////
103-
/////////////////////////
101+
//////////////////////////
102+
//// MobileIO Setup //////
103+
//////////////////////////
104104

105105
// Create the MobileIO object
106-
std::unique_ptr<util::MobileIO> mobile = util::MobileIO::create("Arm", "mobileIO");
107-
if (!mobile)
106+
std::unique_ptr<util::MobileIO> mobile_io = util::MobileIO::create("Arm", "mobileIO");
107+
if (!mobile_io)
108108
{
109109
std::cout << "couldn't find mobile IO device!\n";
110110
return 1;
111111
}
112112

113113
// Clear any garbage on screen
114-
mobile -> clearText();
114+
mobile_io -> clearText();
115115

116116
// Setup instructions for display
117117
std::string instructions;
@@ -120,10 +120,10 @@ int main(int argc, char* argv[])
120120
"B6 - Grav comp mode\nB8 - Quit\n");
121121

122122
// Display instructions on screen
123-
mobile->appendText(instructions);
123+
mobile_io->appendText(instructions);
124124

125125
// Setup state variable for mobile device
126-
auto last_mobile_state = mobile->update();
126+
auto last_mobile_state = mobile_io->update();
127127

128128

129129
//////////////////////////
@@ -137,29 +137,29 @@ int main(int argc, char* argv[])
137137
while(arm->update())
138138
{
139139
// Get latest mobile_state
140-
bool updated_mobile = mobile->update(0);
140+
bool updated_mobile_io = mobile_io->update(0);
141141

142-
if (!updated_mobile)
142+
if (!updated_mobile_io)
143143
std::cout << "Failed to get feedback from mobile I/O; check connection!\n";
144144
else
145145
{
146146
// Buttton B1 - Add Stop Waypoint
147-
if (mobile->getButtonDiff(1) == util::MobileIO::ButtonState::ToOn) {
147+
if (mobile_io->getButtonDiff(1) == util::MobileIO::ButtonState::ToOn) {
148148
addWaypoint(state, arm -> lastFeedback(), true);
149149
}
150150

151151
// Button B2 - Clear Waypoints
152-
if (mobile->getButtonDiff(2) == util::MobileIO::ButtonState::ToOn) {
152+
if (mobile_io->getButtonDiff(2) == util::MobileIO::ButtonState::ToOn) {
153153
state.waypoints.clear();
154154
}
155155

156156
// Button B3 - Add Through Waypoint
157-
if (mobile->getButtonDiff(3) == util::MobileIO::ButtonState::ToOn) {
157+
if (mobile_io->getButtonDiff(3) == util::MobileIO::ButtonState::ToOn) {
158158
addWaypoint(state, arm -> lastFeedback(), false);
159159
}
160160

161161
// Button B5 - Playback Waypoints
162-
if (mobile->getButtonDiff(5) == util::MobileIO::ButtonState::ToOn) {
162+
if (mobile_io->getButtonDiff(5) == util::MobileIO::ButtonState::ToOn) {
163163
if (state.waypoints.size() <= 1){
164164
printf("You have not added enough waypoints!\n");
165165
}
@@ -170,15 +170,15 @@ int main(int argc, char* argv[])
170170
}
171171

172172
// Button B6 - Grav Comp Mode
173-
if (mobile->getButtonDiff(6) == util::MobileIO::ButtonState::ToOn) {
173+
if (mobile_io->getButtonDiff(6) == util::MobileIO::ButtonState::ToOn) {
174174
// Cancel any goal that is set, returning arm into gravComp mode
175175
arm->cancelGoal();
176176
}
177177

178178
// Button B8 - End Demo
179-
if (mobile->getButtonDiff(8) == util::MobileIO::ButtonState::ToOn) {
179+
if (mobile_io->getButtonDiff(8) == util::MobileIO::ButtonState::ToOn) {
180180
// Clear MobileIO text
181-
mobile->clearText();
181+
mobile_io->clearText();
182182
return 1;
183183
}
184184
}
@@ -188,7 +188,7 @@ int main(int argc, char* argv[])
188188
}
189189

190190
// Clear MobileIO text
191-
mobile->clearText();
191+
mobile_io->clearText();
192192

193193
return 0;
194194
}

0 commit comments

Comments
 (0)