Skip to content

Commit d131e5d

Browse files
committed
Merging message-rollback
2 parents ce1ba19 + 2335006 commit d131e5d

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ install(TARGETS
3838
DESTINATION lib/${PROJECT_NAME}
3939
)
4040

41+
# copy the config dir over as well
42+
install(DIRECTORY config
43+
DESTINATION share/${PROJECT_NAME}
44+
)
45+
4146
if(BUILD_TESTING)
4247
# no auto linting for now
4348
endif()

include/ap1/control/control_node.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
#include "ap1_msgs/msg/speed_profile_stamped.hpp"
1515
#include "ap1_msgs/msg/target_path_stamped.hpp"
16+
<<<<<<< HEAD
17+
=======
18+
#include "ap1_msgs/msg/turn_angle_stamped.hpp"
19+
#include "ap1_msgs/msg/vehicle_speed_stamped.hpp"
20+
>>>>>>> message-rollback
1621
#include "ap1_msgs/msg/float_stamped.hpp"
1722

1823
#include "ap1/control/ackermann_controller.hpp"
@@ -34,8 +39,6 @@ class ControlNode : public rclcpp::Node
3439
AckermannController ackermann_controller_;
3540

3641
// Memory
37-
// half these types are very unnecessary, we should just have stampedfloat or
38-
// stamped double or something
3942
ap1_msgs::msg::SpeedProfileStamped speed_profile_;
4043
ap1_msgs::msg::TargetPathStamped target_path_;
4144
ap1_msgs::msg::FloatStamped vehicle_speed_;

src/control_node.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include "ap1_msgs/msg/speed_profile_stamped.hpp"
1313
#include "ap1_msgs/msg/target_path_stamped.hpp"
14+
#include "ap1_msgs/msg/turn_angle_stamped.hpp"
15+
#include "ap1_msgs/msg/vehicle_speed_stamped.hpp"
1416
#include "ap1_msgs/msg/float_stamped.hpp"
1517

1618
#include "ap1/control/control_node.hpp"
@@ -23,6 +25,7 @@ using namespace ap1::control;
2325

2426
void ControlNode::on_speed_profile(const SpeedProfileStamped speed_profile)
2527
{
28+
2629
speed_profile_ = speed_profile;
2730
}
2831

@@ -31,20 +34,20 @@ void ControlNode::on_path(const TargetPathStamped target_path)
3134
target_path_ = target_path;
3235
}
3336

34-
void ControlNode::on_speed(const FloatStamped & msg)
37+
void ControlNode::on_speed(const FloatStamped speed)
3538
{
3639
vehicle_speed_ = msg.value;
3740
}
3841

39-
void ControlNode::on_turn_angle(const FloatStamped & msg)
42+
void ControlNode::on_turn_angle(const FloatStamped turn_angle)
4043
{
4144
vehicle_turn_angle = msg.value;
4245
}
4346

4447
void ControlNode::control_loop_callback()
4548
{
4649
// the car's current velocity. we only support moving forward atp
47-
const vec3f velocity(this->vehicle_speed_, 0, 0); // +x is always forward on the car
50+
const vec3f velocity(this->vehicle_speed_.value, 0, 0); // +x is always forward on the car
4851

4952
const bool PATH_IS_STALE = false, SPEED_PROFILE_IS_STALE = false; // TEMP
5053

@@ -66,17 +69,13 @@ void ControlNode::control_loop_callback()
6669
velocity, vec2f(next_waypoint.x, next_waypoint.y), speed_profile_.speeds.at(0));
6770

6871
// log
69-
std::string s = "ACC: " + std::to_string(acc.x) + ", " + std::to_string(acc.y) + ", " +
70-
std::to_string(acc.z);
71-
RCLCPP_INFO(this->get_logger(), s.c_str());
72+
// RCLCPP_INFO(this->get_logger(), "ACC: %.2f, %.2f, %.2f", acc.x, acc.y, acc.z);
7273

7374
// compute acc and throttle using ackermann controller
7475
AckermannController::Command cmd = ackermann_controller_.compute_command(acc, velocity);
7576

7677
// log
77-
s = "CMD: {throttle:" + std::to_string(cmd.throttle) +
78-
", steering:" + std::to_string(cmd.steering) + "}";
79-
RCLCPP_INFO(this->get_logger(), s.c_str());
78+
// RCLCPP_INFO(this->get_logger(), "CMD: {throttle: %.2f, steering: %.2f}", cmd.throttle, cmd.steering);
8079

8180
// pack the turn angle into a message
8281
FloatStamped turn_msg;
@@ -89,7 +88,6 @@ void ControlNode::control_loop_callback()
8988
pwr_msg.header.stamp = this->now();
9089
pwr_msg.header.frame_id = "base_link";
9190
pwr_msg.value = cmd.throttle; // [-1, 1]
92-
// pwr_msg.power = 1.0f;
9391

9492
// send both messages out
9593
turning_angle_pub_->publish(turn_msg);

0 commit comments

Comments
 (0)