Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions src/app/RosControlTest/groupMotors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "ControlGroup.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs to move to its own folder with its own CMakeLists.txt to respect the structure of the project.

#include "ControlGroupRosHandler.h"
#include "Group.h"
#include "MockMotor.h"
#include "ros/node_handle.h"
#include <cstdint>
#include <iostream>
#include <memory>
#include <vector>

auto main(int32_t argc, char **argv) -> int32_t {
std::cout << "wrevolution ROS test start..." << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This print can be removed.


// motors 1 - 3
auto motor1{std::make_shared<Hardware::Motor>(1, "LeftBackMotor_1")};
auto motor2{std::make_shared<Hardware::Motor>(2, "LeftMiddleMotor_2")};
auto motor3{std::make_shared<Hardware::Motor>(3, "LeftFrontMotor_3")};

// motors 4 - 6
auto motor4{std::make_shared<Hardware::Motor>(4, "RightBackMotor_4")};
auto motor5{std::make_shared<Hardware::Motor>(5, "RightMiddleMotor_5")};
auto motor6{std::make_shared<Hardware::Motor>(6, "RightFrontMotor_6")};
Comment on lines +15 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number can be dropped to avoid duplicating ID information.


// motor group 1
auto motorGroup1{std::make_shared<Hardware::Group>("LeftGroupMotors")};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For compatibility reasons, this group should be called left.

motorGroup1->addControlGroup(motor1);
motorGroup1->addControlGroup(motor2);
motorGroup1->addControlGroup(motor3);

// motor group 2
auto motorGroup1{std::make_shared<Hardware::Group>("RightGroupMotors")};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For compatibility reasons, this group should be called right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a motor group called motorGroup1, so this doesn't compile.

motorGroup2->addControlGroup(motor4);
motorGroup2->addControlGroup(motor5);
motorGroup2->addControlGroup(motor6);

std::cout << "Motor setup complete!" << std::endl;

// Setup ROS Interface
ros::init(argc, argv, "RosControlTest");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The node name should change, since this would not be a test node.

ros::NodeHandle node{};

std::vector<std::unique_ptr<RosHandler::ControlGroupRosHandler>> controlGroupHandlers{};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only 2 groups of motors, so we probably don't need a dynamic list.


controlGroupHandlers.reserve(testingGroups.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think testingGroups is declared, so this doesn't compile.


for (const auto &controlGroup : testingGroups) {
controlGroupHandlers.push_back(std::make_unique<RosHandler::ControlGroupRosHandler>(node, controlGroup));
}
Comment on lines +46 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be converted to 2 separate constructions.


std::cout << "ROS Setup complete!" << std::endl;

// Spin ROS comms
ros::spin();

std::cout << "Shutting down..." << std::endl;

return 0;
}