struct move_target_heading {
move_target_op operation;
float angle;
- float distance; /* Distance used by TOP_ARRIVE_FROM */
+ float distance;
+ /* Distance used by TOP_ARRIVE_FROM */
+ move_target_heading(){}
+ move_target_heading(move_target_op op, float ang, float dist) : operation(op), angle(ang), distance(dist) {}
};
-static inline move_target_heading __target_heading(move_target_op op, float angle, float distance) {
- move_target_heading th;
- th.operation = op;
- th.angle = angle;
- th.distance = distance;
- return th;
-}
-
-#define TURN(heading) __target_heading(TOP_TURN_SHORTEST, (heading), 0)
-#define TURN_CW(heading) __target_heading(TOP_TURN_CW, (heading), 0)
-#define TURN_CCW(heading) __target_heading(TOP_TURN_CCW, (heading), 0)
-#define NO_TURN() __target_heading(TOP_DONT_TURN, 0, 0)
-#define ARRIVE_FROM(heading, dist) __target_heading(TOP_ARRIVE_FROM, (heading), (dist))
-
-static inline final_heading target2final_heading(move_target_heading th) {
- final_heading fh;
-
- switch (th.operation) {
- case TOP_DONT_TURN: fh.turn_type = FH_DONT_TURN; break;
- case TOP_TURN_CW: fh.turn_type = FH_CW; break;
- case TOP_TURN_CCW: fh.turn_type = FH_CCW; break;
- case TOP_TURN_SHORTEST: fh.turn_type = FH_SHORTEST; break;
- case TOP_ARRIVE_FROM: fh.turn_type = FH_DONT_TURN; break;
- }
- fh.heading = th.angle;
- return fh;
-}
+#define TURN(heading) move_target_heading(TOP_TURN_SHORTEST, (heading), 0)
+#define TURN_CW(heading) move_target_heading(TOP_TURN_CW, (heading), 0)
+#define TURN_CCW(heading) move_target_heading(TOP_TURN_CCW, (heading), 0)
+#define NO_TURN() move_target_heading(TOP_DONT_TURN, 0, 0)
+#define ARRIVE_FROM(heading, dist) move_target_heading(TOP_ARRIVE_FROM, (heading), (dist))
struct move_target {
double x, y;
class MoveHelper
{
struct Trajectory *t;
+ final_heading fh;
+ move_target_heading mh;
move_target_heading trans_heading(move_target_heading h);
- public:
+public:
/* Low-level trajectory handling */
MoveHelper& trajectory_new(TrajectoryConstraints *tc, bool backward = false);
MoveHelper& trajectory_new_backward(TrajectoryConstraints *tc) {
return trajectory_new(tc, true);
}
MoveHelper& add_point_notrans(double x_m, double y_m);
- void add_final_point_notrans(double x_m, double y_m, move_target_heading heading);
MoveHelper& add_point_trans(double x, double y) {
return add_point_notrans(trans_x(x), trans_y(y));
}
+ void add_final_point_notrans(double x_m, double y_m, move_target_heading heading);
void add_final_point_trans(double x, double y, move_target_heading heading) {
add_final_point_notrans(trans_x(x), trans_y(y), trans_heading(heading));
}
void send_speed(double left, double right);
void goto_notrans(double x, double y, move_target_heading heading, TrajectoryConstraints *tc, bool planning);
- void move_by(double distance, move_target_heading heading, TrajectoryConstraints *tc);
- void stop();
void goto_trans(double x, double y, move_target_heading heading, TrajectoryConstraints *tc) {
goto_notrans(trans_x(x), trans_y(y), trans_heading(heading), tc, true);
}
void moveto_trans(double x, double y, move_target_heading heading, TrajectoryConstraints *tc) {
goto_notrans(trans_x(x), trans_y(y), trans_heading(heading), tc, false);
}
+ void move_by(double distance, move_target_heading heading, TrajectoryConstraints *tc);
void move_by_trans(double distance, move_target_heading heading, TrajectoryConstraints *tc) {
move_by(distance, trans_heading(heading), tc);
}
bool get_arrive_from_point(double target_x_m, double target_y_m, move_target_heading heading, double &point_x_m, double &point_y_m);
+ void stop();
+ final_heading target2final_heading(move_target_heading th);
};
/* Represents the target position of a move. */