Skip to content

Controller_overseer to C++#1

Draft
jjdarnley1 wants to merge 47 commits intodevfrom
v1
Draft

Controller_overseer to C++#1
jjdarnley1 wants to merge 47 commits intodevfrom
v1

Conversation

@jjdarnley1
Copy link
Copy Markdown

Refactoring of controller_overseer.py to C++


#define FF_PUBLISH_PARAM "disable_native_ff"

#define PARAMETER_SCALE 1000000
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why a #define?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I just did this to match what was done in the current version but I don't really see a point


//parameters
string robotName, configPath, thrusterSolverName;
bool writeAutoFF;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In ROS standard, variable declarations are placed after functions. Think about it like defining the public interface at the top of the file. Also, don't feel the need to leave whitespace between each variable. It can make the code feel cluttered. Use whitespace for logical organization of variables


updateTimer = create_wall_timer(std::chrono_literals::1s, /*callback*/);

weightTimer = create_wall_timer(std::chrono_literals::1s, /*callback*/);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same kind of deal here. Don't need all the whitespace


tfListener = std::make_shared<tf2_ros::TransformListener>(*tfBuffer);

tfNamespace = "talos"; //get_parameter("robot").as_string()??
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct. You want to use the robot parameter instead of hardcoding it

bool writeAutoFF;

ControllerOverseer() : Node("controller_overseer") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just be careful since you're declaring the constructor as private currently

/*
Yaml traversal -- get recursed
*/
void traversal(std::vector<std::pair<std::string,int64_t>>& ints, std::vector<std::pair<std::string,bool>>& bools, std::vector<std::pair<std::string,std::vector<int64_t>>> & arrays, const YAML::Node& tree, const std::string path){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are some pretty nasty C++ types. Consider making a using reference for them

}

}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Parsing code is always going to be kinda gross, and this seems pretty good, so nice work

};

//queue of service calls
std::deque<servicePair> waitingRequests;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why a deque specifically?



//constructor
SimulinkModelClass::SimulinkModelClass(std::shared_ptr<ControllerOverseer> overseerNode, string nodeName) : overseer(overseerNode), nodeName(nodeName), modelActive(false), paramsLoaded(false){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Space please between parenthesis and curly brace


bool found = false;
//check for integers
for (const std::pair<std::string, int64_t>& p : intV) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Appreciate the use of const reference in for loops


<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Keep in mind that in future you'll need to update the package.xml with dependencies added in the CmakeList using the key. Please don't for the time being, until we remove all the riptide deps from the controller

@Effo12345
Copy link
Copy Markdown
Member

Seems like overall solid development on pace to be done in time. Functionality, where implemented, seems to be as I expected. Just focus on reformatting for a few stylistic things when you get the chance

jjdarnley1 and others added 7 commits March 12, 2026 01:00
Needed to link yaml cpp (stole from physics simulator)
lots of ROS/tf2 sytax and type nonsense
specifically I needed to use a vector of long ints instead of doubles even though I was under the impression that cpp would just cast that for me. Also made hpp file for controller overseer but all of this needs comments so I need to go through that and then start testing.

Also, need to determine if this will be tested within the new software stack or I should be using this with all old stack things and testing in sim that way.
@Effo12345
Copy link
Copy Markdown
Member

Seems like mostly just naming changes. Glad the model seems to be working and the overseer builds. More thorough testing coming this week!

@Effo12345
Copy link
Copy Markdown
Member

Can you remove the extra models you added while working on the controller since it takes longer to generate the matlab packages. These would include: 'trial', 'newController', 'complete_controller_organized', 'complete_controller_unorganized'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants