This is an error report.
Screenshot of the error
Error details
I wrote my code correctly but I still receive error on gradebot.
This is an error report.
Screenshot of the error
Error details
I wrote my code correctly but I still receive error on gradebot.
@mcankizilkaya
You have not given us much to work with here.
This is mycode:
#include "geometry_msgs/msg/twist.hpp"
#include "rclcpp/rclcpp.hpp"
#include "sensor_msgs/msg/laser_scan.hpp"
#include <chrono>
using namespace std::chrono_literals;
using std::placeholders::_1;
class MoveRobot : public rclcpp::Node {
public:
MoveRobot() : Node("move_robot") {
publisher_ =
this->create_publisher<geometry_msgs::msg::Twist>("cmd_vel", 10);
subscription_ = this->create_subscription<sensor_msgs::msg::LaserScan>(
"/scan", 10, std::bind(&MoveRobot::topic_callback, this, _1));
}
private:
void topic_callback(const sensor_msgs::msg::LaserScan::SharedPtr msg) {
auto message = geometry_msgs::msg::Twist();
message.linear.x = 0.0;
message.angular.z = 0.0;
if (msg->ranges[359] < 1.0) {
message.angular.z = 0.4;
} else {
message.linear.x = 0.4;
for (int i = 370; i < 720; i++) {
if (msg->ranges[i] < 1.0) {
message.linear.x = 0.0;
message.angular.z = 0.4;
}
}
}
publisher_->publish(message);
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr publisher_;
rclcpp::Subscription<sensor_msgs::msg::LaserScan>::SharedPtr subscription_;
};
int main(int argc, char *argv[]) {
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<MoveRobot>());
rclcpp::shutdown();
return 0;
}
And this is the error that Gradebot gives me:
What is the result of your check of each of the points the gradebot raised? That’s the key to this problem.
Your node should be named topics_quiz_node
class MoveRobot : public rclcpp::Node {
public:
MoveRobot() : Node("topics_quiz_node") {
//instead of "move_robot"
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.